Made the rest of the PartDesign features aware of the Body

This commit is contained in:
jrheinlaender
2013-04-21 09:24:12 +04:30
committed by Stefan Tröger
parent 4bb14de504
commit 7330d4357e
19 changed files with 923 additions and 746 deletions

View File

@@ -23,6 +23,12 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <TopoDS_Shape.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <QApplication>
# include <QInputDialog>
# include <BRep_Tool.hxx>
# include <TopExp_Explorer.hxx>
# include <TopoDS.hxx>
@@ -55,10 +61,13 @@
#include <Gui/ViewProviderDocumentObject.h>
#include <Mod/Part/App/Part2DObject.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/DatumFeature.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Mod/Sketcher/Gui/SketchOrientationDialog.h>
#include <Mod/PartDesign/App/FeatureAdditive.h>
#include <Mod/PartDesign/App/FeatureSubtractive.h>
#include <Mod/PartDesign/App/FeatureGroove.h>
#include <Mod/PartDesign/App/FeatureRevolution.h>
@@ -626,6 +635,36 @@ bool CmdPartDesignNewSketch::isActive(void)
return false;
}
//===========================================================================
// Common utility functions for all features creating solids
//===========================================================================
void finishFeature(const Gui::Command* cmd, const std::string& FeatName)
{
PartDesign::Body *pcActiveBody = PartDesignGui::getBody();
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
if (cmd->isActiveObjectValid() && (pcActiveBody != NULL)) {
App::DocumentObject* prevSolidFeature = pcActiveBody->getPrevSolidFeature(NULL, false);
if (prevSolidFeature != NULL)
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", prevSolidFeature->getNameInDocument());
}
cmd->updateActive();
// #0001721: use '0' as edit value to avoid switching off selection in
// ViewProviderGeometryObject::setEditViewer
cmd->doCommand(cmd->Gui,"Gui.activeDocument().setEdit('%s', 0)", FeatName.c_str());
cmd->doCommand(cmd->Gui,"Gui.Selection.clearSelection()");
//cmd->doCommand(cmd->Gui,"Gui.Selection.addSelection(App.ActiveDocument.ActiveObject)");
if (pcActiveBody) {
cmd->copyVisual(FeatName.c_str(), "ShapeColor", pcActiveBody->getNameInDocument());
cmd->copyVisual(FeatName.c_str(), "LineColor", pcActiveBody->getNameInDocument());
cmd->copyVisual(FeatName.c_str(), "PointColor", pcActiveBody->getNameInDocument());
}
}
//===========================================================================
// Common utility functions for SketchBased features
//===========================================================================
@@ -735,41 +774,14 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which, Part::Part2
which.c_str(), FeatName.c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.Sketch = App.activeDocument().%s",
FeatName.c_str(), sketch->getNameInDocument());
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
}
void finishSketchBased(const Gui::Command* cmd, const Part::Part2DObject* sketch, const std::string& FeatName)
{
App::DocumentObjectGroup* grp = sketch->getGroup();
if (grp) {
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
,grp->getNameInDocument(),sketch->getNameInDocument());
}
PartDesign::Body *pcActiveBody = PartDesignGui::getBody();
if (cmd->isActiveObjectValid()) {
if (cmd->isActiveObjectValid())
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", sketch->getNameInDocument());
if (pcActiveBody != NULL) {
App::DocumentObject* prevSolidFeature = pcActiveBody->getPrevSolidFeature(NULL, false);
if (prevSolidFeature != NULL)
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", prevSolidFeature->getNameInDocument());
}
}
cmd->updateActive();
// #0001721: use '0' as edit value to avoid switching off selection in
// ViewProviderGeometryObject::setEditViewer
cmd->doCommand(cmd->Gui,"Gui.activeDocument().setEdit('%s', 0)", FeatName.c_str());
cmd->doCommand(cmd->Gui,"Gui.Selection.clearSelection()");
cmd->doCommand(cmd->Gui,"Gui.Selection.addSelection(App.ActiveDocument.ActiveObject)");
if (pcActiveBody) {
cmd->copyVisual(FeatName.c_str(), "ShapeColor", pcActiveBody->getNameInDocument());
cmd->copyVisual(FeatName.c_str(), "LineColor", pcActiveBody->getNameInDocument());
cmd->copyVisual(FeatName.c_str(), "PointColor", pcActiveBody->getNameInDocument());
}
finishFeature(cmd, FeatName);
}
//===========================================================================
@@ -924,25 +936,16 @@ bool CmdPartDesignGroove::isActive(void)
}
//===========================================================================
// PartDesign_Fillet
// Common utility functions for Dressup features
//===========================================================================
DEF_STD_CMD_A(CmdPartDesignFillet);
CmdPartDesignFillet::CmdPartDesignFillet()
:Command("PartDesign_Fillet")
void makeChamferOrFillet(Gui::Command* cmd, const std::string& which)
{
sAppModule = "PartDesign";
sGroup = QT_TR_NOOP("PartDesign");
sMenuText = QT_TR_NOOP("Fillet");
sToolTipText = QT_TR_NOOP("Make a fillet on an edge, face or body");
sWhatsThis = "PartDesign_Fillet";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Fillet";
}
PartDesign::Body *pcActiveBody = PartDesignGui::getBody();
if (!pcActiveBody)
return;
void CmdPartDesignFillet::activated(int iMsg)
{
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@@ -952,7 +955,7 @@ void CmdPartDesignFillet::activated(int iMsg)
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
QObject::tr("Fillet works only on parts."));
QString::fromStdString(which) + QObject::tr(" works only on parts."));
return;
}
@@ -1032,13 +1035,13 @@ void CmdPartDesignFillet::activated(int iMsg)
if (SubNames.size() == 0) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("No fillet possible on selected faces/edges."));
QString::fromStdString(which) + QObject::tr(" not possible on selected faces/edges."));
return;
}
std::string SelString;
SelString += "(App.";
SelString += "ActiveDocument";//getObject()->getDocument()->getName();
SelString += "ActiveDocument";
SelString += ".";
SelString += selection[0].getFeatName();
SelString += ",[";
@@ -1051,23 +1054,35 @@ void CmdPartDesignFillet::activated(int iMsg)
}
SelString += "])";
std::string FeatName = getUniqueObjectName("Fillet");
std::string FeatName = cmd->getUniqueObjectName(which.c_str());
openCommand("Make Fillet");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Fillet\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
cmd->openCommand((std::string("Make ") + which).c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().addObject(\"PartDesign::%s\",\"%s\")",which.c_str(), FeatName.c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
doCommand(Gui,"Gui.Selection.clearSelection()");
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
App::DocumentObjectGroup* grp = base->getGroup();
if (grp) {
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
}
finishFeature(cmd, FeatName);
}
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
//===========================================================================
// PartDesign_Fillet
//===========================================================================
DEF_STD_CMD_A(CmdPartDesignFillet);
CmdPartDesignFillet::CmdPartDesignFillet()
:Command("PartDesign_Fillet")
{
sAppModule = "PartDesign";
sGroup = QT_TR_NOOP("PartDesign");
sMenuText = QT_TR_NOOP("Fillet");
sToolTipText = QT_TR_NOOP("Make a fillet on an edge, face or body");
sWhatsThis = "PartDesign_Fillet";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Fillet";
}
void CmdPartDesignFillet::activated(int iMsg)
{
makeChamferOrFillet(this, "Fillet");
}
bool CmdPartDesignFillet::isActive(void)
@@ -1094,133 +1109,8 @@ CmdPartDesignChamfer::CmdPartDesignChamfer()
void CmdPartDesignChamfer::activated(int iMsg)
{
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select an edge, face or body. Only one body is allowed."));
return;
}
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
QObject::tr("Chamfer works only on parts."));
return;
}
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
const Part::TopoShape& TopShape = base->Shape.getShape();
if (TopShape._Shape.IsNull()){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Shape of selected part is empty."));
return;
}
TopTools_IndexedMapOfShape mapOfEdges;
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
TopExp::MapShapesAndAncestors(TopShape._Shape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
TopExp::MapShapes(TopShape._Shape, TopAbs_EDGE, mapOfEdges);
std::vector<std::string> SubNames = std::vector<std::string>(selection[0].getSubNames());
unsigned int i = 0;
while(i < SubNames.size())
{
std::string aSubName = static_cast<std::string>(SubNames.at(i));
if (aSubName.size() > 4 && aSubName.substr(0,4) == "Edge") {
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(aSubName.c_str()));
const TopTools_ListOfShape& los = mapEdgeFace.FindFromKey(edge);
if(los.Extent() != 2)
{
SubNames.erase(SubNames.begin()+i);
continue;
}
const TopoDS_Shape& face1 = los.First();
const TopoDS_Shape& face2 = los.Last();
GeomAbs_Shape cont = BRep_Tool::Continuity(TopoDS::Edge(edge),
TopoDS::Face(face1),
TopoDS::Face(face2));
if (cont != GeomAbs_C0) {
SubNames.erase(SubNames.begin()+i);
continue;
}
i++;
}
else if(aSubName.size() > 4 && aSubName.substr(0,4) == "Face") {
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str()));
TopTools_IndexedMapOfShape mapOfFaces;
TopExp::MapShapes(face, TopAbs_EDGE, mapOfFaces);
for(int j = 1; j <= mapOfFaces.Extent(); ++j) {
TopoDS_Edge edge = TopoDS::Edge(mapOfFaces.FindKey(j));
int id = mapOfEdges.FindIndex(edge);
std::stringstream buf;
buf << "Edge";
buf << id;
if(std::find(SubNames.begin(),SubNames.end(),buf.str()) == SubNames.end())
{
SubNames.push_back(buf.str());
}
}
SubNames.erase(SubNames.begin()+i);
}
// empty name or any other sub-element
else {
SubNames.erase(SubNames.begin()+i);
}
}
if (SubNames.size() == 0) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("No chamfer possible on selected faces/edges."));
return;
}
std::string SelString;
SelString += "(App.";
SelString += "ActiveDocument";//getObject()->getDocument()->getName();
SelString += ".";
SelString += selection[0].getFeatName();
SelString += ",[";
for(std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
SelString += "\"";
SelString += *it;
SelString += "\"";
if(it != --SubNames.end())
SelString += ",";
}
SelString += "])";
std::string FeatName = getUniqueObjectName("Chamfer");
openCommand("Make Chamfer");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Chamfer\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
makeChamferOrFillet(this, "Chamfer");
doCommand(Gui,"Gui.Selection.clearSelection()");
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
App::DocumentObjectGroup* grp = base->getGroup();
if (grp) {
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
}
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
}
bool CmdPartDesignChamfer::isActive(void)
@@ -1247,6 +1137,9 @@ CmdPartDesignDraft::CmdPartDesignDraft()
void CmdPartDesignDraft::activated(int iMsg)
{
PartDesign::Body *pcActiveBody = PartDesignGui::getBody();
if (!pcActiveBody) return;
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
if (selection.size() < 1) {
@@ -1263,6 +1156,12 @@ void CmdPartDesignDraft::activated(int iMsg)
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
if (base != pcActiveBody->Tip.getValue()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong base feature"),
QObject::tr("Only the current Tip of the active Body can be selected as the base feature"));
return;
}
const Part::TopoShape& TopShape = base->Shape.getShape();
if (TopShape._Shape.IsNull()){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@@ -1323,20 +1222,8 @@ void CmdPartDesignDraft::activated(int iMsg)
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Draft\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
doCommand(Doc,"App.activeDocument().%s.Angle = %f",FeatName.c_str(), 1.5);
updateActive();
if (isActiveObjectValid()) {
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
}
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
App::DocumentObjectGroup* grp = base->getGroup();
if (grp) {
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
}
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
finishFeature(this, FeatName);
}
bool CmdPartDesignDraft::isActive(void)
@@ -1379,7 +1266,7 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
}
}
FeatName = cmd->getUniqueObjectName("Mirrored");
FeatName = cmd->getUniqueObjectName(which.c_str());
std::stringstream str;
str << "App.activeDocument()." << FeatName << ".Originals = [";
@@ -1389,6 +1276,21 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
}
str << "]";
selNames = str.str();
cmd->openCommand((std::string("Make ") + which + " feature").c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().addObject(\"PartDesign::%s\",\"%s\")",which.c_str(), FeatName.c_str());
// FIXME: There seems to be kind of a race condition here, leading to sporadic errors like
// Exception (Thu Sep 6 11:52:01 2012): 'App.Document' object has no attribute 'Mirrored'
cmd->updateActive(); // Helps to ensure that the object already exists when the next command comes up
cmd->doCommand(cmd->Doc,selNames.c_str());
}
void finishTransformed(Gui::Command* cmd, std::string& FeatName, std::vector<std::string>& selList)
{
//for (std::vector<std::string>::iterator it = selList.begin(); it != selList.end(); ++it)
// cmd->doCommand(cmd->Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
finishFeature(cmd, FeatName);
}
//===========================================================================
@@ -1417,23 +1319,12 @@ void CmdPartDesignMirrored::activated(int iMsg)
if (features.empty())
return;
openCommand("Mirrored");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Mirrored\",\"%s\")",FeatName.c_str());
// FIXME: There seems to be kind of a race condition here, leading to sporadic errors like
// Exception (Thu Sep 6 11:52:01 2012): 'App.Document' object has no attribute 'Mirrored'
updateActive(); // Helps to ensure that the object already exists when the next command comes up
doCommand(Doc,selNames.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.MirrorPlane = (App.activeDocument().%s, [\"V_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
for (std::vector<std::string>::iterator it = selList.begin(); it != selList.end(); ++it)
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
copyVisual(FeatName.c_str(), "ShapeColor", selList.front().c_str());
copyVisual(FeatName.c_str(), "DisplayMode", selList.front().c_str());
finishTransformed(this, FeatName, selList);
}
bool CmdPartDesignMirrored::isActive(void)
@@ -1467,30 +1358,14 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
if (features.empty())
return;
openCommand("LinearPattern");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",FeatName.c_str());
updateActive();
doCommand(Doc,selNames.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Length = 100", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
for (std::vector<std::string>::iterator it = selList.begin(); it != selList.end(); ++it)
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
App::DocumentObjectGroup* grp = sketch->getGroup();
if (grp) {
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
,grp->getNameInDocument(),sketch->getNameInDocument());
}
copyVisual(FeatName.c_str(), "ShapeColor", selList.front().c_str());
copyVisual(FeatName.c_str(), "DisplayMode", selList.front().c_str());
finishTransformed(this, FeatName, selList);
}
bool CmdPartDesignLinearPattern::isActive(void)
@@ -1524,30 +1399,14 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
if (features.empty())
return;
openCommand("PolarPattern");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",FeatName.c_str());
updateActive();
doCommand(Doc,selNames.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"N_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Angle = 360", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
for (std::vector<std::string>::iterator it = selList.begin(); it != selList.end(); ++it)
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
App::DocumentObjectGroup* grp = sketch->getGroup();
if (grp) {
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
,grp->getNameInDocument(),sketch->getNameInDocument());
}
copyVisual(FeatName.c_str(), "ShapeColor", selList.front().c_str());
copyVisual(FeatName.c_str(), "DisplayMode", selList.front().c_str());
finishTransformed(this, FeatName, selList);
}
bool CmdPartDesignPolarPattern::isActive(void)
@@ -1581,19 +1440,10 @@ void CmdPartDesignScaled::activated(int iMsg)
if (features.empty())
return;
openCommand("Scaled");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Scaled\",\"%s\")",FeatName.c_str());
updateActive();
doCommand(Doc,selNames.c_str());
doCommand(Doc,"App.activeDocument().%s.Factor = 2", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
for (std::vector<std::string>::iterator it = selList.begin(); it != selList.end(); ++it)
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
copyVisual(FeatName.c_str(), "ShapeColor", selList.front().c_str());
copyVisual(FeatName.c_str(), "DisplayMode", selList.front().c_str());
finishTransformed(this, FeatName, selList);
}
bool CmdPartDesignScaled::isActive(void)
@@ -1627,15 +1477,21 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
if (features.empty())
return;
openCommand("MultiTransform");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::MultiTransform\",\"%s\")",FeatName.c_str());
PartDesign::Body *pcActiveBody = PartDesignGui::getBody();
if (!pcActiveBody)
return;
updateActive();
doCommand(Doc,selNames.c_str());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
// Make sure the user isn't presented with an empty screen because no transformations are defined yet...
App::DocumentObject* prevSolid = pcActiveBody->getPrevSolidFeature(NULL, true);
if (prevSolid != NULL) {
Part::Feature* feat = static_cast<Part::Feature*>(prevSolid);
doCommand(Doc,"App.activeDocument().%s.Shape = App.activeDocument().%s.Shape",
FeatName.c_str(), feat->getNameInDocument());
}
copyVisual(FeatName.c_str(), "ShapeColor", selList.front().c_str());
copyVisual(FeatName.c_str(), "DisplayMode", selList.front().c_str());
finishFeature(this, FeatName);
}
bool CmdPartDesignMultiTransform::isActive(void)

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,7 @@
#include "ui_TaskChamferParameters.h"
#include "TaskChamferParameters.h"
#include "Workbench.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
@@ -40,6 +41,7 @@
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeatureChamfer.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -154,19 +156,20 @@ bool TaskDlgChamferParameters::accept()
bool TaskDlgChamferParameters::reject()
{
// get the support and Sketch
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(ChamferView->getObject());
App::DocumentObject *pcSupport;
pcSupport = pcChamfer->Base.getValue();
// role back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the support is visible again
if (!Gui::Application::Instance->getViewProvider(pcChamfer)) {
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
// Body housekeeping
if (ActivePartObject != NULL) {
// Make the new Tip and the previous solid feature visible again
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
if (tip != NULL) {
Gui::Application::Instance->getViewProvider(tip)->show();
if ((tip != prev) && (prev != NULL))
Gui::Application::Instance->getViewProvider(prev)->show();
}
}
return true;

View File

@@ -29,6 +29,7 @@
#include "ui_TaskDraftParameters.h"
#include "TaskDraftParameters.h"
#include "Workbench.h"
#include <Base/UnitsApi.h>
#include <App/Application.h>
#include <App/Document.h>
@@ -42,6 +43,7 @@
#include <Gui/Command.h>
#include <Gui/MainWindow.h>
#include <Mod/PartDesign/App/FeatureDraft.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Mod/PartDesign/Gui/ReferenceSelection.h>
@@ -426,19 +428,20 @@ bool TaskDlgDraftParameters::accept()
bool TaskDlgDraftParameters::reject()
{
// get the support
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
App::DocumentObject *pcSupport;
pcSupport = pcDraft->Base.getValue();
// roll back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the support is visible again
if (!Gui::Application::Instance->getViewProvider(pcDraft)) {
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
// Body housekeeping
if (ActivePartObject != NULL) {
// Make the new Tip and the previous solid feature visible again
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
if (tip != NULL) {
Gui::Application::Instance->getViewProvider(tip)->show();
if ((tip != prev) && (prev != NULL))
Gui::Application::Instance->getViewProvider(prev)->show();
}
}
return true;

View File

@@ -28,6 +28,7 @@
#include "ui_TaskFilletParameters.h"
#include "TaskFilletParameters.h"
#include "Workbench.h"
#include <Base/UnitsApi.h>
#include <App/Application.h>
#include <App/Document.h>
@@ -40,6 +41,7 @@
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeatureFillet.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -154,19 +156,20 @@ bool TaskDlgFilletParameters::accept()
bool TaskDlgFilletParameters::reject()
{
// get the support and Sketch
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
App::DocumentObject *pcSupport;
pcSupport = pcFillet->Base.getValue();
// role back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the support is visible again
if (!Gui::Application::Instance->getViewProvider(pcFillet)) {
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
// Body housekeeping
if (ActivePartObject != NULL) {
// Make the new Tip and the previous solid feature visible again
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
if (tip != NULL) {
Gui::Application::Instance->getViewProvider(tip)->show();
if ((tip != prev) && (prev != NULL))
Gui::Application::Instance->getViewProvider(prev)->show();
}
}
return true;

View File

@@ -456,7 +456,6 @@ bool TaskDlgMultiTransformParameters::reject()
// Get objects before view is invalidated
// For the same reason we can't delegate showing the originals to TaskDlgTransformedParameters::reject()
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
std::vector<App::DocumentObject*> pcOriginals = pcMultiTransform->Originals.getValues();
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
// Delete the transformation features - must happen before abortCommand()!
@@ -471,17 +470,7 @@ bool TaskDlgMultiTransformParameters::reject()
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the originals are visible again
if (!Gui::Application::Instance->getViewProvider(pcMultiTransform)) {
for (std::vector<App::DocumentObject*>::const_iterator it = pcOriginals.begin(); it != pcOriginals.end(); ++it)
{
if (((*it) != NULL) && (Gui::Application::Instance->getViewProvider(*it) != NULL)) {
Gui::Application::Instance->getViewProvider(*it)->show();
}
}
}
return true;
return TaskDlgTransformedParameters::reject();
}
#include "moc_TaskMultiTransformParameters.cpp"

View File

@@ -559,7 +559,7 @@ bool TaskDlgPadParameters::reject()
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the support is visible again
// if abort command deleted the object the sketch is visible again
if (!Gui::Application::Instance->getViewProvider(pcPad)) {
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();

View File

@@ -32,6 +32,7 @@
#include "TaskTransformedParameters.h"
#include "TaskMultiTransformParameters.h"
#include "Workbench.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
@@ -45,6 +46,7 @@
#include <Mod/PartDesign/App/FeatureTransformed.h>
#include <Mod/PartDesign/App/FeatureAdditive.h>
#include <Mod/PartDesign/App/FeatureSubtractive.h>
#include <Mod/PartDesign/App/Body.h>
#include "ReferenceSelection.h"
using namespace PartDesignGui;
@@ -274,21 +276,19 @@ bool TaskDlgTransformedParameters::reject()
// ensure that we are not in selection mode
parameter->exitSelectionMode();
// get object and originals before view is invalidated (if it is invalidated)
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
std::vector<App::DocumentObject*> pcOriginals = pcTransformed->Originals.getValues();
// roll back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the originals are visible again
if (!Gui::Application::Instance->getViewProvider(pcTransformed)) {
for (std::vector<App::DocumentObject*>::const_iterator it = pcOriginals.begin(); it != pcOriginals.end(); ++it)
{
if (((*it) != NULL) && (Gui::Application::Instance->getViewProvider(*it) != NULL)) {
Gui::Application::Instance->getViewProvider(*it)->show();
}
// Body housekeeping
if (ActivePartObject != NULL) {
// Make the new Tip and the previous solid feature visible again
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
if (tip != NULL) {
Gui::Application::Instance->getViewProvider(tip)->show();
if ((tip != prev) && (prev != NULL))
Gui::Application::Instance->getViewProvider(prev)->show();
}
}

View File

@@ -115,20 +115,11 @@ void ViewProviderChamfer::unsetEdit(int ModNum)
}
}
bool ViewProviderChamfer::onDelete(const std::vector<std::string> &)
bool ViewProviderChamfer::onDelete(const std::vector<std::string> &s)
{
// get the support and Sketch
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(getObject());
App::DocumentObject *pcSupport = 0;
if (pcChamfer->Base.getValue()){
pcSupport = static_cast<Sketcher::SketchObject*>(pcChamfer->Base.getValue());
}
// if abort command deleted the object the support is visible again
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
return true;
return ViewProvider::onDelete(s);
}

View File

@@ -115,20 +115,9 @@ void ViewProviderDraft::unsetEdit(int ModNum)
}
}
bool ViewProviderDraft::onDelete(const std::vector<std::string> &)
bool ViewProviderDraft::onDelete(const std::vector<std::string> &s)
{
// get the support and Sketch
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(getObject());
App::DocumentObject *pcSupport = 0;
if (pcDraft->Base.getValue()){
pcSupport = static_cast<Sketcher::SketchObject*>(pcDraft->Base.getValue());
}
// if abort command deleted the object the support is visible again
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
return true;
return ViewProvider::onDelete(s);
}

View File

@@ -115,20 +115,9 @@ void ViewProviderFillet::unsetEdit(int ModNum)
}
}
bool ViewProviderFillet::onDelete(const std::vector<std::string> &)
bool ViewProviderFillet::onDelete(const std::vector<std::string> &s)
{
// get the support and Sketch
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(getObject());
App::DocumentObject *pcSupport = 0;
if (pcFillet->Base.getValue()){
pcSupport = static_cast<Sketcher::SketchObject*>(pcFillet->Base.getValue());
}
// if abort command deleted the object the support is visible again
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
return true;
return ViewProvider::onDelete(s);
}

View File

@@ -149,19 +149,9 @@ void ViewProviderTransformed::unsetEdit(int ModNum)
rejectedFaceSet->unref();
}
bool ViewProviderTransformed::onDelete(const std::vector<std::string> &)
bool ViewProviderTransformed::onDelete(const std::vector<std::string> &s)
{
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(getObject());
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
// if abort command deleted the object the originals are visible again
for (std::vector<App::DocumentObject*>::const_iterator it = originals.begin(); it != originals.end(); ++it)
{
if (((*it) != NULL) && Gui::Application::Instance->getViewProvider(*it))
Gui::Application::Instance->getViewProvider(*it)->show();
}
return true;
return ViewProvider::onDelete(s);
}
const bool ViewProviderTransformed::checkDlgOpen(TaskDlgTransformedParameters* transformedDlg) {