Setup ShapeBinder Viewprovider and command
This commit is contained in:
parent
811ccc410c
commit
e58ae2b616
|
@ -101,13 +101,13 @@ TopoShape ShapeBinder::buildShapeFromReferences(std::vector< App::DocumentObject
|
|||
if(objs[index] != obj)
|
||||
continue;
|
||||
|
||||
//in this mode the full shape is allowed, as we already started the subshape
|
||||
//prcessing
|
||||
//in this mode the full shape is not allowed, as we already started the subshape
|
||||
//processing
|
||||
if(sub.empty())
|
||||
continue;
|
||||
|
||||
if(base.isNull())
|
||||
base = obj->Shape.getShape();
|
||||
base = obj->Shape.getShape().getSubShape(sub.c_str());
|
||||
else
|
||||
operators.push_back(obj->Shape.getShape().getSubShape(sub.c_str()));
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include <Mod/PartDesign/App/DatumPoint.h>
|
||||
#include <Mod/PartDesign/App/DatumLine.h>
|
||||
#include <Mod/PartDesign/App/DatumPlane.h>
|
||||
#include <Mod/PartDesign/App/ShapeBinder.h>
|
||||
|
||||
#include "TaskFeaturePick.h"
|
||||
#include "ReferenceSelection.h"
|
||||
|
@ -214,6 +215,80 @@ bool CmdPartDesignPoint::isActive(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// PartDesign_ShapeBinder
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdPartDesignShapeBinder);
|
||||
|
||||
CmdPartDesignShapeBinder::CmdPartDesignShapeBinder()
|
||||
:Command("PartDesign_ShapeBinder")
|
||||
{
|
||||
sAppModule = "PartDesign";
|
||||
sGroup = QT_TR_NOOP("PartDesign");
|
||||
sMenuText = QT_TR_NOOP("Create a shape binder");
|
||||
sToolTipText = QT_TR_NOOP("Create a new shape binder");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "PartDesign_ShapeBinder";
|
||||
}
|
||||
|
||||
void CmdPartDesignShapeBinder::activated(int iMsg)
|
||||
{
|
||||
App::PropertyLinkSubList support;
|
||||
getSelection().getAsPropertyLinkSubList(support);
|
||||
|
||||
bool bEditSelected = false;
|
||||
if (support.getSize() == 1 && support.getValue() ){
|
||||
if (support.getValue()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) ||
|
||||
support.getValue()->isDerivedFrom(PartDesign::ShapeBinder2D::getClassTypeId()))
|
||||
bEditSelected = true;
|
||||
}
|
||||
|
||||
if (bEditSelected) {
|
||||
std::string tmp = std::string("Edit ShapeBinder");
|
||||
openCommand(tmp.c_str());
|
||||
doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s')",
|
||||
support.getValue()->getNameInDocument());
|
||||
} else {
|
||||
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
|
||||
if (pcActiveBody == 0)
|
||||
return;
|
||||
|
||||
std::string FeatName = getUniqueObjectName("ShapeBinder");
|
||||
std::string tmp = std::string("Create ShapeBinder");
|
||||
|
||||
openCommand(tmp.c_str());
|
||||
|
||||
if(support.getValue()->isDerivedFrom(PartDesign::ShapeBinder2D::getClassTypeId()) ||
|
||||
support.getValue()->isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
doCommand(Gui::Command::Doc,"App.activeDocument().addObject('%s','%s')",
|
||||
"PartDesign::ShapeBinder2D",FeatName.c_str());
|
||||
} else {
|
||||
doCommand(Gui::Command::Doc,"App.activeDocument().addObject('%s','%s')",
|
||||
"PartDesign::ShapeBinder",FeatName.c_str());
|
||||
}
|
||||
|
||||
//test if current selection fits a mode.
|
||||
if (support.getSize() > 0) {
|
||||
AttachableObject* pcDatum = static_cast<AttachableObject*>(
|
||||
getDocument()->getObject(FeatName.c_str()));
|
||||
doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = %s",
|
||||
FeatName.c_str(),support.getPyReprString().c_str());
|
||||
}
|
||||
doCommand(Gui::Command::Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)",
|
||||
pcActiveBody->getNameInDocument(), FeatName.c_str());
|
||||
doCommand(Gui::Command::Doc,"App.activeDocument().recompute()"); // recompute the feature based on its references
|
||||
doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
}
|
||||
// TODO do a proper error processing (2015-09-11, Fat-Zer)
|
||||
}
|
||||
|
||||
bool CmdPartDesignShapeBinder::isActive(void)
|
||||
{
|
||||
return hasActiveDocument ();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// PartDesign_Sketch
|
||||
//===========================================================================
|
||||
|
@ -667,7 +742,7 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
// If there is more than one selection/possibility, show dialog and let user pick sketch
|
||||
if ((bNoSketchWasSelected && validSketches > 1) ||
|
||||
(!bNoSketchWasSelected && sketches.size() > 1) ||
|
||||
(!bNoSketchWasSelected && ext) ) {
|
||||
(!bNoSketchWasSelected && ext) ) {
|
||||
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast<PartDesignGui::TaskDlgFeaturePick *>(dlg);
|
||||
|
@ -689,7 +764,7 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
|
||||
Gui::Selection().clearSelection();
|
||||
pickDlg = new PartDesignGui::TaskDlgFeaturePick(sketches, status, accepter, worker);
|
||||
if(!bNoSketchWasSelected && ext)
|
||||
if(!bNoSketchWasSelected && ext)
|
||||
pickDlg->showExternal(true);
|
||||
|
||||
Gui::Control().showDialog(pickDlg);
|
||||
|
@ -1741,6 +1816,7 @@ void CreatePartDesignCommands(void)
|
|||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
|
||||
rcCmdMgr.addCommand(new CmdPartDesignShapeBinder());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignPlane());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignLine());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignPoint());
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<file>icons/PartDesign_Hole.svg</file>
|
||||
<file>icons/PartDesign_Body.svg</file>
|
||||
<file>icons/PartDesign_Boolean.svg</file>
|
||||
<file>icons/PartDesign_ShapeBinder.svg</file>
|
||||
<file>icons/PartDesign_Plane.svg</file>
|
||||
<file>icons/PartDesign_Line.svg</file>
|
||||
<file>icons/PartDesign_Point.svg</file>
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
<?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="svg3052"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="PartDesign_ShapeBinder.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
version="1.1">
|
||||
<defs
|
||||
id="defs3054">
|
||||
<linearGradient
|
||||
id="linearGradient4189">
|
||||
<stop
|
||||
id="stop4191"
|
||||
offset="0"
|
||||
style="stop-color:#064d9a;stop-opacity:1" />
|
||||
<stop
|
||||
id="stop4193"
|
||||
offset="1"
|
||||
style="stop-color:#7499ff;stop-opacity:1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4032">
|
||||
<stop
|
||||
style="stop-color:#71b2f8;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4034" />
|
||||
<stop
|
||||
style="stop-color:#002795;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop4036" />
|
||||
</linearGradient>
|
||||
<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="perspective3060" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3377"
|
||||
id="radialGradient3705"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cx="148.88333"
|
||||
cy="81.869568"
|
||||
fx="148.88333"
|
||||
fy="81.869568"
|
||||
r="19.467436"
|
||||
gradientTransform="matrix(1.6244669,-0.05136783,0.04345521,0.9993132,-102.99033,7.7040438)" />
|
||||
<linearGradient
|
||||
id="linearGradient3377">
|
||||
<stop
|
||||
id="stop3379"
|
||||
offset="0"
|
||||
style="stop-color:#4bff54;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3381"
|
||||
offset="1"
|
||||
style="stop-color:#00b800;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3206"
|
||||
id="radialGradient3703"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cx="135.38333"
|
||||
cy="97.369568"
|
||||
fx="135.38333"
|
||||
fy="97.369568"
|
||||
r="19.467436"
|
||||
gradientTransform="matrix(0.87904684,0.2250379,-0.41709097,2.0016728,56.73751,-127.99883)" />
|
||||
<linearGradient
|
||||
id="linearGradient3199">
|
||||
<stop
|
||||
id="stop3201"
|
||||
offset="0"
|
||||
style="stop-color:#faff2b;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3203"
|
||||
offset="1"
|
||||
style="stop-color:#ffaa00;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3377"
|
||||
id="radialGradient3692"
|
||||
cx="45.883327"
|
||||
cy="28.869568"
|
||||
fx="45.883327"
|
||||
fy="28.869568"
|
||||
r="19.467436"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
id="linearGradient3206">
|
||||
<stop
|
||||
id="stop3208"
|
||||
offset="0"
|
||||
style="stop-color:#faff2b;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3210"
|
||||
offset="1"
|
||||
style="stop-color:#ffaa00;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4032"
|
||||
id="radialGradient4030"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.260164,-0.05136783,0.03370995,0.9993132,-43.139781,7.2044077)"
|
||||
cx="148.88333"
|
||||
cy="81.869568"
|
||||
fx="148.88333"
|
||||
fy="81.869568"
|
||||
r="19.467436" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4189"
|
||||
id="radialGradient4187"
|
||||
cx="35.436966"
|
||||
cy="41.607136"
|
||||
fx="35.436966"
|
||||
fy="41.607136"
|
||||
r="30.506065"
|
||||
gradientTransform="matrix(1,0,0,1.0210373,-0.68828645,-0.79147572)"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="8.7173008"
|
||||
inkscape:cx="-10.847173"
|
||||
inkscape:cy="49.396719"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:window-width="1848"
|
||||
inkscape:window-height="1043"
|
||||
inkscape:window-x="66"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata3057">
|
||||
<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">
|
||||
<path
|
||||
style="fill:url(#radialGradient4187);fill-opacity:1;fill-rule:evenodd;stroke:#0040ff;stroke-width:4.69999981;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 6.1945781,28.667963 C 4.1297187,46.56341 2.2942882,39.451117 4.1297187,46.56341 c 1.8354306,7.112294 9.8654393,4.359148 19.0425923,9.406582 9.177153,5.047434 14.454015,6.309292 22.598738,3.212003 8.144723,-3.097289 -3.097289,-12.848013 -0.573572,-21.566308 2.523717,-8.718295 12.274442,-16.977733 12.274442,-16.977733 0,0 5.965149,-4.015004 -1.606002,-13.3068716 -7.571151,-9.291867 -23.17231,0.2294288 -23.17231,0.2294288 l -0.344143,0 c 0,0 -4.015005,3.4414328 -10.439012,0.2294289 C 15.486446,4.5779366 6.5387213,3.3160781 5.3915772,9.740085 4.2444331,16.164092 6.1945781,28.667963 6.1945781,28.667963 Z"
|
||||
id="path4179"
|
||||
inkscape:connector-curvature="0" />
|
||||
<ellipse
|
||||
style="fill:#ff0900;fill-opacity:1;fill-rule:nonzero;stroke:#ff0900;stroke-width:1.04872465;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="path3078"
|
||||
cx="55.873356"
|
||||
cy="6.2061419"
|
||||
rx="3.9230394"
|
||||
ry="3.9230397" />
|
||||
<ellipse
|
||||
style="fill:#ff0900;fill-opacity:1;fill-rule:nonzero;stroke:#ff0900;stroke-width:1.10121942;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="path3078-5"
|
||||
cx="46.200706"
|
||||
cy="58.597679"
|
||||
rx="4.0590229"
|
||||
ry="4.180696" />
|
||||
<ellipse
|
||||
style="fill:#ff0900;fill-opacity:1;fill-rule:nonzero;stroke:#ff0900;stroke-width:1.10121942;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="path3078-5-4"
|
||||
cx="6.6248178"
|
||||
cy="26.886995"
|
||||
rx="4.0590229"
|
||||
ry="4.180696" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 7.0 KiB |
|
@ -38,6 +38,24 @@ PROPERTY_SOURCE(PartDesignGui::ViewProviderShapeBinder,PartGui::ViewProviderPart
|
|||
ViewProviderShapeBinder::ViewProviderShapeBinder()
|
||||
{
|
||||
sPixmap = "PartDesign_ShapeBinder.svg";
|
||||
|
||||
//make the viewprovider more datum like
|
||||
AngularDeflection.StatusBits.set(3, true);
|
||||
Deviation.StatusBits.set(3, true);
|
||||
DrawStyle.StatusBits.set(3, true);
|
||||
Lighting.StatusBits.set(3, true);
|
||||
LineColor.StatusBits.set(3, true);
|
||||
LineWidth.StatusBits.set(3, true);
|
||||
PointColor.StatusBits.set(3, true);
|
||||
PointSize.StatusBits.set(3, true);
|
||||
ShapeColor.StatusBits.set(3, true);
|
||||
Transparency.StatusBits.set(3, true);
|
||||
|
||||
//get the datum coloring sheme
|
||||
ShapeColor.setValue(App::Color(0.9f, 0.9f, 0.13f, 0.5f));
|
||||
LineColor.setValue(App::Color(0.9f, 0.9f, 0.13f, 0.5f));
|
||||
PointColor.setValue(App::Color(0.9f, 0.9f, 0.13f, 0.5f));
|
||||
LineWidth.setValue(1);
|
||||
}
|
||||
|
||||
ViewProviderShapeBinder::~ViewProviderShapeBinder()
|
||||
|
|
|
@ -462,6 +462,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
<< "PartDesign_Point"
|
||||
<< "PartDesign_Line"
|
||||
<< "PartDesign_Plane"
|
||||
<< "PartDesign_ShapeBinder"
|
||||
<< "Separator"
|
||||
<< "PartDesign_Pad"
|
||||
<< "PartDesign_Pocket"
|
||||
|
@ -521,6 +522,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
<< "PartDesign_Point"
|
||||
<< "PartDesign_Line"
|
||||
<< "PartDesign_Plane"
|
||||
<< "PartDesign_ShapeBinder"
|
||||
<< "Separator"
|
||||
<< "PartDesign_CompPrimitiveAdditive"
|
||||
<< "PartDesign_CompPrimitiveSubtractive"
|
||||
|
|
Loading…
Reference in New Issue
Block a user