+ split create/edit sketch command into two commands

This commit is contained in:
wmayer 2014-07-13 10:17:50 +02:00
parent da708faa5e
commit d7fafdb2b6
6 changed files with 353 additions and 46 deletions

View File

@ -274,6 +274,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*sketch
<< "Sketcher_NewSketch"
<< "Sketcher_EditSketch"
<< "Sketcher_LeaveSketch"
<< "Sketcher_ViewSketch"
<< "Sketcher_MapSketch"

View File

@ -109,6 +109,7 @@ void Workbench::activated()
const char* Sketch[] = {
"Sketcher_NewSketch",
"Sketcher_EditSketch",
"PartDesign_Pad",
"PartDesign_Pocket",
"PartDesign_Revolution",
@ -205,6 +206,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
root->insertItem(item, part);
part->setCommand("&Part Design");
*part << "Sketcher_NewSketch"
<< "Sketcher_EditSketch"
<< "Sketcher_LeaveSketch"
<< "Sketcher_ViewSketch"
<< "Sketcher_MapSketch"

View File

@ -62,7 +62,7 @@ CmdSketcherNewSketch::CmdSketcherNewSketch()
sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("Create sketch");
sToolTipText = QT_TR_NOOP("Create a new or edit the selected sketch");
sToolTipText = QT_TR_NOOP("Create a new sketch");
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Sketcher_NewSketch";
@ -70,15 +70,9 @@ CmdSketcherNewSketch::CmdSketcherNewSketch()
void CmdSketcherNewSketch::activated(int iMsg)
{
Gui::SelectionFilter SketchFilter("SELECT Sketcher::SketchObject COUNT 1");
Gui::SelectionFilter FaceFilter ("SELECT Part::Feature SUBELEMENT Face COUNT 1");
if (SketchFilter.match()) {
Sketcher::SketchObject *Sketch = static_cast<Sketcher::SketchObject*>(SketchFilter.Result[0][0].getObject());
openCommand("Edit Sketch");
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",Sketch->getNameInDocument());
}
else if (FaceFilter.match()) {
if (FaceFilter.match()) {
// get the selected object
Part::Feature *part = static_cast<Part::Feature*>(FaceFilter.Result[0][0].getObject());
Base::Placement ObjectPos = part->Placement.getValue();
@ -181,6 +175,72 @@ bool CmdSketcherNewSketch::isActive(void)
return false;
}
DEF_STD_CMD_A(CmdSketcherEditSketch);
CmdSketcherEditSketch::CmdSketcherEditSketch()
:Command("Sketcher_EditSketch")
{
sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("Edit sketch");
sToolTipText = QT_TR_NOOP("Edit the selected sketch");
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Sketcher_EditSketch";
}
void CmdSketcherEditSketch::activated(int iMsg)
{
Gui::SelectionFilter SketchFilter("SELECT Sketcher::SketchObject COUNT 1");
if (SketchFilter.match()) {
Sketcher::SketchObject *Sketch = static_cast<Sketcher::SketchObject*>(SketchFilter.Result[0][0].getObject());
openCommand("Edit Sketch");
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",Sketch->getNameInDocument());
}
}
bool CmdSketcherEditSketch::isActive(void)
{
return Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 1;
}
DEF_STD_CMD_A(CmdSketcherLeaveSketch);
CmdSketcherLeaveSketch::CmdSketcherLeaveSketch()
: Command("Sketcher_LeaveSketch")
{
sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("Leave sketch");
sToolTipText = QT_TR_NOOP("Close the editing of the sketch");
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Sketcher_LeaveSketch";
eType = 0;
}
void CmdSketcherLeaveSketch::activated(int iMsg)
{
openCommand("Sketch changed");
doCommand(Gui,"Gui.activeDocument().resetEdit()");
doCommand(Doc,"App.ActiveDocument.recompute()");
commitCommand();
}
bool CmdSketcherLeaveSketch::isActive(void)
{
Gui::Document *doc = getActiveGuiDocument();
if (doc) {
// checks if a Sketch Viewprovider is in Edit and is in no special mode
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
if (vp && vp->getSketchMode() == ViewProviderSketch::STATUS_NONE)
return true;
}
return false;
}
DEF_STD_CMD_A(CmdSketcherReorientSketch);
CmdSketcherReorientSketch::CmdSketcherReorientSketch()
@ -368,43 +428,6 @@ bool CmdSketcherMapSketch::isActive(void)
return getActiveGuiDocument() != 0;
}
DEF_STD_CMD_A(CmdSketcherLeaveSketch);
CmdSketcherLeaveSketch::CmdSketcherLeaveSketch()
: Command("Sketcher_LeaveSketch")
{
sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("Leave sketch");
sToolTipText = QT_TR_NOOP("Close the editing of the sketch");
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Sketcher_LeaveSketch";
eType = 0;
}
void CmdSketcherLeaveSketch::activated(int iMsg)
{
openCommand("Sketch changed");
doCommand(Gui,"Gui.activeDocument().resetEdit()");
doCommand(Doc,"App.ActiveDocument.recompute()");
commitCommand();
}
bool CmdSketcherLeaveSketch::isActive(void)
{
Gui::Document *doc = getActiveGuiDocument();
if (doc) {
// checks if a Sketch Viewprovider is in Edit and is in no special mode
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
if (vp && vp->getSketchMode() == ViewProviderSketch::STATUS_NONE)
return true;
}
return false;
}
DEF_STD_CMD_A(CmdSketcherViewSketch);
CmdSketcherViewSketch::CmdSketcherViewSketch()
@ -482,9 +505,10 @@ void CreateSketcherCommands(void)
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new CmdSketcherNewSketch());
rcCmdMgr.addCommand(new CmdSketcherEditSketch());
rcCmdMgr.addCommand(new CmdSketcherLeaveSketch());
rcCmdMgr.addCommand(new CmdSketcherReorientSketch());
rcCmdMgr.addCommand(new CmdSketcherMapSketch());
rcCmdMgr.addCommand(new CmdSketcherLeaveSketch());
rcCmdMgr.addCommand(new CmdSketcherViewSketch());
rcCmdMgr.addCommand(new CmdSketcherValidateSketch());
}

View File

@ -64,6 +64,7 @@
<file>icons/Sketcher_DraftLine.svg</file>
<file>icons/Sketcher_Trimming.svg</file>
<file>icons/Sketcher_External.svg</file>
<file>icons/Sketcher_EditSketch.svg</file>
<file>icons/Sketcher_LeaveSketch.svg</file>
<file>icons/Sketcher_MapSketch.svg</file>
<file>icons/Sketcher_NewSketch.svg</file>

View File

@ -0,0 +1,278 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2726"
sodipodi:version="0.32"
inkscape:version="0.48.0 r9654"
sodipodi:docname="Sketcher_LeaveSketch.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs2728">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2734" />
<inkscape:perspective
id="perspective3045"
inkscape:persp3d-origin="32 : 21.333333 : 1"
inkscape:vp_z="64 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 32 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
gradientUnits="userSpaceOnUse"
y2="1076.6174"
x2="3935.5251"
y1="1286.7291"
x1="3709.3296"
id="linearGradient3847"
xlink:href="#linearGradient3841"
inkscape:collect="always" />
<linearGradient
id="linearGradient3841">
<stop
id="stop3843"
offset="0"
style="stop-color:#0619c0;stop-opacity:1;" />
<stop
id="stop3845"
offset="1"
style="stop-color:#379cfb;stop-opacity:1;" />
</linearGradient>
<inkscape:perspective
id="perspective2971"
inkscape:persp3d-origin="32 : 21.333333 : 1"
inkscape:vp_z="64 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 32 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
gradientUnits="userSpaceOnUse"
y2="1218.0156"
x2="2032.5356"
y1="1218.0156"
x1="1634.3081"
id="linearGradient3376"
xlink:href="#linearGradient3354"
inkscape:collect="always" />
<linearGradient
id="linearGradient3354">
<stop
id="stop3356"
offset="0"
style="stop-color:#2157c7;stop-opacity:1;" />
<stop
id="stop3358"
offset="1"
style="stop-color:#6daaff;stop-opacity:1;" />
</linearGradient>
<inkscape:perspective
id="perspective3238"
inkscape:persp3d-origin="32 : 21.333333 : 1"
inkscape:vp_z="64 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 32 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
y2="711.11219"
x2="2839.0713"
y1="711.11219"
x1="2732.3571"
gradientTransform="matrix(0.7802234,0,0,1,599.85156,0)"
gradientUnits="userSpaceOnUse"
id="linearGradient2403"
xlink:href="#linearGradient3255"
inkscape:collect="always" />
<linearGradient
id="linearGradient3255"
inkscape:collect="always">
<stop
id="stop3257"
offset="0"
style="stop-color:#ffffff;stop-opacity:1;" />
<stop
id="stop3259"
offset="1"
style="stop-color:#ffffff;stop-opacity:0;" />
</linearGradient>
<linearGradient
y2="671.11081"
x2="2900.148"
y1="671.11081"
x1="2754.6858"
gradientTransform="matrix(-1,0,0,-1,5656.8338,1344.2216)"
gradientUnits="userSpaceOnUse"
id="linearGradient2405"
xlink:href="#linearGradient3293"
inkscape:collect="always" />
<linearGradient
id="linearGradient3293"
inkscape:collect="always">
<stop
id="stop3295"
offset="0"
style="stop-color:#808000;stop-opacity:1;" />
<stop
id="stop3297"
offset="1"
style="stop-color:#808000;stop-opacity:0;" />
</linearGradient>
<linearGradient
y2="671.11081"
x2="2900.148"
y1="671.11081"
x1="2754.6858"
gradientTransform="matrix(-1,0,0,-1,5656.8338,1376.2216)"
gradientUnits="userSpaceOnUse"
id="linearGradient2407"
xlink:href="#linearGradient3293"
inkscape:collect="always" />
<linearGradient
y2="671.11081"
x2="2900.148"
y1="671.11081"
x1="2754.6858"
gradientTransform="matrix(-1,0,0,-1,5656.8338,1408.2216)"
gradientUnits="userSpaceOnUse"
id="linearGradient2409"
xlink:href="#linearGradient3293"
inkscape:collect="always" />
<radialGradient
r="38.829369"
fy="552.89736"
fx="2787.5991"
cy="552.89736"
cx="2787.5991"
gradientTransform="matrix(1,0,0,1.0807499,0,-44.646407)"
gradientUnits="userSpaceOnUse"
id="radialGradient2411"
xlink:href="#linearGradient3273"
inkscape:collect="always" />
<linearGradient
id="linearGradient3273"
inkscape:collect="always">
<stop
id="stop3275"
offset="0"
style="stop-color:#ffffff;stop-opacity:1;" />
<stop
id="stop3277"
offset="1"
style="stop-color:#ffffff;stop-opacity:0;" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="8.046875"
inkscape:cx="32"
inkscape:cy="32"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1092"
inkscape:window-height="722"
inkscape:window-x="69"
inkscape:window-y="42"
inkscape:window-maximized="0" />
<metadata
id="metadata2731">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
inkscape:label="Layer 1"
id="g3363"
transform="matrix(-0.4354254,0,0,-0.6347203,47.20712,47.435633)">
<g
transform="matrix(0.1731146,0,0,0.1731146,-635.22048,-168.53671)"
inkscape:export-ydpi="8.71"
inkscape:export-xdpi="8.71"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/upgrade.png"
id="g3853">
<path
style="opacity:0.60792954;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 3875.9311,1028.0961 -149.5,155.5625 84.8437,0 0,139.4063 127.2813,0 0,-139.4063 76.7813,0 -139.4063,-155.5625 z"
id="path3849"
inkscape:connector-curvature="0" />
<path
style="fill:url(#linearGradient3847);fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 3848.6875,999.84375 -149.5,155.56245 84.8437,0 0,139.4063 127.2813,0 0,-139.4063 76.7813,0 -139.4063,-155.56245 z"
id="rect3066"
inkscape:connector-curvature="0" />
</g>
</g>
<g
inkscape:label="Layer 1"
id="g3436"
transform="translate(107.50353,10.589633)" />
<rect
style="fill:#323232;fill-opacity:1;stroke:#323232;stroke-width:0.99242818;stroke-opacity:1"
id="rect3450"
width="13.890088"
height="3.7927058"
x="7.0579472"
y="34.724739" />
<rect
style="fill:#323232;fill-opacity:1;stroke:#323232;stroke-opacity:1"
id="rect3452"
width="14.13106"
height="3.7851338"
x="44.159561"
y="34.854675" />
<rect
style="fill:#323232;fill-opacity:1;stroke:#323232;stroke-width:1.70863736;stroke-opacity:1"
id="rect3454"
width="50.757404"
height="3.0764964"
x="7.1788988"
y="55.143879" />
<rect
style="fill:#323232;fill-opacity:1;stroke:#323232;stroke-width:1.05181527;stroke-opacity:1"
id="rect3456"
width="15.839073"
height="3.7359855"
x="38.737869"
y="-58.021709"
transform="matrix(2.5335968e-3,0.9999968,-0.9999995,-1.0227786e-3,0,0)" />
<rect
style="fill:#323232;fill-opacity:1;stroke:#323232;stroke-width:1.05181527;stroke-opacity:1"
id="rect3458"
width="15.839075"
height="3.7359855"
x="38.110561"
y="-10.813628"
transform="matrix(-2.4670029e-3,0.999997,-0.9999819,-6.0233492e-3,0,0)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -108,6 +108,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*sketch
<< "Sketcher_NewSketch"
<< "Sketcher_EditSketch"
<< "Sketcher_LeaveSketch"
<< "Sketcher_ViewSketch"
<< "Sketcher_MapSketch"