~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/PartDesign/Gui/Command.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2010-01-11 08:48:33 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100111084833-4g9vgdqbkw8u34zb
Tags: 0.9.2646.5-1
* New upstream version (closes: #561696).
* Added swig to Build-Depends (closes: #563523, #563772).
* Removed python-opencv from Build-Depends and Recommends (closes: #560768).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "PreCompiled.h"
25
25
#ifndef _PreComp_
 
26
# include <QMessageBox>
26
27
#endif
27
28
 
28
29
#include <Gui/Application.h>
46
47
{
47
48
    sAppModule    = "PartDesign";
48
49
    sGroup        = QT_TR_NOOP("PartDesign");
49
 
    sMenuText     = QT_TR_NOOP("Pad...");
 
50
    sMenuText     = QT_TR_NOOP("Pad");
50
51
    sToolTipText  = QT_TR_NOOP("Pad a selected sketch");
51
52
    sWhatsThis    = sToolTipText;
52
53
    sStatusTip    = sToolTipText;
 
54
    sPixmap       = "PartDesign_Pad";
53
55
    iAccel        = 0;
54
56
}
55
57
 
58
60
    unsigned int n = getSelection().countObjectsOfType(Part::Part2DObject::getClassTypeId());
59
61
    if (n != 1) {
60
62
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
61
 
            QObject::tr("Select a Sketch or 2D object."));
 
63
            QObject::tr("Select a sketch or 2D object."));
62
64
        return;
63
65
    }
64
66
 
69
71
    openCommand("Make Pad");
70
72
    doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Pad\",\"%s\")",FeatName.c_str());
71
73
    doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),Sel[0].FeatName);
72
 
    doCommand(Doc,"App.activeDocument().%s.Dir = (0.0,0.0,-100.0)",FeatName.c_str());
 
74
    doCommand(Doc,"App.activeDocument().%s.Dir = (0.0,0.0,-5.0)",FeatName.c_str());
73
75
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[0].FeatName);
74
76
    updateActive();
75
77
    commitCommand();
91
93
    sAppModule    = "PartDesign";
92
94
    sGroup        = QT_TR_NOOP("PartDesign");
93
95
    sMenuText     = QT_TR_NOOP("Fillet");
94
 
    sToolTipText  = QT_TR_NOOP("Make a fillet on a edge, face or body");
 
96
    sToolTipText  = QT_TR_NOOP("Make a fillet on an edge, face or body");
95
97
    sWhatsThis    = sToolTipText;
96
98
    sStatusTip    = sToolTipText;
 
99
    sPixmap       = "Part_Fillet";
97
100
    iAccel        = 0;
98
101
}
99
102
 
100
103
void CmdPartDesignFillet::activated(int iMsg)
101
104
{
102
 
    unsigned int n = getSelection().countObjectsOfType(Part::Part2DObject::getClassTypeId());
103
 
    if (n != 1) {
 
105
    //unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId());
 
106
 
 
107
        std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
 
108
 
 
109
    if (selection.size() != 1) {
104
110
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
105
 
            QObject::tr("Select a edge, face or body."));
 
111
            QObject::tr("Select an edge, face or body. Only one body is allowed."));
106
112
        return;
107
113
    }
108
114
 
 
115
        if ( ! selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
 
116
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
 
117
            QObject::tr("Fillet works only on parts"));
 
118
        return;
 
119
    }
 
120
        std::string SelString = selection[0].getAsPropertyLinkSubString();
109
121
    std::string FeatName = getUniqueObjectName("Fillet");
110
122
 
111
 
    std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
112
 
 
113
 
    openCommand("Make Pad");
 
123
    openCommand("Make Fillet");
114
124
    doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Fillet\",\"%s\")",FeatName.c_str());
115
 
    doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),Sel[0].FeatName);
116
 
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[0].FeatName);
 
125
    doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
 
126
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
117
127
    updateActive();
118
128
    commitCommand();
119
129
}