+ Gui for Pocket and Revolution

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5059 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
jriegel 2011-10-24 20:10:59 +00:00
parent 45e5b4135d
commit aaf5f08d8e
14 changed files with 449 additions and 110 deletions

View File

@ -115,14 +115,10 @@ App::DocumentObjectExecReturn *Pad::execute(void)
SupportObject = static_cast<Part::Feature*>(SupportLink);
#if 0
//TopoDS_Wire theWire = TopoDS::Wire(shape);
//TopoDS_Face aFace = BRepBuilderAPI_MakeFace(theWire);
#else
TopoDS_Shape aFace = makeFace(wires);
if (aFace.IsNull())
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
#endif
// lengthen the vector
SketchOrientationVector *= Length.getValue();
@ -159,14 +155,11 @@ App::DocumentObjectExecReturn *Pad::execute(void)
// get the first
TopoDS_Solid solRes = TopoDS::Solid(anExplorer.Current());
//TopoDS_Solid solRes = TopoDS::Solid(result);
// lets check if the result is a solid
//if (result.ShapeType() != TopAbs_SOLID)
// return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
if (solRes.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
this->Shape.setValue(solRes);
//this->Shape.setValue(result);
}
else
return new App::DocumentObjectExecReturn("Support is not a solid");

View File

@ -37,6 +37,7 @@
# include <TopoDS.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS_Wire.hxx>
# include <TopoDS_Solid.hxx>
# include <TopExp_Explorer.hxx>
# include <BRepAlgoAPI_Cut.hxx>
#endif
@ -138,7 +139,18 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
// Let's check if the fusion has been successful
if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Cut with support failed");
this->Shape.setValue(mkCut.Shape());
// we have to get the solids (fuse create seldomly compounds)
TopExp_Explorer anExplorer;
anExplorer.Init(mkCut.Shape(),TopAbs_SOLID);
TopoDS_Solid solRes = TopoDS::Solid(anExplorer.Current());
if (solRes.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
this->Shape.setValue(solRes);
//this->Shape.setValue(mkCut.Shape());
}
else{
return new App::DocumentObjectExecReturn("Cannot create a tool out of sketch with no support");

View File

@ -93,11 +93,27 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
}
if (wires.empty()) // there can be several wires
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
Base::Vector3f b = Base.getValue();
#if 0
App::DocumentObject* support = sketch->Support.getValue();
Base::Placement placement = sketch->Placement.getValue();
Base::Vector3d axis(0,1,0);
placement.getRotation().multVec(axis, axis);
Base::BoundBox3d bbox = sketch->Shape.getBoundingBox();
bbox.Enlarge(0.1);
Base::Vector3d base(bbox.MaxX, bbox.MaxY, bbox.MaxZ);
#endif
// get the Sketch plane
Base::Placement SketchPos = static_cast<Part::Part2DObject*>(link)->Placement.getValue();
Base::Rotation SketchOrientation = SketchPos.getRotation();
// get rvolve axis
Base::Vector3f v = Axis.getValue();
Base::Vector3d SketchOrientationVector(v.x,v.y,v.z);
SketchOrientation.multVec(SketchOrientationVector,SketchOrientationVector);
Base::Vector3f b(0,0,0);
gp_Pnt pnt(b.x,b.y,b.z);
gp_Dir dir(v.x,v.y,v.z);
gp_Dir dir(SketchOrientationVector.x,SketchOrientationVector.y,SketchOrientationVector.z);
// get the support of the Sketch if any
App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(link)->Support.getValue();

View File

@ -227,7 +227,7 @@ void CmdPartDesignPocket::activated(int iMsg)
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument());
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument());
}
commitCommand();
doCommand(Gui,"Gui.activeDocument().setEdit('%s',2)",FeatName.c_str());
copyVisual(FeatName.c_str(), "ShapeColor", support->getNameInDocument());
copyVisual(FeatName.c_str(), "LineColor", support->getNameInDocument());
@ -289,18 +289,11 @@ void CmdPartDesignRevolution::activated(int iMsg)
}
App::DocumentObject* support = sketch->Support.getValue();
Base::Placement placement = sketch->Placement.getValue();
Base::Vector3d axis(0,1,0);
placement.getRotation().multVec(axis, axis);
Base::BoundBox3d bbox = sketch->Shape.getBoundingBox();
bbox.Enlarge(0.1);
Base::Vector3d base(bbox.MaxX, bbox.MaxY, bbox.MaxZ);
openCommand("Make Revolution");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Revolution\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Sketch = App.activeDocument().%s",FeatName.c_str(),sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Base = App.Vector(%f,%f,%f)",FeatName.c_str(), base.x, base.y, base.z);
doCommand(Doc,"App.activeDocument().%s.Axis = App.Vector(%f,%f,%f)",FeatName.c_str(), axis.x, axis.y, axis.z);
doCommand(Doc,"App.activeDocument().%s.Axis = App.Vector(0,1,0)",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Angle = 360.0",FeatName.c_str());
updateActive();
if (isActiveObjectValid()) {
@ -308,8 +301,7 @@ void CmdPartDesignRevolution::activated(int iMsg)
if (support)
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument());
}
commitCommand();
adjustCameraPosition();
doCommand(Gui,"Gui.activeDocument().setEdit('%s',2)",FeatName.c_str());
if (support) {
copyVisual(FeatName.c_str(), "ShapeColor", support->getNameInDocument());

View File

@ -28,6 +28,8 @@
#include "ui_TaskPocketParameters.h"
#include "TaskPocketParameters.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -36,6 +38,8 @@
#include <Base/Console.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeaturePocket.h>
#include <Mod/Sketcher/App/SketchObject.h>
using namespace PartDesignGui;
@ -43,8 +47,8 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskPocketParameters */
TaskPocketParameters::TaskPocketParameters(QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("TaskPocketParameters"),true, parent)
TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Pocket"),tr("Pocket parameters"),true, parent),PocketView(PocketView)
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
@ -52,15 +56,47 @@ TaskPocketParameters::TaskPocketParameters(QWidget *parent)
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
this->groupLayout()->addWidget(proxy);
Gui::Selection().Attach(this);
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
double l = pcPocket->Length.getValue();
ui->doubleSpinBox->setValue(l);
ui->doubleSpinBox->selectAll();
//// check if the sketch has support
//Sketcher::SketchObject *pcSketch;
//if (pcPocket->Sketch.getValue()) {
// pcSketch = static_cast<Sketcher::SketchObject*>(pcPocket->Sketch.getValue());
// if (pcSketch->Support.getValue())
// // in case of sketch with support, reverse makes no sense (goes into the part)
// ui->checkBoxReversed->setEnabled(0);
// else
// ui->checkBoxReversed->setChecked(reversed);
//}
setFocus ();
}
void TaskPocketParameters::onLengthChanged(double len)
{
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
pcPocket->Length.setValue((float)len);
pcPocket->getDocument()->recomputeFeature(pcPocket);
}
double TaskPocketParameters::getLength(void) const
{
return ui->doubleSpinBox->value();
}
TaskPocketParameters::~TaskPocketParameters()
{
delete ui;
Gui::Selection().Detach(this);
}
void TaskPocketParameters::changeEvent(QEvent *e)
@ -71,18 +107,6 @@ void TaskPocketParameters::changeEvent(QEvent *e)
}
}
/// @cond DOXERR
void TaskPocketParameters::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
Gui::SelectionSingleton::MessageType Reason)
{
if (Reason.Type == SelectionChanges::AddSelection ||
Reason.Type == SelectionChanges::RmvSelection ||
Reason.Type == SelectionChanges::SetSelection ||
Reason.Type == SelectionChanges::ClrSelection) {
}
}
/// @endcond
//**************************************************************************
//**************************************************************************
// TaskDialog
@ -92,7 +116,7 @@ TaskDlgPocketParameters::TaskDlgPocketParameters(ViewProviderPocket *PocketView)
: TaskDialog(),PocketView(PocketView)
{
assert(PocketView);
parameter = new TaskPocketParameters();
parameter = new TaskPocketParameters(PocketView);
Content.push_back(parameter);
}
@ -107,7 +131,7 @@ TaskDlgPocketParameters::~TaskDlgPocketParameters()
void TaskDlgPocketParameters::open()
{
}
void TaskDlgPocketParameters::clicked(int)
@ -117,25 +141,46 @@ void TaskDlgPocketParameters::clicked(int)
bool TaskDlgPocketParameters::accept()
{
return true;
}
std::string name = PocketView->getObject()->getNameInDocument();
bool TaskDlgPocketParameters::reject()
{
Gui::Command::openCommand("Pocket changed");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
//Gui::Command::openCommand("Pocket changed");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),parameter->getLength());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
return true;
}
void TaskDlgPocketParameters::helpRequested()
bool TaskDlgPocketParameters::reject()
{
// get the support and Sketch
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
if (pcPocket->Sketch.getValue()) {
pcSketch = static_cast<Sketcher::SketchObject*>(pcPocket->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
// role back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the support is visible again
if (!Gui::Application::Instance->getViewProvider(pcPocket)) {
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
}
//Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
//Gui::Command::commitCommand();
return true;
}
#include "moc_TaskPocketParameters.cpp"

View File

@ -19,7 +19,7 @@
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_TASKVIEW_TaskPocketParameters_H
#define GUI_TASKVIEW_TaskPocketParameters_H
@ -44,18 +44,18 @@ namespace PartDesignGui {
class TaskPocketParameters : public Gui::TaskView::TaskBox, public Gui::SelectionSingleton::ObserverType
class TaskPocketParameters : public Gui::TaskView::TaskBox
{
Q_OBJECT
public:
TaskPocketParameters(QWidget *parent = 0);
TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent = 0);
~TaskPocketParameters();
/// Observer message from the Selection
void OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
Gui::SelectionSingleton::MessageType Reason);
double getLength(void) const;
private Q_SLOTS:
void onLengthChanged(double);
protected:
void changeEvent(QEvent *e);
@ -65,6 +65,7 @@ private:
private:
QWidget* proxy;
Ui_TaskPocketParameters* ui;
ViewProviderPocket *PocketView;
};
/// simulation dialog for the TaskView
@ -79,6 +80,7 @@ public:
ViewProviderPocket* getPocketView() const
{ return PocketView; }
public:
/// is called the TaskView when the dialog is opened
virtual void open();
@ -89,13 +91,12 @@ public:
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
/// is called by the framework if the user presses the help button
virtual void helpRequested();
virtual bool isAllowedAlterDocument(void) const
{ return false; }
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
{ return QDialogButtonBox::Close|QDialogButtonBox::Help; }
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:
ViewProviderPocket *PocketView;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>137</width>
<height>116</height>
<height>68</height>
</rect>
</property>
<property name="windowTitle">
@ -30,16 +30,6 @@
<string>Dimension</string>
</property>
</item>
<item>
<property name="text">
<string>Up to last</string>
</property>
</item>
<item>
<property name="text">
<string>Up to first</string>
</property>
</item>
</widget>
</item>
</layout>
@ -49,7 +39,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Size:</string>
<string>Length</string>
</property>
</widget>
</item>

View File

@ -28,6 +28,8 @@
#include "ui_TaskRevolutionParameters.h"
#include "TaskRevolutionParameters.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -36,6 +38,8 @@
#include <Base/Console.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeatureRevolution.h>
#include <Mod/Sketcher/App/SketchObject.h>
using namespace PartDesignGui;
@ -43,8 +47,8 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskRevolutionParameters */
TaskRevolutionParameters::TaskRevolutionParameters(QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("TaskRevolutionParameters"),true, parent)
TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *RevolutionView,QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Revolution"),tr("Revolution parameters"),true, parent),RevolutionView(RevolutionView)
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
@ -52,15 +56,63 @@ TaskRevolutionParameters::TaskRevolutionParameters(QWidget *parent)
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(onAngleChanged(double)));
connect(ui->axis, SIGNAL(activated(int)),
this, SLOT(onAxisChanged(int)));
this->groupLayout()->addWidget(proxy);
Gui::Selection().Attach(this);
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
double l = pcRevolution->Angle.getValue();
Base::Vector3f Ax = pcRevolution->Axis.getValue();
ui->doubleSpinBox->setValue(l);
if(Ax.y > 0)
ui->axis->setCurrentIndex(0);
else
ui->axis->setCurrentIndex(1);
setFocus ();
}
void TaskRevolutionParameters::onAngleChanged(double len)
{
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
pcRevolution->Angle.setValue((float)len);
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
}
void TaskRevolutionParameters::onAxisChanged(int num)
{
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
if(num == 0)
pcRevolution->Axis.setValue(Base::Vector3f(0,1,0));
else
pcRevolution->Axis.setValue(Base::Vector3f(1,0,0));
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
}
double TaskRevolutionParameters::getAngle(void) const
{
return ui->doubleSpinBox->value();
}
Base::Vector3f TaskRevolutionParameters::getAxis(void) const
{
if( ui->axis->currentIndex() == 0)
return Base::Vector3f(0,1,0);
else
return Base::Vector3f(1,0,0);
}
TaskRevolutionParameters::~TaskRevolutionParameters()
{
delete ui;
Gui::Selection().Detach(this);
}
void TaskRevolutionParameters::changeEvent(QEvent *e)
@ -71,18 +123,6 @@ void TaskRevolutionParameters::changeEvent(QEvent *e)
}
}
/// @cond DOXERR
void TaskRevolutionParameters::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
Gui::SelectionSingleton::MessageType Reason)
{
if (Reason.Type == SelectionChanges::AddSelection ||
Reason.Type == SelectionChanges::RmvSelection ||
Reason.Type == SelectionChanges::SetSelection ||
Reason.Type == SelectionChanges::ClrSelection) {
}
}
/// @endcond
//**************************************************************************
//**************************************************************************
// TaskDialog
@ -92,7 +132,7 @@ TaskDlgRevolutionParameters::TaskDlgRevolutionParameters(ViewProviderRevolution
: TaskDialog(),RevolutionView(RevolutionView)
{
assert(RevolutionView);
parameter = new TaskRevolutionParameters();
parameter = new TaskRevolutionParameters(RevolutionView);
Content.push_back(parameter);
}
@ -107,7 +147,7 @@ TaskDlgRevolutionParameters::~TaskDlgRevolutionParameters()
void TaskDlgRevolutionParameters::open()
{
}
void TaskDlgRevolutionParameters::clicked(int)
@ -117,25 +157,48 @@ void TaskDlgRevolutionParameters::clicked(int)
bool TaskDlgRevolutionParameters::accept()
{
return true;
}
std::string name = RevolutionView->getObject()->getNameInDocument();
bool TaskDlgRevolutionParameters::reject()
{
Gui::Command::openCommand("Revolution changed");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
//Gui::Command::openCommand("Revolution changed");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),parameter->getAngle());
Base::Vector3f axis = parameter->getAxis();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = FreeCAD.Vector(%f,%f,%f)",name.c_str(),axis.x,axis.y,axis.z);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
return true;
}
void TaskDlgRevolutionParameters::helpRequested()
bool TaskDlgRevolutionParameters::reject()
{
// get the support and Sketch
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(RevolutionView->getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
if (pcRevolution->Sketch.getValue()) {
pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
// role back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the support is visible again
if (!Gui::Application::Instance->getViewProvider(pcRevolution)) {
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
}
//Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
//Gui::Command::commitCommand();
return true;
}
#include "moc_TaskRevolutionParameters.cpp"

View File

@ -44,18 +44,20 @@ namespace PartDesignGui {
class TaskRevolutionParameters : public Gui::TaskView::TaskBox, public Gui::SelectionSingleton::ObserverType
class TaskRevolutionParameters : public Gui::TaskView::TaskBox
{
Q_OBJECT
public:
TaskRevolutionParameters(QWidget *parent = 0);
TaskRevolutionParameters(ViewProviderRevolution *RevolutionView,QWidget *parent = 0);
~TaskRevolutionParameters();
/// Observer message from the Selection
void OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
Gui::SelectionSingleton::MessageType Reason);
Base::Vector3f getAxis (void) const;
double getAngle(void) const;
private Q_SLOTS:
void onAngleChanged(double);
void onAxisChanged(int);
protected:
void changeEvent(QEvent *e);
@ -65,6 +67,7 @@ private:
private:
QWidget* proxy;
Ui_TaskRevolutionParameters* ui;
ViewProviderRevolution *RevolutionView;
};
/// simulation dialog for the TaskView
@ -79,6 +82,7 @@ public:
ViewProviderRevolution* getRevolutionView() const
{ return RevolutionView; }
public:
/// is called the TaskView when the dialog is opened
virtual void open();
@ -89,13 +93,12 @@ public:
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
/// is called by the framework if the user presses the help button
virtual void helpRequested();
virtual bool isAllowedAlterDocument(void) const
{ return false; }
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
{ return QDialogButtonBox::Close|QDialogButtonBox::Help; }
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:
ViewProviderRevolution *RevolutionView;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>136</width>
<height>58</height>
<width>182</width>
<height>68</height>
</rect>
</property>
<property name="windowTitle">
@ -15,7 +15,32 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Axis:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="axis">
<item>
<property name="text">
<string>Vertical</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
@ -24,7 +49,20 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
<widget class="QDoubleSpinBox" name="doubleSpinBox">
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>360.000000000000000</double>
</property>
<property name="singleStep">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>360.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>

View File

@ -27,7 +27,13 @@
#endif
#include "ViewProviderPocket.h"
#include <Mod/PartDesign/App/FeaturePad.h>
#include "TaskPocketParameters.h"
#include <Mod/PartDesign/App/FeaturePocket.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Application.h>
using namespace PartDesignGui;
@ -44,9 +50,87 @@ ViewProviderPocket::~ViewProviderPocket()
std::vector<App::DocumentObject*> ViewProviderPocket::claimChildren(void)const
{
std::vector<App::DocumentObject*> temp;
temp.push_back(static_cast<PartDesign::Pad*>(getObject())->Sketch.getValue());
temp.push_back(static_cast<PartDesign::Pocket*>(getObject())->Sketch.getValue());
return temp;
}
void ViewProviderPocket::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit pocket"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
act = menu->addAction(QObject::tr("Transform"), receiver, member);
act->setData(QVariant((int)ViewProvider::Transform));
}
bool ViewProviderPocket::setEdit(int ModNum)
{
// When double-clicking on the item for this pad the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgPocketParameters *padDlg = qobject_cast<TaskDlgPocketParameters *>(dlg);
if (padDlg && padDlg->getPocketView() != this)
padDlg = 0; // another pad left open its task panel
if (dlg && !padDlg) {
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?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
Gui::Control().closeDialog();
else
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
if(ModNum == 1)
Gui::Command::openCommand("Change pocket parameters");
// start the edit dialog
if (padDlg)
Gui::Control().showDialog(padDlg);
else
Gui::Control().showDialog(new TaskDlgPocketParameters(this));
return true;
}
void ViewProviderPocket::unsetEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
// and update the pad
//getSketchObject()->getDocument()->recompute();
// when pressing ESC make sure to close the dialog
Gui::Control().closeDialog();
}
else {
PartGui::ViewProviderPart::unsetEdit(ModNum);
}
}
bool ViewProviderPocket::onDelete(const std::vector<std::string> &)
{
// get the support and Sketch
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
if (pcPocket->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcPocket->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
// if abort command deleted the object the support is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
return true;
}

View File

@ -41,6 +41,14 @@ public:
/// grouping handling
std::vector<App::DocumentObject*> claimChildren(void)const;
void setupContextMenu(QMenu*, QObject*, const char*);
virtual bool onDelete(const std::vector<std::string> &);
protected:
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
};

View File

@ -26,8 +26,14 @@
#ifndef _PreComp_
#endif
#include "ViewProviderRevolution.h"
#include <Mod/PartDesign/App/FeatureRevolution.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Application.h>
#include "ViewProviderRevolution.h"
#include "TaskRevolutionParameters.h"
using namespace PartDesignGui;
@ -49,4 +55,83 @@ std::vector<App::DocumentObject*> ViewProviderRevolution::claimChildren(void)con
return temp;
}
void ViewProviderRevolution::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit revolution"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
act = menu->addAction(QObject::tr("Transform"), receiver, member);
act->setData(QVariant((int)ViewProvider::Transform));
}
bool ViewProviderRevolution::setEdit(int ModNum)
{
// When double-clicking on the item for this pad the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgRevolutionParameters *padDlg = qobject_cast<TaskDlgRevolutionParameters *>(dlg);
if (padDlg && padDlg->getRevolutionView() != this)
padDlg = 0; // another pad left open its task panel
if (dlg && !padDlg) {
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?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
Gui::Control().closeDialog();
else
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
if(ModNum == 1)
Gui::Command::openCommand("Change revolution parameters");
// start the edit dialog
if (padDlg)
Gui::Control().showDialog(padDlg);
else
Gui::Control().showDialog(new TaskDlgRevolutionParameters(this));
return true;
}
void ViewProviderRevolution::unsetEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
// and update the pad
//getSketchObject()->getDocument()->recompute();
// when pressing ESC make sure to close the dialog
Gui::Control().closeDialog();
}
else {
PartGui::ViewProviderPart::unsetEdit(ModNum);
}
}
bool ViewProviderRevolution::onDelete(const std::vector<std::string> &)
{
// get the support and Sketch
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
if (pcRevolution->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
// if abort command deleted the object the support is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
return true;
}

View File

@ -41,6 +41,15 @@ public:
/// grouping handling
std::vector<App::DocumentObject*> claimChildren(void)const;
void setupContextMenu(QMenu*, QObject*, const char*);
virtual bool onDelete(const std::vector<std::string> &);
protected:
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
};