Commands and object making
This commit is contained in:
@@ -48,7 +48,7 @@ public:
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
//const char* getViewProviderName(void) const {
|
||||
// return "PartDesignGui::ViewProviderConstraint";
|
||||
// return "AssemblyGui::ViewProviderConstraint";
|
||||
//}
|
||||
//@}
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderItem";
|
||||
return "AssemblyGui::ViewProviderItem";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderItemAssembly";
|
||||
return "AssemblyGui::ViewProviderItemAssembly";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
short mustExecute() const;
|
||||
// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "ItemPartDesignGui::ViewProviderItemPart";
|
||||
return "AssemblyGui::ViewProviderItemPart";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "ViewProviderPart.h"
|
||||
#include "ViewProviderAssembly.h"
|
||||
|
||||
#include <Mod/Assembly/App/ItemAssembly.h>
|
||||
|
||||
//#include "resources/qrc_Assembly.cpp"
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
@@ -52,6 +54,7 @@ void loadAssemblyResource()
|
||||
extern struct PyMethodDef AssemblyGui_Import_methods[];
|
||||
|
||||
|
||||
|
||||
/* Python entry */
|
||||
extern "C" {
|
||||
void AssemblyGuiExport initAssemblyGui()
|
||||
|
||||
@@ -26,8 +26,45 @@
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include <Mod/Assembly/App/ItemPy.h>
|
||||
|
||||
// pointer to the active assembly object
|
||||
Assembly::Item *ActiveAsmObject =0;
|
||||
|
||||
|
||||
/* module functions */
|
||||
static PyObject * setActiveAssembly(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *object;
|
||||
if (PyArg_ParseTuple(args,"O!",&(Assembly::ItemPy::Type), &object)) {
|
||||
Assembly::Item* Item = static_cast<Assembly::ItemPy*>(object)->getItemPtr();
|
||||
// Should be set!
|
||||
assert(Item);
|
||||
|
||||
if(ActiveAsmObject){
|
||||
|
||||
ActiveAsmObject = 0;
|
||||
|
||||
}
|
||||
ActiveAsmObject = Item;
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance -> getViewProvider(ActiveAsmObject);
|
||||
//PyErr_SetString(PyExc_Exception, "empty shape");
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef AssemblyGui_Import_methods[] = {
|
||||
{"setActiveAssembly" ,setActiveAssembly ,METH_VARARGS,
|
||||
"setActiveAssembly(AssemblyObject) -- Set the Assembly object in work."},
|
||||
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ CmdAssemblyAddNewPart::CmdAssemblyAddNewPart()
|
||||
sToolTipText = QT_TR_NOOP("Add a new Part into the active Assembly");
|
||||
sWhatsThis = "Assembly_ConstraintAxle";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/Axle_constraint";
|
||||
sPixmap = "Part_Box";
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ CmdAssemblyAddNewComponent::CmdAssemblyAddNewComponent()
|
||||
sToolTipText = QT_TR_NOOP("Add a new Component into the active Assembly");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/Axle_constraint";
|
||||
sPixmap = "Part_Box";
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ CmdAssemblyAddExistingComponent::CmdAssemblyAddExistingComponent()
|
||||
sToolTipText = QT_TR_NOOP("Add a existing Component or File into the active Assembly");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "actions/Axle_constraint";
|
||||
sPixmap = "Part_Box";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,12 +28,14 @@
|
||||
|
||||
// Importing of App classes
|
||||
#ifdef FC_OS_WIN32
|
||||
# define AssemblyAppExport __declspec(dllimport)
|
||||
# define AssemblyExport __declspec(dllimport)
|
||||
# define PartGuiExport __declspec(dllimport)
|
||||
# define PartExport __declspec(dllimport)
|
||||
# define AssemblyGuiExport __declspec(dllexport)
|
||||
#else // for Linux
|
||||
# define AssemblyAppExport
|
||||
# define AssemblyExport
|
||||
# define PartGuiExport
|
||||
# define PartExport
|
||||
# define AssemblyGuiExport
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,7 +28,11 @@
|
||||
#endif
|
||||
|
||||
#include "Workbench.h"
|
||||
#include <App/Application.h>
|
||||
#include <Gui/MenuManager.h>
|
||||
#include <Gui/ToolBarManager.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
|
||||
using namespace AssemblyGui;
|
||||
|
||||
@@ -56,6 +60,25 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
return root;
|
||||
}
|
||||
|
||||
Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
{
|
||||
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
|
||||
Gui::MenuItem* item = root->findItem("&Windows");
|
||||
|
||||
|
||||
Gui::MenuItem* asmCmd = new Gui::MenuItem();
|
||||
root->insertItem(item, asmCmd);
|
||||
asmCmd->setCommand("&Assembly");
|
||||
*asmCmd << "Assembly_ConstraintAxle"
|
||||
<< "Separator"
|
||||
<< "Assembly_AddNewPart"
|
||||
<< "Assembly_AddNewComponent"
|
||||
<< "Assembly_AddExistingComponent";
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
{
|
||||
// Part tools
|
||||
@@ -63,3 +86,49 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
return root;
|
||||
}
|
||||
|
||||
void Workbench::activated()
|
||||
{
|
||||
Gui::Workbench::activated();
|
||||
|
||||
std::vector<Gui::TaskView::TaskWatcher*> Watcher;
|
||||
|
||||
const char* Asm[] = {
|
||||
"Assembly_AddNewPart",
|
||||
"PartDesign_Fillet",
|
||||
"PartDesign_Chamfer",
|
||||
0};
|
||||
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
||||
"SELECT Assembly::Item COUNT 1",
|
||||
Asm,
|
||||
"Assembly tools",
|
||||
"Part_Box"
|
||||
));
|
||||
|
||||
addTaskWatcher(Watcher);
|
||||
Gui::Control().showTaskView();
|
||||
|
||||
App::Document *doc = App::GetApplication().getActiveDocument();
|
||||
if(!doc){
|
||||
// create a new document
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.newDocument()");
|
||||
doc = App::GetApplication().getActiveDocument();
|
||||
|
||||
}
|
||||
// now we should have a document!
|
||||
assert(doc);
|
||||
|
||||
if(doc->countObjects()==0){
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('Assembly::ItemAssembly','Product')");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Workbench::deactivated()
|
||||
{
|
||||
Gui::Workbench::deactivated();
|
||||
removeTaskWatcher();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,12 +36,19 @@ class AssemblyGuiExport Workbench : public Gui::StdWorkbench
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
Workbench();
|
||||
virtual ~Workbench();
|
||||
Workbench();
|
||||
virtual ~Workbench();
|
||||
|
||||
/** Run some actions when the workbench gets activated. */
|
||||
virtual void activated();
|
||||
/** Run some actions when the workbench gets deactivated. */
|
||||
virtual void deactivated();
|
||||
|
||||
protected:
|
||||
Gui::ToolBarItem* setupToolBars() const;
|
||||
Gui::ToolBarItem* setupCommandBars() const;
|
||||
Gui::MenuItem* setupMenuBar() const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace AssemblyGui
|
||||
|
||||
Reference in New Issue
Block a user