[Part] allow to edit helices via a dialog

+ add class ViewProviderPrimitive to avoid to re-implement setEdit/unsetEdit methods for each sub-class separately
+ avoid using global variables
+ when editing a feature directly pass it to the dialogs
+ when editing a feature then do not use active document as this could point to the wrong object
+ fix undo/redo message
+ re-add '3D View' button to location dialog
This commit is contained in:
wmayer
2020-11-06 19:59:14 +01:00
parent ca5d4d5f72
commit 677ce69873
32 changed files with 407 additions and 248 deletions

View File

@@ -157,6 +157,7 @@ PyMOD_INIT_FUNC(PartGui)
PartGui::ViewProviderAttachExtensionPython ::init();
PartGui::ViewProviderPartExt ::init();
PartGui::ViewProviderPart ::init();
PartGui::ViewProviderPrimitive ::init();
PartGui::ViewProviderEllipsoid ::init();
PartGui::ViewProviderPython ::init();
PartGui::ViewProviderBox ::init();

View File

@@ -50,7 +50,9 @@
#include <Gui/View3DInventorViewer.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Gui/TaskView/TaskView.h>
#include <Mod/Part/App/PartFeatures.h>
#include <Mod/Part/App/PrimitiveFeature.h>
#include <Mod/Part/App/FeaturePartBox.h>
#include <Mod/Part/App/FeaturePartCircle.h>
#include <Mod/Part/App/Tools.h>
#include "DlgPrimitives.h"
@@ -59,8 +61,6 @@ using namespace PartGui;
namespace PartGui {
const char* ObjectNameSave;
const char* gce_ErrorStatusText(gce_ErrorType et)
{
switch (et)
@@ -185,49 +185,14 @@ private:
/* TRANSLATOR PartGui::DlgPrimitives */
DlgPrimitives::DlgPrimitives(QWidget* parent, PrimitiveType type, bool edit, const char* ObjectName)
DlgPrimitives::DlgPrimitives(QWidget* parent, Part::Primitive* feature)
: QWidget(parent)
, featurePtr(feature)
{
ui.setupUi(this);
Gui::Command::doCommand(Gui::Command::Doc, "from FreeCAD import Base");
Gui::Command::doCommand(Gui::Command::Doc, "import Part,PartGui");
ui.comboBox1->setCurrentIndex(type);
ui.widgetStack2->setCurrentIndex(type);
// fill the dialog with data if the primitives already exists
if (edit) {
// if existing, the primitive type can not be changed by the user
ui.comboBox1->setDisabled(edit);
// get the primitives object
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (!doc)
return;
auto docObj = doc->getDocument()->getObject(ObjectName);
// read values from the properties
if (type == PrimitiveType::Helix)
{
auto Property = docObj->getPropertyByName("Pitch");
auto value = static_cast<const App::PropertyQuantity*>(Property);
ui.helixPitch->setValue(value->getQuantityValue());
Property = docObj->getPropertyByName("Height");
value = static_cast<const App::PropertyQuantity*>(Property);
ui.helixHeight->setValue(value->getQuantityValue());
Property = docObj->getPropertyByName("Radius");
value = static_cast<const App::PropertyQuantity*>(Property);
ui.helixRadius->setValue(value->getQuantityValue());
Property = docObj->getPropertyByName("Angle");
value = static_cast<const App::PropertyQuantity*>(Property);
ui.helixAngle->setValue(value->getQuantityValue());
Property = docObj->getPropertyByName("LocalCoord");
auto HandedIndex = static_cast<const App::PropertyEnumeration*>(Property);
ui.helixLocalCS->setCurrentIndex(HandedIndex->getValue());
// ToDo: connect signal if there is a preview of primitives available
}
}
// set limits
//
// plane
@@ -324,6 +289,95 @@ DlgPrimitives::DlgPrimitives(QWidget* parent, PrimitiveType type, bool edit, con
ui.edgeZ2->setMinimum(INT_MIN);
// RegularPolygon
ui.regularPolygonCircumradius->setRange(0, INT_MAX);
// fill the dialog with data if the primitives already exists
if (feature) {
// must be the same order as of the stacked widget
std::vector<Base::Type> types;
types.emplace_back(Part::Plane::getClassTypeId());
types.emplace_back(Part::Box::getClassTypeId());
types.emplace_back(Part::Cylinder::getClassTypeId());
types.emplace_back(Part::Cone::getClassTypeId());
types.emplace_back(Part::Sphere::getClassTypeId());
types.emplace_back(Part::Ellipsoid::getClassTypeId());
types.emplace_back(Part::Torus::getClassTypeId());
types.emplace_back(Part::Prism::getClassTypeId());
types.emplace_back(Part::Wedge::getClassTypeId());
types.emplace_back(Part::Helix::getClassTypeId());
types.emplace_back(Part::Spiral::getClassTypeId());
types.emplace_back(Part::Circle::getClassTypeId());
types.emplace_back(Part::Ellipse::getClassTypeId());
types.emplace_back(Part::Vertex::getClassTypeId());
types.emplace_back(Part::Line::getClassTypeId());
types.emplace_back(Part::RegularPolygon::getClassTypeId());
Base::Type type = feature->getTypeId();
int index = std::distance(types.begin(), std::find(types.begin(), types.end(), type));
ui.comboBox1->setCurrentIndex(index);
ui.widgetStack2->setCurrentIndex(index);
// if existing, the primitive type can not be changed by the user
ui.comboBox1->setDisabled(feature != nullptr);
// read values from the properties
if (type == Part::Plane::getClassTypeId()) {
Part::Plane* plane = static_cast<Part::Plane*>(feature);
ui.planeLength->setValue(plane->Length.getQuantityValue());
ui.planeWidth->setValue(plane->Width.getQuantityValue());
}
else if (type == Part::Box::getClassTypeId()) {
}
else if (type == Part::Cylinder::getClassTypeId()) {
}
else if (type == Part::Cone::getClassTypeId()) {
}
else if (type == Part::Sphere::getClassTypeId()) {
}
else if (type == Part::Ellipsoid::getClassTypeId()) {
}
else if (type == Part::Torus::getClassTypeId()) {
}
else if (type == Part::Prism::getClassTypeId()) {
}
else if (type == Part::Wedge::getClassTypeId()) {
}
else if (type == Part::Helix::getClassTypeId()) {
Part::Helix* helix = static_cast<Part::Helix*>(feature);
ui.helixPitch->setValue(helix->Pitch.getQuantityValue());
ui.helixHeight->setValue(helix->Height.getQuantityValue());
ui.helixRadius->setValue(helix->Radius.getQuantityValue());
ui.helixAngle->setValue(helix->Angle.getQuantityValue());
ui.helixLocalCS->setCurrentIndex(helix->LocalCoord.getValue());
// ToDo: connect signal if there is a preview of primitives available
}
else if (type == Part::Spiral::getClassTypeId()) {
}
else if (type == Part::Circle::getClassTypeId()) {
}
else if (type == Part::Ellipse::getClassTypeId()) {
}
else if (type == Part::Vertex::getClassTypeId()) {
}
else if (type == Part::Line::getClassTypeId()) {
}
else if (type == Part::RegularPolygon::getClassTypeId()) {
}
}
}
/*
@@ -725,49 +779,103 @@ void DlgPrimitives::createPrimitive(const QString& placement)
void DlgPrimitives::accept(const QString& placement)
{
QString command;
// get the current object
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (!doc)
if (featurePtr.expired())
return;
auto docObj = doc->getDocument()->getObject(ObjectNameSave);
auto ObjectName = docObj->getNameInDocument();
QString command;
App::Document* doc = featurePtr->getDocument();
Base::Type type = featurePtr->getTypeId();
QString objectName = QString::fromLatin1("App.getDocument(\"%1\").%2")
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(featurePtr->getNameInDocument()));
// the combox with the primitive type is fixed
// therefore by reading its state we know what we need to change
if (ui.comboBox1->currentIndex() == 9) { // helix
// read values from the properties
if (type == Part::Plane::getClassTypeId()) {
command = QString::fromLatin1(
"App.ActiveDocument.%1.Pitch=%2\n"
"App.ActiveDocument.%1.Height=%3\n"
"App.ActiveDocument.%1.Radius=%4\n"
"App.ActiveDocument.%1.Angle=%5\n"
"App.ActiveDocument.%1.LocalCoord=%6\n"
"App.ActiveDocument.%1.Placement=%7\n"
"App.ActiveDocument.recompute()\n")
.arg(QString::fromLatin1(ObjectName))
"%1.Length=%2\n"
"%1.Width=%3\n"
"%1.Placement=%4\n")
.arg(objectName)
.arg(ui.planeLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals())
.arg(ui.planeWidth->value().getValue(),0,'f',Base::UnitsApi::getDecimals())
.arg(placement);
}
else if (type == Part::Box::getClassTypeId()) {
}
else if (type == Part::Cylinder::getClassTypeId()) {
}
else if (type == Part::Cone::getClassTypeId()) {
}
else if (type == Part::Sphere::getClassTypeId()) {
}
else if (type == Part::Ellipsoid::getClassTypeId()) {
}
else if (type == Part::Torus::getClassTypeId()) {
}
else if (type == Part::Prism::getClassTypeId()) {
}
else if (type == Part::Wedge::getClassTypeId()) {
}
else if (type == Part::Helix::getClassTypeId()) {
command = QString::fromLatin1(
"%1.Pitch=%2\n"
"%1.Height=%3\n"
"%1.Radius=%4\n"
"%1.Angle=%5\n"
"%1.LocalCoord=%6\n"
"%1.Placement=%7\n"
"%1.recompute()\n")
.arg(objectName)
.arg(ui.helixPitch->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals())
.arg(ui.helixHeight->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals())
.arg(ui.helixRadius->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals())
.arg(ui.helixAngle->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals())
.arg(ui.helixLocalCS->currentIndex())
.arg(placement);
.arg(placement);
}
else if (type == Part::Spiral::getClassTypeId()) {
}
else if (type == Part::Circle::getClassTypeId()) {
}
else if (type == Part::Ellipse::getClassTypeId()) {
}
else if (type == Part::Vertex::getClassTypeId()) {
}
else if (type == Part::Line::getClassTypeId()) {
}
else if (type == Part::RegularPolygon::getClassTypeId()) {
}
// store command for undo
doc->openCommand(command.toUtf8());
QString cmd = tr("Edit %1").arg(QString::fromUtf8(featurePtr->Label.getValue()));
doc->openTransaction(cmd.toLatin1());
// execute command
Gui::Command::runCommand(Gui::Command::App, command.toLatin1());
// commit undo command
doc->commitCommand();
doc->commitTransaction();
}
// ----------------------------------------------
/* TRANSLATOR PartGui::Location */
Location::Location(QWidget* parent, bool edit, const char* ObjectName)
Location::Location(QWidget* parent, Part::Feature* feature)
{
Q_UNUSED(parent);
mode = 0;
@@ -779,30 +887,24 @@ Location::Location(QWidget* parent, bool edit, const char* ObjectName)
ui.AngleQSB->setUnit(Base::Unit::Angle);
// fill location widget if object already exists
if (edit) {
// get the primitives object
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (!doc)
return;
auto docObj = doc->getDocument()->getObject(ObjectName);
if (feature) {
// get the placement values
auto Property = docObj->getPropertyByName("Placement");
auto placement = static_cast<const App::PropertyPlacement*>(Property);
auto placement = feature->Placement.getValue();
auto position = placement->getValue().getPosition();
auto position = placement.getPosition();
ui.XPositionQSB->setValue(position.x);
ui.YPositionQSB->setValue(position.y);
ui.ZPositionQSB->setValue(position.z);
double rotationAngle;
Base::Vector3d rotationAxes;
auto rotation = placement->getValue().getRotation();
auto rotation = placement.getRotation();
rotation.getRawValue(rotationAxes, rotationAngle);
ui.XDirectionEdit->setValue(rotationAxes.x);
ui.YDirectionEdit->setValue(rotationAxes.y);
ui.ZDirectionEdit->setValue(rotationAxes.z);
// the angle is in this format: 180° = PI, thus transform it to deg
ui.AngleQSB->setValue(rotationAngle*180/M_PI);
ui.AngleQSB->setValue(Base::toDegrees<double>(rotationAngle));
}
}
@@ -925,6 +1027,7 @@ TaskPrimitives::TaskPrimitives()
location = new Location();
taskbox = new Gui::TaskView::TaskBox(QPixmap(), location->windowTitle() ,true, 0);
taskbox->groupLayout()->addWidget(location);
taskbox->hideGroupBox();
Content.push_back(taskbox);
}
@@ -960,20 +1063,17 @@ bool TaskPrimitives::reject()
/* TRANSLATOR PartGui::TaskPrimitivesEdit */
TaskPrimitivesEdit::TaskPrimitivesEdit(DlgPrimitives::PrimitiveType type, const char* ObjectName)
TaskPrimitivesEdit::TaskPrimitivesEdit(Part::Primitive* feature)
{
// save object name to be able to access it in accept() since if there are e.g. 3 helices
// the last one would be the active object, no matter that one is editing the first one
ObjectNameSave = ObjectName;
// create and show dialog for the primitives
Gui::TaskView::TaskBox* taskbox;
widget = new DlgPrimitives(0, type, true, ObjectName);
widget = new DlgPrimitives(nullptr, feature);
taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
// create and show dialog for the location
location = new Location(0, true, ObjectName);
location = new Location(nullptr, feature);
taskbox = new Gui::TaskView::TaskBox(QPixmap(), location->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(location);
Content.push_back(taskbox);
@@ -999,13 +1099,15 @@ void TaskPrimitivesEdit::modifyStandardButtons(QDialogButtonBox* box)
bool TaskPrimitivesEdit::accept()
{
widget->accept(location->toPlacement());
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()");
std::string document = getDocumentName(); // needed because resetEdit() deletes this instance
Gui::Command::doCommand(Gui::Command::Gui, "Gui.getDocument('%s').resetEdit()", document.c_str());
return true;
}
bool TaskPrimitivesEdit::reject()
{
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()");
std::string document = getDocumentName(); // needed because resetEdit() deletes this instance
Gui::Command::doCommand(Gui::Command::Gui, "Gui.getDocument('%s').resetEdit()", document.c_str());
return true;
}

View File

@@ -25,6 +25,7 @@
#include <QEventLoop>
#include <QPointer>
#include <App/DocumentObserver.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Mod/Part/Gui/ui_DlgPrimitives.h>
#include <Mod/Part/Gui/ui_Location.h>
@@ -35,6 +36,10 @@ class SoEventCallback;
namespace App { class Document; }
namespace Gui { class Document; }
namespace Part {
class Feature;
class Primitive;
}
namespace PartGui {
class Picker
@@ -61,13 +66,7 @@ class DlgPrimitives : public QWidget
Q_OBJECT
public:
enum PrimitiveType {
Plane, Box, Cylinder, Cone, Sphere, Ellipsoid, Torus, Prism, Wedge,
Helix, Spiral, Circle, Ellipse, Point, Line, RegPolygon
};
DlgPrimitives(QWidget* parent = 0, PrimitiveType type = PrimitiveType::Plane,
bool edit = false, const char* ObjectName = "");
DlgPrimitives(QWidget* parent = nullptr, Part::Primitive* feature = nullptr);
~DlgPrimitives();
void createPrimitive(const QString&);
void accept(const QString&);
@@ -81,6 +80,7 @@ private:
private:
Ui_DlgPrimitives ui;
App::DocumentObjectWeakPtrT featurePtr;
};
class Location : public QWidget
@@ -88,7 +88,7 @@ class Location : public QWidget
Q_OBJECT
public:
Location(QWidget* parent = 0, bool edit = false, const char* ObjectName = "");
Location(QWidget* parent = nullptr, Part::Feature* feature = nullptr);
~Location();
QString toPlacement() const;
@@ -126,7 +126,7 @@ class TaskPrimitivesEdit : public Gui::TaskView::TaskDialog
Q_OBJECT
public:
TaskPrimitivesEdit(DlgPrimitives::PrimitiveType type, const char* ObjectName);
TaskPrimitivesEdit(Part::Primitive* feature);
~TaskPrimitivesEdit();
public:

View File

@@ -83,6 +83,13 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="viewPositionButton">
<property name="text">
<string>3D view</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -94,132 +101,117 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Rotation</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="RotationAxisGB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Use custom vector for pad direction otherwise
<property name="toolTip">
<string>Use custom vector for pad direction otherwise
the sketch plane's normal vector will be used</string>
</property>
<property name="title">
<string>Rotation axis direction</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="labelXSkew">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::DoubleSpinBox" name="XDirectionEdit">
<property name="toolTip">
<string>x-component of direction vector</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="labelYSkew">
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::DoubleSpinBox" name="YDirectionEdit">
<property name="toolTip">
<string>y-component of direction vector</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="labelZSkew">
<property name="text">
<string>z</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::DoubleSpinBox" name="ZDirectionEdit">
<property name="toolTip">
<string>z-component of direction vector</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</property>
<property name="title">
<string>Rotation axis</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="labelXSkew">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::DoubleSpinBox" name="XDirectionEdit">
<property name="toolTip">
<string>x-component of direction vector</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="labelYSkew">
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::DoubleSpinBox" name="YDirectionEdit">
<property name="toolTip">
<string>y-component of direction vector</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="labelZSkew">
<property name="text">
<string>z</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::DoubleSpinBox" name="ZDirectionEdit">
<property name="toolTip">
<string>z-component of direction vector</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelLength2">

View File

@@ -24,16 +24,22 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QAction>
# include <QMenu>
#endif
#include <Base/Console.h>
#include <Base/Exception.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/PrimitiveFeature.h>
#include "ViewProvider.h"
#include "DlgPrimitives.h"
using namespace PartGui;
@@ -94,6 +100,53 @@ void ViewProviderPart::applyTransparency(const float& transparency,
// ----------------------------------------------------------------------------
PROPERTY_SOURCE(PartGui::ViewProviderPrimitive, PartGui::ViewProviderPart)
ViewProviderPrimitive::ViewProviderPrimitive()
{
}
ViewProviderPrimitive::~ViewProviderPrimitive()
{
}
void ViewProviderPrimitive::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue())), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
ViewProviderPart::setupContextMenu(menu, receiver, member);
}
bool ViewProviderPrimitive::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
if (Gui::Control().activeDialog())
return false;
PartGui::TaskPrimitivesEdit* dlg
= new PartGui::TaskPrimitivesEdit(dynamic_cast<Part::Primitive*>(getObject()));
Gui::Control().showDialog(dlg);
return true;
}
else {
ViewProviderPart::setEdit(ModNum);
return true;
}
}
void ViewProviderPrimitive::unsetEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
Gui::Control().closeDialog();
}
else {
ViewProviderPart::unsetEdit(ModNum);
}
}
// ----------------------------------------------------------------------------
void ViewProviderShapeBuilder::buildNodes(const App::Property* , std::vector<SoNode*>& ) const
{
}

View File

@@ -61,6 +61,23 @@ protected:
std::vector<App::Color>& colors);
};
class PartGuiExport ViewProviderPrimitive : public ViewProviderPart
{
PROPERTY_HEADER(PartGui::ViewProviderPrimitive);
public:
/// constructor
ViewProviderPrimitive();
/// destructor
virtual ~ViewProviderPrimitive();
void setupContextMenu(QMenu*, QObject*, const char*);
protected:
bool setEdit(int ModNum);
void unsetEdit(int ModNum);
};
} // namespace PartGui

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderBox, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderBox, PartGui::ViewProviderPrimitive)
ViewProviderBox::ViewProviderBox()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderBox:public ViewProviderPart
class PartGuiExport ViewProviderBox : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderBox);

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderCircleParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderCircleParametric, PartGui::ViewProviderPrimitive)
ViewProviderCircleParametric::ViewProviderCircleParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderCircleParametric:public ViewProviderPart
class PartGuiExport ViewProviderCircleParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderCircleParametric);

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderConeParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderConeParametric, PartGui::ViewProviderPrimitive)
ViewProviderConeParametric::ViewProviderConeParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderConeParametric:public ViewProviderPart
class PartGuiExport ViewProviderConeParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderConeParametric);

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderCylinderParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderCylinderParametric, PartGui::ViewProviderPrimitive)
ViewProviderCylinderParametric::ViewProviderCylinderParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderCylinderParametric:public ViewProviderPart
class PartGuiExport ViewProviderCylinderParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderCylinderParametric);

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderEllipseParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderEllipseParametric, PartGui::ViewProviderPrimitive)
ViewProviderEllipseParametric::ViewProviderEllipseParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderEllipseParametric:public ViewProviderPart
class PartGuiExport ViewProviderEllipseParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderEllipseParametric);

View File

@@ -30,6 +30,7 @@
#include <Gui/Application.h>
#include <Gui/Control.h>
#include <Mod/Part/App/PrimitiveFeature.h>
#include "DlgPrimitives.h"
#include "ViewProviderHelixParametric.h"
@@ -67,19 +68,13 @@ void ViewProviderHelixParametric::setupContextMenu(QMenu* menu, QObject* receive
ViewProviderSpline::setupContextMenu(menu, receiver, member);
}
void ViewProviderHelixParametric::updateData(const App::Property* prop)
{
PartGui::ViewProviderSpline::updateData(prop);
}
bool ViewProviderHelixParametric::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
if (Gui::Control().activeDialog())
return false;
auto ObjectName = getObject()->getNameInDocument();
PartGui::TaskPrimitivesEdit* dlg
= new PartGui::TaskPrimitivesEdit(PartGui::DlgPrimitives::PrimitiveType::Helix, ObjectName);
= new PartGui::TaskPrimitivesEdit(dynamic_cast<Part::Primitive*>(getObject()));
Gui::Control().showDialog(dlg);
return true;
}

View File

@@ -42,7 +42,6 @@ public:
void setupContextMenu(QMenu*, QObject*, const char*);
protected:
void updateData(const App::Property*);
bool setEdit(int ModNum);
void unsetEdit(int ModNum);

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderLineParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderLineParametric, PartGui::ViewProviderPrimitive)
ViewProviderLineParametric::ViewProviderLineParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderLineParametric:public ViewProviderPart
class PartGuiExport ViewProviderLineParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderLineParametric);

View File

@@ -36,7 +36,7 @@ using namespace PartGui;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderPlaneParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderPlaneParametric, PartGui::ViewProviderPrimitive)
ViewProviderPlaneParametric::ViewProviderPlaneParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderPlaneParametric : public ViewProviderPart
class PartGuiExport ViewProviderPlaneParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderPlaneParametric);

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderPointParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderPointParametric, PartGui::ViewProviderPrimitive)
ViewProviderPointParametric::ViewProviderPointParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderPointParametric:public ViewProviderPart
class PartGuiExport ViewProviderPointParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderPointParametric);

View File

@@ -35,7 +35,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderPrism, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderPrism, PartGui::ViewProviderPrimitive)
ViewProviderPrism::ViewProviderPrism()
@@ -67,7 +67,7 @@ std::vector<std::string> ViewProviderPrism::getDisplayModes(void) const
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderWedge, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderWedge, PartGui::ViewProviderPrimitive)
ViewProviderWedge::ViewProviderWedge()

View File

@@ -30,7 +30,7 @@
namespace PartGui {
class PartGuiExport ViewProviderPrism : public ViewProviderPart
class PartGuiExport ViewProviderPrism : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderPrism);
@@ -46,7 +46,7 @@ protected:
};
class PartGuiExport ViewProviderWedge : public ViewProviderPart
class PartGuiExport ViewProviderWedge : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderWedge);

View File

@@ -35,7 +35,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderRegularPolygon, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderRegularPolygon, PartGui::ViewProviderPrimitive)
ViewProviderRegularPolygon::ViewProviderRegularPolygon()

View File

@@ -30,7 +30,7 @@
namespace PartGui {
class PartGuiExport ViewProviderRegularPolygon : public ViewProviderPart
class PartGuiExport ViewProviderRegularPolygon : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderRegularPolygon);

View File

@@ -34,7 +34,7 @@ using namespace PartGui;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderSphereParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderSphereParametric, PartGui::ViewProviderPrimitive)
ViewProviderSphereParametric::ViewProviderSphereParametric()
{
@@ -61,7 +61,7 @@ std::vector<std::string> ViewProviderSphereParametric::getDisplayModes(void) con
// ----------------------------------------------------------------------------
PROPERTY_SOURCE(PartGui::ViewProviderEllipsoid, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderEllipsoid, PartGui::ViewProviderPrimitive)
ViewProviderEllipsoid::ViewProviderEllipsoid()
{

View File

@@ -28,7 +28,7 @@
namespace PartGui {
class PartGuiExport ViewProviderSphereParametric : public ViewProviderPart
class PartGuiExport ViewProviderSphereParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderSphereParametric);
@@ -44,7 +44,7 @@ protected:
};
class PartGuiExport ViewProviderEllipsoid : public ViewProviderPart
class PartGuiExport ViewProviderEllipsoid : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderEllipsoid);

View File

@@ -36,7 +36,7 @@ using namespace std;
//**************************************************************************
// Construction/Destruction
PROPERTY_SOURCE(PartGui::ViewProviderTorusParametric, PartGui::ViewProviderPart)
PROPERTY_SOURCE(PartGui::ViewProviderTorusParametric, PartGui::ViewProviderPrimitive)
ViewProviderTorusParametric::ViewProviderTorusParametric()

View File

@@ -36,7 +36,7 @@ class SoTransform;
namespace PartGui {
class PartGuiExport ViewProviderTorusParametric:public ViewProviderPart
class PartGuiExport ViewProviderTorusParametric : public ViewProviderPrimitive
{
PROPERTY_HEADER(PartGui::ViewProviderTorusParametric);