Setup ShapeBinder Viewprovider and command
This commit is contained in:
@@ -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>
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
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"
|
||||
|
||||
Reference in New Issue
Block a user