activate/create 3d view when setting or getting active objects
This commit is contained in:
@@ -69,7 +69,8 @@ void StdCmdPart::activated(int iMsg)
|
||||
// TODO We really must set label ourselves? (2015-08-17, Fat-Zer)
|
||||
doCommand(Doc,"App.activeDocument().%s.Label = '%s'", PartName.c_str(),
|
||||
QObject::tr(PartName.c_str()).toUtf8().data());
|
||||
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
|
||||
doCommand(Gui::Command::Gui, "Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
|
||||
PARTKEY, PartName.c_str());
|
||||
|
||||
updateActive();
|
||||
|
||||
@@ -94,12 +94,14 @@ bool ViewProviderPart::doubleClicked(void)
|
||||
if (activePart == this->getObject()){
|
||||
//active part double-clicked. Deactivate.
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', None)",
|
||||
this->getObject()->getDocument()->getName(),
|
||||
PARTKEY);
|
||||
} else {
|
||||
//set new active part
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
|
||||
this->getObject()->getDocument()->getName(),
|
||||
PARTKEY,
|
||||
|
||||
@@ -218,7 +218,8 @@ void CmdPartDesignBody::activated(int iMsg)
|
||||
}
|
||||
}
|
||||
addModule(Gui,"PartDesignGui"); // import the Gui module only once a session
|
||||
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
|
||||
doCommand(Gui::Command::Gui, "Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
|
||||
PDBODYKEY, bodyName.c_str());
|
||||
|
||||
// Make the "Create sketch" prompt appear in the task panel
|
||||
|
||||
@@ -80,6 +80,7 @@ PartDesign::Body *getBody(bool messageIfNot, bool autoActivate, bool assertModer
|
||||
|
||||
if (!activeBody && singleBodyDocument && autoActivate) {
|
||||
Gui::Command::doCommand( Gui::Command::Gui,
|
||||
"Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.activeView().setActiveObject('pdbody',App.ActiveDocument.findObjects('PartDesign::Body')[0])");
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
return activeBody;
|
||||
|
||||
@@ -152,6 +152,7 @@ bool ViewProviderBody::doubleClicked(void)
|
||||
if (activeBody == this->getObject()){
|
||||
//active body double-clicked. Deactivate.
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', None)",
|
||||
this->getObject()->getDocument()->getName(),
|
||||
PDBODYKEY);
|
||||
@@ -164,6 +165,7 @@ bool ViewProviderBody::doubleClicked(void)
|
||||
auto* part = App::Part::getPartOfObject ( getObject() );
|
||||
if ( part && part != getActiveView()->getActiveObject<App::Part*> ( PARTKEY ) ) {
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
|
||||
part->getDocument()->getName(),
|
||||
PARTKEY,
|
||||
@@ -172,6 +174,7 @@ bool ViewProviderBody::doubleClicked(void)
|
||||
}
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
|
||||
this->getObject()->getDocument()->getName(),
|
||||
PDBODYKEY,
|
||||
|
||||
@@ -294,6 +294,7 @@ bool ViewProviderDatum::doubleClicked(void)
|
||||
if (datumBody != NULL) {
|
||||
if (datumBody != activeBody) {
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.activateView('Gui::View3DInventor', True)\n"
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
|
||||
datumBody->getDocument()->getName(),
|
||||
PDBODYKEY,
|
||||
|
||||
@@ -87,6 +87,7 @@ class PartDesignGuiTestCases(unittest.TestCase):
|
||||
def testRefuseToMoveSingleFeature(self):
|
||||
FreeCAD.Console.PrintMessage('Testing refuse to move the feature with dependencies from one body to another\n')
|
||||
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
|
||||
Gui.activateView('Gui::View3DInventor', True)
|
||||
Gui.activeView().setActiveObject('pdbody', self.BodySource)
|
||||
|
||||
self.BoxObj = self.Doc.addObject('PartDesign::AdditiveBox','Box')
|
||||
@@ -147,6 +148,7 @@ class PartDesignGuiTestCases(unittest.TestCase):
|
||||
def testMoveSingleFeature(self):
|
||||
FreeCAD.Console.PrintMessage('Testing moving one feature from one body to another\n')
|
||||
self.BodySource = self.Doc.addObject('PartDesign::Body','Body')
|
||||
Gui.activateView('Gui::View3DInventor', True)
|
||||
Gui.activeView().setActiveObject('pdbody', self.BodySource)
|
||||
|
||||
self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch')
|
||||
|
||||
Reference in New Issue
Block a user