First claimChildren3D implementation and Starting PartItem implementation
This commit is contained in:
@@ -59,9 +59,29 @@ CmdAssemblyAddNewPart::CmdAssemblyAddNewPart()
|
||||
|
||||
void CmdAssemblyAddNewPart::activated(int iMsg)
|
||||
{
|
||||
// load the file with the module
|
||||
//Command::doCommand(Command::Gui, "import Assembly, AssemblyGui");
|
||||
|
||||
Assembly::ItemAssembly *dest = 0;
|
||||
|
||||
unsigned int n = getSelection().countObjectsOfType(Assembly::ItemAssembly::getClassTypeId());
|
||||
if (n >= 1) {
|
||||
std::vector<App::DocumentObject*> Sel = getSelection().getObjectsOfType(Assembly::ItemAssembly::getClassTypeId());
|
||||
dest = dynamic_cast<Assembly::ItemAssembly*>(Sel.front());
|
||||
}else if(ActiveAsmObject && ActiveAsmObject->getTypeId().isDerivedFrom(Assembly::ItemAssembly::getClassTypeId())) {
|
||||
dest = dynamic_cast<Assembly::ItemAssembly*>(ActiveAsmObject);
|
||||
}
|
||||
|
||||
openCommand("Insert Part");
|
||||
std::string PartName = getUniqueObjectName("Part.0");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemPart','%s')",PartName.c_str());
|
||||
if(dest){
|
||||
std::string fatherName = dest->getNameInDocument();
|
||||
doCommand(Doc,"App.activeDocument().%s.Items = App.activeDocument().%s.Items + [App.activeDocument().%s] ",fatherName.c_str(),fatherName.c_str(),PartName.c_str());
|
||||
}
|
||||
Command::addModule(App,"PartDesign");
|
||||
Command::addModule(Gui,"PartDesignGui");
|
||||
std::string BodyName = getUniqueObjectName("Body");
|
||||
doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')",BodyName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Model = App.activeDocument().%s.Items = App.activeDocument().%s ",BodyName.c_str(),BodyName.c_str(),BodyName.c_str());
|
||||
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@@ -94,7 +114,7 @@ void CmdAssemblyAddNewComponent::activated(int iMsg)
|
||||
}
|
||||
|
||||
openCommand("Insert Component");
|
||||
std::string CompName = getUniqueObjectName("Product");
|
||||
std::string CompName = getUniqueObjectName("Product.0");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemAssembly','%s')",CompName.c_str());
|
||||
if(dest){
|
||||
std::string fatherName = dest->getNameInDocument();
|
||||
|
||||
@@ -24,22 +24,29 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/nodes/SoGroup.h>
|
||||
#endif
|
||||
|
||||
#include "ViewProvider.h"
|
||||
#include <Gui/Command.h>
|
||||
//#include <Gui/Document.h>
|
||||
|
||||
|
||||
using namespace AssemblyGui;
|
||||
|
||||
PROPERTY_SOURCE(AssemblyGui::ViewProviderItem,PartGui::ViewProviderPart)
|
||||
|
||||
ViewProviderItem::ViewProviderItem()
|
||||
{
|
||||
pcChildren = new SoGroup();
|
||||
pcChildren->ref();
|
||||
|
||||
}
|
||||
|
||||
ViewProviderItem::~ViewProviderItem()
|
||||
{
|
||||
pcChildren->unref();
|
||||
pcChildren = 0;
|
||||
}
|
||||
|
||||
bool ViewProviderItem::doubleClicked(void)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
|
||||
class SoGroup;
|
||||
|
||||
namespace AssemblyGui {
|
||||
|
||||
@@ -39,7 +40,13 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderItem();
|
||||
|
||||
// returns the root node where the children gets collected(3D)
|
||||
virtual SoGroup* getChildRoot(void) const {return pcChildren;}
|
||||
|
||||
|
||||
virtual bool doubleClicked(void);
|
||||
private:
|
||||
SoGroup *pcChildren;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/nodes/SoGroup.h>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderAssembly.h"
|
||||
@@ -50,6 +51,35 @@ bool ViewProviderItemAssembly::doubleClicked(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderItemAssembly::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
// call parent attach method
|
||||
ViewProviderGeometryObject::attach(pcFeat);
|
||||
|
||||
|
||||
// putting all together with the switch
|
||||
addDisplayMaskMode(getChildRoot(), "Main");
|
||||
}
|
||||
|
||||
void ViewProviderItemAssembly::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if ( strcmp("Main",ModeName)==0 )
|
||||
setDisplayMaskMode("Main");
|
||||
|
||||
ViewProviderGeometryObject::setDisplayMode( ModeName );
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderItemAssembly::getDisplayModes(void) const
|
||||
{
|
||||
// get the modes of the father
|
||||
std::vector<std::string> StrList = ViewProviderGeometryObject::getDisplayModes();
|
||||
|
||||
// add your own modes
|
||||
StrList.push_back("Main");
|
||||
|
||||
return StrList;
|
||||
}
|
||||
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderItemAssembly::claimChildren(void)const
|
||||
{
|
||||
@@ -57,3 +87,10 @@ std::vector<App::DocumentObject*> ViewProviderItemAssembly::claimChildren(void)c
|
||||
return static_cast<Assembly::ItemAssembly*>(getObject())->Items.getValues();
|
||||
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderItemAssembly::claimChildren3D(void)const
|
||||
{
|
||||
|
||||
return static_cast<Assembly::ItemAssembly*>(getObject())->Items.getValues();
|
||||
|
||||
}
|
||||
|
||||
@@ -40,9 +40,15 @@ public:
|
||||
virtual ~ViewProviderItemAssembly();
|
||||
|
||||
virtual bool doubleClicked(void);
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
|
||||
virtual std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
|
||||
virtual std::vector<App::DocumentObject*> claimChildren3D(void)const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -107,20 +107,20 @@ void Workbench::activated()
|
||||
addTaskWatcher(Watcher);
|
||||
Gui::Control().showTaskView();
|
||||
|
||||
//App::Document *doc = App::GetApplication().getActiveDocument();
|
||||
//if(!doc){
|
||||
// // create a new document
|
||||
App::Document *doc = App::GetApplication().getActiveDocument();
|
||||
if(!doc){
|
||||
// create a new document
|
||||
|
||||
// Gui::Command::doCommand(Gui::Command::Doc,"App.newDocument()");
|
||||
// doc = App::GetApplication().getActiveDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.newDocument()");
|
||||
doc = App::GetApplication().getActiveDocument();
|
||||
|
||||
//}
|
||||
//// now we should have a document!
|
||||
//assert(doc);
|
||||
}
|
||||
// now we should have a document!
|
||||
assert(doc);
|
||||
|
||||
//if(doc->countObjects()==0){
|
||||
// Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('Assembly::ItemAssembly','Product')");
|
||||
//}
|
||||
if(doc->countObjects()==0){
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('Assembly::ItemAssembly','Product')");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user