add coordinate system datum
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#include "ViewProviderDatumPlane.h"
|
||||
#include "ViewProviderBoolean.h"
|
||||
#include "ViewProviderPrimitive.h"
|
||||
#include "ViewProviderDatumCS.h"
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreatePartDesignCommands(void);
|
||||
@@ -134,6 +135,7 @@ PyMODINIT_FUNC initPartDesignGui()
|
||||
PartDesignGui::ViewProviderDatumPoint ::init();
|
||||
PartDesignGui::ViewProviderDatumLine ::init();
|
||||
PartDesignGui::ViewProviderDatumPlane ::init();
|
||||
PartDesignGui::ViewProviderDatumCoordinateSystem::init();
|
||||
PartDesignGui::ViewProviderBoolean ::init();
|
||||
PartDesignGui::ViewProviderPrimitive ::init();
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ set(PartDesignGui_MOC_HDRS
|
||||
TaskMultiTransformParameters.h
|
||||
TaskDatumParameters.h
|
||||
TaskBooleanParameters.h
|
||||
TaskPrimitiveParameters.h
|
||||
)
|
||||
fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS})
|
||||
SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS})
|
||||
@@ -118,6 +119,8 @@ SET(PartDesignGuiViewProvider_SRCS CommandPrimitive.cpp
|
||||
ViewProviderDatumLine.h
|
||||
ViewProviderDatumPlane.cpp
|
||||
ViewProviderDatumPlane.h
|
||||
ViewProviderDatumCS.cpp
|
||||
ViewProviderDatumCS.h
|
||||
ViewProviderBoolean.cpp
|
||||
ViewProviderBoolean.h
|
||||
ViewProviderPrimitive.h
|
||||
@@ -185,6 +188,8 @@ SET(PartDesignGuiTaskDlgs_SRCS
|
||||
TaskBooleanParameters.ui
|
||||
TaskBooleanParameters.cpp
|
||||
TaskBooleanParameters.h
|
||||
TaskPrimitiveParameters.h
|
||||
TaskPrimitiveParameters.cpp
|
||||
)
|
||||
SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS})
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ CmdPrimtiveCompAdditive::CmdPrimtiveCompAdditive()
|
||||
|
||||
void CmdPrimtiveCompAdditive::activated(int iMsg)
|
||||
{
|
||||
Base::Console().Message("activated msg %i\n", iMsg);
|
||||
|
||||
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
|
||||
if (!pcActiveBody) return;
|
||||
@@ -62,13 +61,23 @@ void CmdPrimtiveCompAdditive::activated(int iMsg)
|
||||
if(iMsg == 0) {
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Box");
|
||||
std::string CSName = getUniqueObjectName("CoordinateSystem");
|
||||
|
||||
Gui::Command::openCommand("Make additive box");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\'PartDesign::AdditiveBox\',\'%s\')",
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.addObject(\'PartDesign::AdditiveBox\',\'%s\')",
|
||||
FeatName.c_str());
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)"
|
||||
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addFeature(App.activeDocument().%s)"
|
||||
,pcActiveBody->getNameInDocument(), FeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().setEdit(\'%s\')", FeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.addObject(\'PartDesign::CoordinateSystem\',\'%s\')",
|
||||
CSName.c_str());
|
||||
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addFeature(App.activeDocument().%s)"
|
||||
,pcActiveBody->getNameInDocument(), CSName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.CoordinateSystem=(App.ActiveDocument.%s)",
|
||||
FeatName.c_str(), CSName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
|
||||
Gui::Command::doCommand(Gui, "Gui.activeDocument().hide(\'%s\')", CSName.c_str());
|
||||
Gui::Command::doCommand(Gui, "Gui.activeDocument().setEdit(\'%s\')", FeatName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,17 +144,22 @@ CmdPrimtiveCompSubtractive::CmdPrimtiveCompSubtractive()
|
||||
}
|
||||
|
||||
void CmdPrimtiveCompSubtractive::activated(int iMsg)
|
||||
{
|
||||
Base::Console().Message("activated msg %i\n", iMsg);
|
||||
return;
|
||||
|
||||
// Since the default icon is reset when enabing/disabling the command we have
|
||||
// to explicitly set the icon of the used command.
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
assert(iMsg < a.size());
|
||||
pcAction->setIcon(a[iMsg]->icon());
|
||||
{
|
||||
PartDesign::Body *pcActiveBody = PartDesignGui::getBody();
|
||||
if (!pcActiveBody) return;
|
||||
|
||||
if(iMsg == 0) {
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Box");
|
||||
|
||||
Gui::Command::openCommand("Make subtractive box");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\'PartDesign::SubtractiveBox\',\'%s\')",
|
||||
FeatName.c_str());
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)"
|
||||
,pcActiveBody->getNameInDocument(), FeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().setEdit(\'%s\')", FeatName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
}
|
||||
}
|
||||
|
||||
Gui::Action * CmdPrimtiveCompSubtractive::createAction(void)
|
||||
|
||||
@@ -277,7 +277,9 @@ void TaskDatumParameters::updateUI()
|
||||
std::set<QString> hint = pcDatum->getHint();
|
||||
|
||||
if (hint == std::set<QString>()) {
|
||||
QMessageBox::warning(this, tr("Illegal selection"), tr("This feature cannot be created with this combination of references"));
|
||||
if(!refs.empty())
|
||||
QMessageBox::warning(this, tr("Illegal selection"), tr("This feature cannot be created with this combination of references"));
|
||||
|
||||
if (refs.size() == 1) {
|
||||
onButtonRef1(true);
|
||||
} else if (refs.size() == 2) {
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <Mod/PartDesign/App/FeatureMultiTransform.h>
|
||||
#include <Mod/PartDesign/App/DatumLine.h>
|
||||
#include <Mod/PartDesign/App/DatumPlane.h>
|
||||
#include <Mod/PartDesign/App/DatumCS.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Base/Console.h"
|
||||
@@ -184,7 +185,7 @@ void ViewProviderBody::updateData(const App::Property* prop)
|
||||
// (prop->getTypeId() == App::PropertyLinkList::getClassTypeId() && strcmp(prop->getName(),"Model") == 0))
|
||||
// // updateTree();
|
||||
|
||||
// Update the visual size of datum lines and planes
|
||||
// Update the visual size of datums
|
||||
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
|
||||
std::vector<App::DocumentObject*> features = body->Model.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator f = features.begin(); f != features.end(); f++) {
|
||||
@@ -193,6 +194,8 @@ void ViewProviderBody::updateData(const App::Property* prop)
|
||||
plm = &(static_cast<PartDesign::Line*>(*f)->Placement);
|
||||
else if ((*f)->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId()))
|
||||
plm = &(static_cast<PartDesign::Plane*>(*f)->Placement);
|
||||
else if ((*f)->getTypeId().isDerivedFrom(PartDesign::CoordinateSystem::getClassTypeId()))
|
||||
plm = &(static_cast<PartDesign::CoordinateSystem*>(*f)->Placement);
|
||||
|
||||
if (plm != NULL) {
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(Gui::Application::Instance->getViewProvider(*f));
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/MDIView.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/DatumCS.h>
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
@@ -92,6 +93,8 @@ void ViewProviderDatum::attach(App::DocumentObject *obj)
|
||||
datumType = QObject::tr("Line");
|
||||
else if (o->getTypeId() == PartDesign::Point::getClassTypeId())
|
||||
datumType = QObject::tr("Point");
|
||||
else if (o->getTypeId() == PartDesign::CoordinateSystem::getClassTypeId())
|
||||
datumType = QObject::tr("CoordinateSystem");
|
||||
|
||||
SoShapeHints* hints = new SoShapeHints();
|
||||
hints->shapeType.setValue(SoShapeHints::UNKNOWN_SHAPE_TYPE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer <jrheinlaender@users.sourceforge.net> *
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
@@ -28,11 +28,13 @@
|
||||
#endif
|
||||
|
||||
#include "ViewProviderPrimitive.h"
|
||||
#include "TaskPrimitiveParameters.h"
|
||||
#include <Mod/PartDesign/App/FeaturePrimitive.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
@@ -49,16 +51,16 @@ ViewProviderPrimitive::~ViewProviderPrimitive()
|
||||
}
|
||||
|
||||
bool ViewProviderPrimitive::setEdit(int ModNum)
|
||||
{/*
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// When double-clicking on the item for this fillet the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgBooleanParameters *booleanDlg = qobject_cast<TaskDlgBooleanParameters *>(dlg);
|
||||
if (booleanDlg && booleanDlg->getBooleanView() != this)
|
||||
booleanDlg = 0; // another pad left open its task panel
|
||||
if (dlg && !booleanDlg) {
|
||||
TaskPrimitiveParameters *primitiveDlg = qobject_cast<TaskPrimitiveParameters *>(dlg);
|
||||
if (primitiveDlg)
|
||||
primitiveDlg = 0; // another pad left open its task panel
|
||||
if (dlg && !primitiveDlg) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
|
||||
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
|
||||
@@ -78,18 +80,24 @@ bool ViewProviderPrimitive::setEdit(int ModNum)
|
||||
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// start the edit dialog
|
||||
if (booleanDlg)
|
||||
Gui::Control().showDialog(booleanDlg);
|
||||
if (primitiveDlg)
|
||||
Gui::Control().showDialog(primitiveDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgBooleanParameters(this));
|
||||
Gui::Control().showDialog(new TaskPrimitiveParameters(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return PartGui::ViewProviderPart::setEdit(ModNum);
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector< App::DocumentObject* > ViewProviderPrimitive::claimChildren(void) const {
|
||||
|
||||
// Base::Console().Message("claim children\n");
|
||||
std::vector< App::DocumentObject* > vec;
|
||||
vec.push_back(static_cast<PartDesign::FeaturePrimitive*>(getObject())->CoordinateSystem.getValue());
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderPrimitive();
|
||||
|
||||
virtual std::vector< App::DocumentObject* > claimChildren(void) const;
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user