implement active body in PartDesign
This commit is contained in:
@@ -22,11 +22,58 @@
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Tree.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
||||
#include <Mod/PartDesign/App/BodyPy.h>
|
||||
|
||||
// pointer to the active assembly object
|
||||
PartDesign::Body *ActivePartObject =0;
|
||||
Gui::Document *ActiveGuiDoc =0;
|
||||
Gui::ViewProviderDocumentObject *ActiveVp =0;
|
||||
|
||||
|
||||
|
||||
static PyObject * setActivePart(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *object=0;
|
||||
if (PyArg_ParseTuple(args,"|O!",&(PartDesign::BodyPy::Type), &object)&& object) {
|
||||
PartDesign::Body* Item = static_cast<PartDesign::BodyPy*>(object)->getBodyPtr();
|
||||
// Should be set!
|
||||
assert(Item);
|
||||
|
||||
// get the gui document of the Assembly Item
|
||||
if(ActivePartObject){
|
||||
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
|
||||
ActivePartObject = 0;
|
||||
|
||||
}
|
||||
ActivePartObject = Item;
|
||||
ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument());
|
||||
ActiveVp = dynamic_cast<Gui::ViewProviderDocumentObject*> (ActiveGuiDoc->getViewProvider(Item)) ;
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,true);
|
||||
|
||||
}else{
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
|
||||
ActivePartObject = 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
/* registration table */
|
||||
struct PyMethodDef Assembly_methods[] = {
|
||||
{"setActivePart" ,setActivePart ,METH_VARARGS,
|
||||
"setActivePart(BodyObject) -- Set the PartBody object in work."},
|
||||
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
||||
|
||||
86
src/Mod/Assembly/App/AppAssemblyPy.cpp.orig
Normal file
86
src/Mod/Assembly/App/AppAssemblyPy.cpp.orig
Normal file
@@ -0,0 +1,86 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
<<<<<<< 8ef3abc971814e64ef79a85812dd1a5827ba955f:src/Mod/Assembly/App/AppAssemblyPy.cpp
|
||||
/* registration table */
|
||||
struct PyMethodDef Assembly_methods[] = {
|
||||
{NULL, NULL} /* end of table marker */
|
||||
=======
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Tree.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
||||
#include <Mod/PartDesign/App/BodyPy.h>
|
||||
|
||||
// pointer to the active assembly object
|
||||
PartDesign::Body *ActivePartObject =0;
|
||||
Gui::Document *ActiveGuiDoc =0;
|
||||
Gui::ViewProviderDocumentObject *ActiveVp =0;
|
||||
|
||||
|
||||
|
||||
static PyObject * setActivePart(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *object=0;
|
||||
if (PyArg_ParseTuple(args,"|O!",&(PartDesign::BodyPy::Type), &object)&& object) {
|
||||
PartDesign::Body* Item = static_cast<PartDesign::BodyPy*>(object)->getBodyPtr();
|
||||
// Should be set!
|
||||
assert(Item);
|
||||
|
||||
// get the gui document of the Assembly Item
|
||||
if(ActivePartObject){
|
||||
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
|
||||
ActivePartObject = 0;
|
||||
|
||||
}
|
||||
ActivePartObject = Item;
|
||||
ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument());
|
||||
ActiveVp = dynamic_cast<Gui::ViewProviderDocumentObject*> (ActiveGuiDoc->getViewProvider(Item)) ;
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,true);
|
||||
|
||||
}else{
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false);
|
||||
ActivePartObject = 0;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef PartDesignGui_Import_methods[] = {
|
||||
{"setActivePart" ,setActivePart ,METH_VARARGS,
|
||||
"setActivePart(BodyObject) -- Set the PartBody object in work."},
|
||||
|
||||
{NULL, NULL} /* end of table marker */
|
||||
>>>>>>> implement active body in PartDesign:src/Mod/PartDesign/Gui/AppPartDesignGuiPy.cpp
|
||||
};
|
||||
@@ -82,27 +82,29 @@ void CmdAssemblyAddNewPart::activated(int iMsg)
|
||||
Command::addModule(App,"PartDesign");
|
||||
Command::addModule(Gui,"PartDesignGui");
|
||||
|
||||
#if 1 // test code for children nesting
|
||||
Command::addModule(App,"Part");
|
||||
std::string BodyName = getUniqueObjectName("Box");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Part::Box','%s')",BodyName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Model = App.activeDocument().%s ",PartName.c_str(),BodyName.c_str(),BodyName.c_str());
|
||||
#else
|
||||
|
||||
std::string BodyName = getUniqueObjectName("Body");
|
||||
// add the standard planes
|
||||
std::string Plane1Name = BodyName + "_PlaneXY";
|
||||
std::string Plane2Name = BodyName + "_PlaneYZ";
|
||||
std::string Plane3Name = BodyName + "_PlaneXZ";
|
||||
doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')",Plane1Name.c_str());
|
||||
doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')",Plane2Name.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Placement = App.Placement(App.Vector(0.000000,0.000000,0.000000),App.Rotation(-0.707107,0.000000,0.000000,-0.707107))",Plane2Name.c_str());
|
||||
doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')",Plane3Name.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Annotation = [App.activeDocument().%s,App.activeDocument().%s,App.activeDocument().%s] ",PartName.c_str(),Plane1Name.c_str(),Plane2Name.c_str(),Plane3Name.c_str());
|
||||
//doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')",Plane1Name.c_str());
|
||||
//doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')",Plane2Name.c_str());
|
||||
//doCommand(Doc,"App.activeDocument().%s.Placement = App.Placement(App.Vector(0.000000,0.000000,0.000000),App.Rotation(-0.707107,0.000000,0.000000,-0.707107))",Plane2Name.c_str());
|
||||
//doCommand(Doc,"App.activeDocument().addObject('App::Plane','%s')",Plane3Name.c_str());
|
||||
//doCommand(Doc,"App.activeDocument().%s.Annotation = [App.activeDocument().%s,App.activeDocument().%s,App.activeDocument().%s] ",PartName.c_str(),Plane1Name.c_str(),Plane2Name.c_str(),Plane3Name.c_str());
|
||||
// add the main body
|
||||
doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')",BodyName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Model = App.activeDocument().%s ",PartName.c_str(),BodyName.c_str(),BodyName.c_str());
|
||||
#endif #
|
||||
doCommand(Doc,"App.activeDocument().%s.Model = App.activeDocument().%s ",PartName.c_str(),BodyName.c_str());
|
||||
|
||||
#if 0 // test code for children nesting
|
||||
Command::addModule(App,"Part");
|
||||
std::string BoxName = getUniqueObjectName("Box");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Part::Box','%s')",BoxName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Model = App.activeDocument().%s ",BodyName.c_str(),BoxName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Tip = App.activeDocument().%s ",BodyName.c_str(),BoxName.c_str());
|
||||
#endif
|
||||
|
||||
this->updateActive();
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,8 @@ void Workbench::activated()
|
||||
|
||||
void Workbench::deactivated()
|
||||
{
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"AssemblyGui.setActiveAssembly(None)");
|
||||
|
||||
Gui::Workbench::deactivated();
|
||||
removeTaskWatcher();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user