implementing commands
This commit is contained in:
parent
72b49dbc6b
commit
58313b0853
|
@ -62,7 +62,7 @@ static PyObject * setActiveAssembly(PyObject *self, PyObject *args)
|
|||
ActiveAsmObject = Item;
|
||||
ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument());
|
||||
ActiveVp = dynamic_cast<Gui::ViewProviderDocumentObject*> (ActiveGuiDoc->getViewProvider(Item)) ;
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue);
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined);
|
||||
|
||||
}else{
|
||||
ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::None);
|
||||
|
|
|
@ -23,16 +23,21 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include <Mod/Assembly/App/ItemAssembly.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern Assembly::Item *ActiveAsmObject;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
|
@ -78,9 +83,23 @@ CmdAssemblyAddNewComponent::CmdAssemblyAddNewComponent()
|
|||
|
||||
void CmdAssemblyAddNewComponent::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 Component");
|
||||
std::string CompName = getUniqueObjectName("Product");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemAssembly','%s')",CompName.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(),CompName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
|
||||
#include <Mod/Assembly/App/ItemAssembly.h>
|
||||
|
||||
using namespace AssemblyGui;
|
||||
|
||||
PROPERTY_SOURCE(AssemblyGui::ViewProviderItemAssembly,AssemblyGui::ViewProviderItem)
|
||||
|
@ -49,3 +51,9 @@ bool ViewProviderItemAssembly::doubleClicked(void)
|
|||
}
|
||||
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderItemAssembly::claimChildren(void)const
|
||||
{
|
||||
|
||||
return static_cast<Assembly::ItemAssembly*>(getObject())->Items.getValues();
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
|
||||
virtual bool doubleClicked(void);
|
||||
|
||||
virtual std::vector<App::DocumentObject*> claimChildren(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')");
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user