Groove feature (code is 99% identical to Revolution feature)
This commit is contained in:
parent
cf31d43e54
commit
33ecf9e768
|
@ -34,6 +34,7 @@
|
|||
#include "FeatureFillet.h"
|
||||
#include "FeatureSketchBased.h"
|
||||
#include "FeatureRevolution.h"
|
||||
#include "FeatureGroove.h"
|
||||
#include "Body.h"
|
||||
#include "FeatureDressUp.h"
|
||||
#include "FeatureChamfer.h"
|
||||
|
@ -82,6 +83,7 @@ void PartDesignExport initPartDesign()
|
|||
PartDesign::Pocket ::init();
|
||||
PartDesign::Fillet ::init();
|
||||
PartDesign::Revolution ::init();
|
||||
PartDesign::Groove ::init();
|
||||
PartDesign::Chamfer ::init();
|
||||
PartDesign::Face ::init();
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ SET(FeaturesSketchBased_SRCS
|
|||
FeaturePocket.h
|
||||
FeatureRevolution.cpp
|
||||
FeatureRevolution.h
|
||||
FeatureGroove.cpp
|
||||
FeatureGroove.h
|
||||
FeatureAdditive.cpp
|
||||
FeatureAdditive.h
|
||||
FeatureSubtractive.h
|
||||
|
|
207
src/Mod/PartDesign/App/FeatureGroove.cpp
Normal file
207
src/Mod/PartDesign/App/FeatureGroove.cpp
Normal file
|
@ -0,0 +1,207 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepPrimAPI_MakeRevol.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS_Wire.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Axis.h>
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "FeatureGroove.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Groove, PartDesign::SketchBased)
|
||||
|
||||
Groove::Groove()
|
||||
{
|
||||
ADD_PROPERTY(Base,(Base::Vector3f(0.0f,0.0f,0.0f)));
|
||||
ADD_PROPERTY(Axis,(Base::Vector3f(0.0f,1.0f,0.0f)));
|
||||
ADD_PROPERTY(Angle,(360.0));
|
||||
ADD_PROPERTY_TYPE(ReferenceAxis,(0),"Groove",(App::PropertyType)(App::Prop_None),"Reference axis of Groove");
|
||||
ADD_PROPERTY(Midplane,(0));
|
||||
ADD_PROPERTY(Reversed, (0));
|
||||
}
|
||||
|
||||
short Groove::mustExecute() const
|
||||
{
|
||||
if (Placement.isTouched() ||
|
||||
Sketch.isTouched() ||
|
||||
ReferenceAxis.isTouched() ||
|
||||
Axis.isTouched() ||
|
||||
Base.isTouched() ||
|
||||
Angle.isTouched() ||
|
||||
Midplane.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Groove::execute(void)
|
||||
{
|
||||
App::DocumentObject* link = Sketch.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No sketch linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
|
||||
|
||||
Part::Part2DObject* pcSketch=static_cast<Part::Part2DObject*>(link);
|
||||
|
||||
TopoDS_Shape shape = pcSketch->Shape.getShape()._Shape;
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
||||
// this is a workaround for an obscure OCC bug which leads to empty tessellations
|
||||
// for some faces. Making an explicit copy of the linked shape seems to fix it.
|
||||
// The error only happens when re-computing the shape.
|
||||
if (!this->Shape.getValue().IsNull()) {
|
||||
BRepBuilderAPI_Copy copy(shape);
|
||||
shape = copy.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
}
|
||||
|
||||
TopExp_Explorer ex;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
wires.push_back(TopoDS::Wire(ex.Current()));
|
||||
}
|
||||
if (wires.empty()) // there can be several wires
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
|
||||
|
||||
// get the Sketch plane
|
||||
Base::Placement SketchPlm = pcSketch->Placement.getValue();
|
||||
|
||||
// get reference axis
|
||||
App::DocumentObject *pcReferenceAxis = ReferenceAxis.getValue();
|
||||
const std::vector<std::string> &subReferenceAxis = ReferenceAxis.getSubValues();
|
||||
if (pcReferenceAxis && pcReferenceAxis == pcSketch) {
|
||||
bool hasValidAxis=false;
|
||||
Base::Axis axis;
|
||||
if (subReferenceAxis[0] == "V_Axis") {
|
||||
hasValidAxis = true;
|
||||
axis = pcSketch->getAxis(Part::Part2DObject::V_Axis);
|
||||
}
|
||||
else if (subReferenceAxis[0] == "H_Axis") {
|
||||
hasValidAxis = true;
|
||||
axis = pcSketch->getAxis(Part::Part2DObject::H_Axis);
|
||||
}
|
||||
else if (subReferenceAxis[0].size() > 4 && subReferenceAxis[0].substr(0,4) == "Axis") {
|
||||
int AxId = std::atoi(subReferenceAxis[0].substr(4,4000).c_str());
|
||||
if (AxId >= 0 && AxId < pcSketch->getAxisCount()) {
|
||||
hasValidAxis = true;
|
||||
axis = pcSketch->getAxis(AxId);
|
||||
}
|
||||
}
|
||||
if (hasValidAxis) {
|
||||
axis *= SketchPlm;
|
||||
Base::Vector3d base=axis.getBase();
|
||||
Base::Vector3d dir=axis.getDirection();
|
||||
Base.setValue(base.x,base.y,base.z);
|
||||
Axis.setValue(dir.x,dir.y,dir.z);
|
||||
}
|
||||
}
|
||||
|
||||
// get revolve axis
|
||||
Base::Vector3f b = Base.getValue();
|
||||
gp_Pnt pnt(b.x,b.y,b.z);
|
||||
Base::Vector3f v = Axis.getValue();
|
||||
gp_Dir dir(v.x,v.y,v.z);
|
||||
|
||||
// get the support of the Sketch if any
|
||||
App::DocumentObject* pcSupport = pcSketch->Support.getValue();
|
||||
Part::Feature *SupportObject = 0;
|
||||
if (pcSupport && pcSupport->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
SupportObject = static_cast<Part::Feature*>(pcSupport);
|
||||
|
||||
TopoDS_Shape aFace = makeFace(wires);
|
||||
if (aFace.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
|
||||
|
||||
// Rotate the face by half the angle to get Groove symmetric to sketch plane
|
||||
if (Midplane.getValue()) {
|
||||
gp_Trsf mov;
|
||||
mov.SetRotation(gp_Ax1(pnt, dir), Base::toRadians<double>(Angle.getValue()) * (-1.0) / 2.0);
|
||||
TopLoc_Location loc(mov);
|
||||
aFace.Move(loc);
|
||||
}
|
||||
|
||||
this->positionBySketch();
|
||||
TopLoc_Location invObjLoc = this->getLocation().Inverted();
|
||||
pnt.Transform(invObjLoc.Transformation());
|
||||
dir.Transform(invObjLoc.Transformation());
|
||||
|
||||
// Reverse angle if selected
|
||||
double angle = Base::toRadians<double>(Angle.getValue());
|
||||
if (Reversed.getValue() && !Midplane.getValue())
|
||||
angle *= (-1.0);
|
||||
|
||||
try {
|
||||
// revolve the face to a solid
|
||||
BRepPrimAPI_MakeRevol RevolMaker(aFace.Moved(invObjLoc), gp_Ax1(pnt, dir), angle);
|
||||
|
||||
if (RevolMaker.IsDone()) {
|
||||
TopoDS_Shape result = RevolMaker.Shape();
|
||||
// if the sketch has a support fuse them to get one result object (PAD!)
|
||||
if (SupportObject) {
|
||||
const TopoDS_Shape& support = SupportObject->Shape.getValue();
|
||||
if (!support.IsNull() && support.ShapeType() == TopAbs_SOLID) {
|
||||
// Let's call algorithm computing a fuse operation:
|
||||
BRepAlgoAPI_Cut mkCut(support.Moved(invObjLoc), result);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkCut.IsDone())
|
||||
throw Base::Exception("Cut out of support failed");
|
||||
result = mkCut.Shape();
|
||||
}
|
||||
}
|
||||
|
||||
this->Shape.setValue(result);
|
||||
}
|
||||
else
|
||||
return new App::DocumentObjectExecReturn("Could not revolve the sketch!");
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
66
src/Mod/PartDesign/App/FeatureGroove.h
Normal file
66
src/Mod/PartDesign/App/FeatureGroove.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2010 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PARTDESIGN_Groove_H
|
||||
#define PARTDESIGN_Groove_H
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include "FeatureSketchBased.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class Groove : public SketchBased
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Groove);
|
||||
|
||||
public:
|
||||
Groove();
|
||||
|
||||
App::PropertyVector Base;
|
||||
App::PropertyVector Axis;
|
||||
App::PropertyAngle Angle;
|
||||
App::PropertyBool Midplane;
|
||||
App::PropertyBool Reversed;
|
||||
|
||||
/** if this property is set to a valid link, both Axis and Base properties
|
||||
* are calculated according to the linked line
|
||||
*/
|
||||
App::PropertyLinkSub ReferenceAxis;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderGroove";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PART_Groove_H
|
|
@ -37,6 +37,7 @@
|
|||
#include "ViewProviderChamfer.h"
|
||||
#include "ViewProviderFillet.h"
|
||||
#include "ViewProviderRevolution.h"
|
||||
#include "ViewProviderGroove.h"
|
||||
|
||||
//#include "resources/qrc_PartDesign.cpp"
|
||||
|
||||
|
@ -83,6 +84,7 @@ void PartDesignGuiExport initPartDesignGui()
|
|||
PartDesignGui::ViewProviderPocket ::init();
|
||||
PartDesignGui::ViewProviderPad ::init();
|
||||
PartDesignGui::ViewProviderRevolution::init();
|
||||
PartDesignGui::ViewProviderGroove ::init();
|
||||
PartDesignGui::ViewProviderChamfer ::init();
|
||||
PartDesignGui::ViewProviderFillet ::init();
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ set(PartDesignGui_MOC_HDRS
|
|||
TaskFilletParameters.h
|
||||
TaskHoleParameters.h
|
||||
TaskRevolutionParameters.h
|
||||
TaskGrooveParameters.h
|
||||
)
|
||||
fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS})
|
||||
SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS})
|
||||
|
@ -46,6 +47,7 @@ set(PartDesignGui_UIC_SRCS
|
|||
TaskFilletParameters.ui
|
||||
TaskHoleParameters.ui
|
||||
TaskRevolutionParameters.ui
|
||||
TaskGrooveParameters.ui
|
||||
)
|
||||
qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS})
|
||||
|
||||
|
@ -64,6 +66,8 @@ SET(PartDesignGuiViewProvider_SRCS
|
|||
ViewProviderFillet.h
|
||||
ViewProviderRevolution.cpp
|
||||
ViewProviderRevolution.h
|
||||
ViewProviderGroove.cpp
|
||||
ViewProviderGroove.h
|
||||
ViewProviderPatternRectangular.cpp
|
||||
ViewProviderPatternRectangular.h
|
||||
)
|
||||
|
@ -88,6 +92,9 @@ SET(PartDesignGuiTaskDlgs_SRCS
|
|||
TaskRevolutionParameters.ui
|
||||
TaskRevolutionParameters.cpp
|
||||
TaskRevolutionParameters.h
|
||||
TaskGrooveParameters.ui
|
||||
TaskGrooveParameters.cpp
|
||||
TaskGrooveParameters.h
|
||||
TaskHoleParameters.ui
|
||||
TaskHoleParameters.cpp
|
||||
TaskHoleParameters.h
|
||||
|
|
|
@ -327,6 +327,82 @@ bool CmdPartDesignRevolution::isActive(void)
|
|||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// PartDesign_Groove
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(CmdPartDesignGroove);
|
||||
|
||||
CmdPartDesignGroove::CmdPartDesignGroove()
|
||||
: Command("PartDesign_Groove")
|
||||
{
|
||||
sAppModule = "PartDesign";
|
||||
sGroup = QT_TR_NOOP("PartDesign");
|
||||
sMenuText = QT_TR_NOOP("Groove");
|
||||
sToolTipText = QT_TR_NOOP("Revolve a selected sketch");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "PartDesign_Groove";
|
||||
}
|
||||
|
||||
void CmdPartDesignGroove::activated(int iMsg)
|
||||
{
|
||||
unsigned int n = getSelection().countObjectsOfType(Part::Part2DObject::getClassTypeId());
|
||||
if (n != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select a sketch or 2D object."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Groove");
|
||||
|
||||
std::vector<App::DocumentObject*> Sel = getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
||||
Part::Part2DObject* sketch = static_cast<Part::Part2DObject*>(Sel.front());
|
||||
const TopoDS_Shape& shape = sketch->Shape.getValue();
|
||||
if (shape.IsNull()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("The shape of the selected object is empty."));
|
||||
return;
|
||||
}
|
||||
|
||||
// count free wires
|
||||
int ctWires=0;
|
||||
TopExp_Explorer ex;
|
||||
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
|
||||
ctWires++;
|
||||
}
|
||||
if (ctWires == 0) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("The shape of the selected object is not a wire."));
|
||||
return;
|
||||
}
|
||||
|
||||
App::DocumentObject* support = sketch->Support.getValue();
|
||||
|
||||
openCommand("Make Groove");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Groove\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Sketch = App.activeDocument().%s",FeatName.c_str(),sketch->getNameInDocument());
|
||||
doCommand(Doc,"App.activeDocument().%s.ReferenceAxis = (App.activeDocument().%s,['V_Axis'])",
|
||||
FeatName.c_str(), sketch->getNameInDocument());
|
||||
doCommand(Doc,"App.activeDocument().%s.Angle = 360.0",FeatName.c_str());
|
||||
updateActive();
|
||||
if (isActiveObjectValid()) {
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument());
|
||||
if (support)
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument());
|
||||
}
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
if (support) {
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", support->getNameInDocument());
|
||||
copyVisual(FeatName.c_str(), "LineColor", support->getNameInDocument());
|
||||
copyVisual(FeatName.c_str(), "PointColor", support->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdPartDesignGroove::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
//===========================================================================
|
||||
// PartDesign_Fillet
|
||||
//===========================================================================
|
||||
|
@ -628,6 +704,7 @@ void CreatePartDesignCommands(void)
|
|||
rcCmdMgr.addCommand(new CmdPartDesignPad());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignPocket());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignRevolution());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignGroove());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignFillet());
|
||||
//rcCmdMgr.addCommand(new CmdPartDesignNewSketch());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignChamfer());
|
||||
|
|
287
src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp
Normal file
287
src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp
Normal file
|
@ -0,0 +1,287 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "ui_TaskGrooveParameters.h"
|
||||
#include "TaskGrooveParameters.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Mod/PartDesign/App/FeatureGroove.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
/* TRANSLATOR PartDesignGui::TaskGrooveParameters */
|
||||
|
||||
TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Groove"),tr("Groove parameters"),true, parent),GrooveView(GrooveView)
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
ui = new Ui_TaskGrooveParameters();
|
||||
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)));
|
||||
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onMidplane(bool)));
|
||||
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onReversed(bool)));
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
double l = pcGroove->Angle.getValue();
|
||||
bool mirrored = pcGroove->Midplane.getValue();
|
||||
bool reversed = pcGroove->Reversed.getValue();
|
||||
|
||||
ui->doubleSpinBox->setValue(l);
|
||||
|
||||
int count=pcGroove->getSketchAxisCount();
|
||||
|
||||
for (int i=ui->axis->count()-1; i >= count+2; i--)
|
||||
ui->axis->removeItem(i);
|
||||
for (int i=ui->axis->count(); i < count+2; i++)
|
||||
ui->axis->addItem(QString::fromAscii("Sketch axis %1").arg(i-2));
|
||||
|
||||
int pos=-1;
|
||||
|
||||
App::DocumentObject *pcReferenceAxis = pcGroove->ReferenceAxis.getValue();
|
||||
const std::vector<std::string> &subReferenceAxis = pcGroove->ReferenceAxis.getSubValues();
|
||||
if (pcReferenceAxis && pcReferenceAxis == pcGroove->Sketch.getValue()) {
|
||||
assert(subReferenceAxis.size()==1);
|
||||
if (subReferenceAxis[0] == "V_Axis")
|
||||
pos = 0;
|
||||
else if (subReferenceAxis[0] == "H_Axis")
|
||||
pos = 1;
|
||||
else if (subReferenceAxis[0].size() > 4 && subReferenceAxis[0].substr(0,4) == "Axis")
|
||||
pos = 2 + std::atoi(subReferenceAxis[0].substr(4,4000).c_str());
|
||||
}
|
||||
|
||||
if (pos < 0 || pos >= ui->axis->count()) {
|
||||
ui->axis->addItem(QString::fromAscii("Undefined"));
|
||||
pos = ui->axis->count()-1;
|
||||
}
|
||||
|
||||
ui->axis->setCurrentIndex(pos);
|
||||
|
||||
ui->checkBoxMidplane->setChecked(mirrored);
|
||||
ui->checkBoxReversed->setChecked(reversed);
|
||||
|
||||
setFocus ();
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onAngleChanged(double len)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
pcGroove->Angle.setValue((float)len);
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onAxisChanged(int num)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
|
||||
if (pcSketch) {
|
||||
int maxcount = pcSketch->getAxisCount()+2;
|
||||
if (num == 0)
|
||||
pcGroove->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,"V_Axis"));
|
||||
else if (num == 1)
|
||||
pcGroove->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
else if (num >= 2 && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-2);
|
||||
std::string str = buf.toStdString();
|
||||
pcGroove->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,str));
|
||||
}
|
||||
if (num < maxcount && ui->axis->count() > maxcount)
|
||||
ui->axis->setMaxCount(maxcount);
|
||||
}
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onMidplane(bool on)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
pcGroove->Midplane.setValue(on);
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::onReversed(bool on)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
pcGroove->Reversed.setValue(on);
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
}
|
||||
|
||||
|
||||
double TaskGrooveParameters::getAngle(void) const
|
||||
{
|
||||
return ui->doubleSpinBox->value();
|
||||
}
|
||||
|
||||
QString TaskGrooveParameters::getReferenceAxis(void) const
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
|
||||
|
||||
QString buf;
|
||||
if (pcSketch) {
|
||||
buf = QString::fromUtf8("(App.ActiveDocument.%1,[%2])");
|
||||
buf = buf.arg(QString::fromUtf8(pcSketch->getNameInDocument()));
|
||||
if (ui->axis->currentIndex() == 0)
|
||||
buf = buf.arg(QString::fromUtf8("'V_Axis'"));
|
||||
else if (ui->axis->currentIndex() == 1)
|
||||
buf = buf.arg(QString::fromUtf8("'H_Axis'"));
|
||||
else if (ui->axis->currentIndex() >= 2) {
|
||||
buf = buf.arg(QString::fromUtf8("'Axis%1'"));
|
||||
buf = buf.arg(ui->axis->currentIndex()-2);
|
||||
}
|
||||
}
|
||||
else
|
||||
buf = QString::fromUtf8("''");
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool TaskGrooveParameters::getMidplane(void) const
|
||||
{
|
||||
return ui->checkBoxMidplane->isChecked();
|
||||
}
|
||||
|
||||
bool TaskGrooveParameters::getReversed(void) const
|
||||
{
|
||||
return ui->checkBoxReversed->isChecked();
|
||||
}
|
||||
|
||||
TaskGrooveParameters::~TaskGrooveParameters()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgGrooveParameters::TaskDlgGrooveParameters(ViewProviderGroove *GrooveView)
|
||||
: TaskDialog(),GrooveView(GrooveView)
|
||||
{
|
||||
assert(GrooveView);
|
||||
parameter = new TaskGrooveParameters(GrooveView);
|
||||
|
||||
Content.push_back(parameter);
|
||||
}
|
||||
|
||||
TaskDlgGrooveParameters::~TaskDlgGrooveParameters()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
|
||||
void TaskDlgGrooveParameters::open()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDlgGrooveParameters::clicked(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TaskDlgGrooveParameters::accept()
|
||||
{
|
||||
std::string name = GrooveView->getObject()->getNameInDocument();
|
||||
|
||||
//Gui::Command::openCommand("Groove changed");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),parameter->getAngle());
|
||||
std::string axis = parameter->getReferenceAxis().toStdString();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ReferenceAxis = %s",name.c_str(),axis.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(),parameter->getMidplane()?1:0);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(),parameter->getReversed()?1:0);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgGrooveParameters::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(GrooveView->getObject());
|
||||
Sketcher::SketchObject *pcSketch;
|
||||
App::DocumentObject *pcSupport;
|
||||
if (pcGroove->Sketch.getValue()) {
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->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(pcGroove)) {
|
||||
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_TaskGrooveParameters.cpp"
|
115
src/Mod/PartDesign/Gui/TaskGrooveParameters.h
Normal file
115
src/Mod/PartDesign/Gui/TaskGrooveParameters.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskGrooveParameters_H
|
||||
#define GUI_TASKVIEW_TaskGrooveParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "ViewProviderGroove.h"
|
||||
|
||||
class Ui_TaskGrooveParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
|
||||
class TaskGrooveParameters : public Gui::TaskView::TaskBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidget *parent = 0);
|
||||
~TaskGrooveParameters();
|
||||
|
||||
QString getReferenceAxis(void) const;
|
||||
double getAngle(void) const;
|
||||
bool getMidplane(void) const;
|
||||
bool getReversed(void) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAngleChanged(double);
|
||||
void onAxisChanged(int);
|
||||
void onMidplane(bool);
|
||||
void onReversed(bool);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskGrooveParameters* ui;
|
||||
ViewProviderGroove *GrooveView;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgGrooveParameters : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgGrooveParameters(ViewProviderGroove *GrooveView);
|
||||
~TaskDlgGrooveParameters();
|
||||
|
||||
ViewProviderGroove* getGrooveView() const
|
||||
{ return GrooveView; }
|
||||
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// 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 bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProviderGroove *GrooveView;
|
||||
|
||||
TaskGrooveParameters *parameter;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
|
93
src/Mod/PartDesign/Gui/TaskGrooveParameters.ui
Normal file
93
src/Mod/PartDesign/Gui/TaskGrooveParameters.ui
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PartDesignGui::TaskGrooveParameters</class>
|
||||
<widget class="QWidget" name="PartDesignGui::TaskGrooveParameters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>278</width>
|
||||
<height>158</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<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 sketch axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Horizontal sketch axis</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Angle:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxMidplane">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Symmetric to plane</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxReversed">
|
||||
<property name="text">
|
||||
<string>Reversed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
141
src/Mod/PartDesign/Gui/ViewProviderGroove.cpp
Normal file
141
src/Mod/PartDesign/Gui/ViewProviderGroove.cpp
Normal file
|
@ -0,0 +1,141 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include <Mod/PartDesign/App/FeatureGroove.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include "ViewProviderGroove.h"
|
||||
#include "TaskGrooveParameters.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderGroove,PartDesignGui::ViewProvider)
|
||||
|
||||
ViewProviderGroove::ViewProviderGroove()
|
||||
{
|
||||
}
|
||||
|
||||
ViewProviderGroove::~ViewProviderGroove()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderGroove::claimChildren(void)const
|
||||
{
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
temp.push_back(static_cast<PartDesign::Groove*>(getObject())->Sketch.getValue());
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
void ViewProviderGroove::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit Groove"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderGroove::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// 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();
|
||||
TaskDlgGrooveParameters *padDlg = qobject_cast<TaskDlgGrooveParameters *>(dlg);
|
||||
if (padDlg && padDlg->getGrooveView() != 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 Groove parameters");
|
||||
|
||||
// start the edit dialog
|
||||
if (padDlg)
|
||||
Gui::Control().showDialog(padDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgGrooveParameters(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return PartGui::ViewProviderPart::setEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderGroove::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 ViewProviderGroove::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(getObject());
|
||||
Sketcher::SketchObject *pcSketch;
|
||||
App::DocumentObject *pcSupport;
|
||||
if (pcGroove->Sketch.getValue()){
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->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;
|
||||
}
|
||||
|
||||
|
59
src/Mod/PartDesign/Gui/ViewProviderGroove.h
Normal file
59
src/Mod/PartDesign/Gui/ViewProviderGroove.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PARTGUI_ViewProviderGroove_H
|
||||
#define PARTGUI_ViewProviderGroove_H
|
||||
|
||||
#include "ViewProvider.h"
|
||||
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class PartDesignGuiExport ViewProviderGroove : public ViewProvider
|
||||
{
|
||||
PROPERTY_HEADER(PartGui::ViewProviderGroove);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderGroove();
|
||||
/// destructor
|
||||
virtual ~ViewProviderGroove();
|
||||
|
||||
/// 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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
||||
|
||||
#endif // PARTGUI_ViewProviderGroove_H
|
|
@ -86,6 +86,7 @@ void Workbench::activated()
|
|||
"PartDesign_Pad",
|
||||
"PartDesign_Pocket",
|
||||
"PartDesign_Revolution",
|
||||
"PartDesign_Groove",
|
||||
0};
|
||||
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
||||
"SELECT Sketcher::SketchObject COUNT 1",
|
||||
|
@ -169,6 +170,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
<< "PartDesign_Pad"
|
||||
<< "PartDesign_Pocket"
|
||||
<< "PartDesign_Revolution"
|
||||
<< "PartDesign_Groove"
|
||||
<< "PartDesign_Fillet"
|
||||
<< "PartDesign_Chamfer";
|
||||
|
||||
|
@ -186,6 +188,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
<< "PartDesign_Pad"
|
||||
<< "PartDesign_Pocket"
|
||||
<< "PartDesign_Revolution"
|
||||
<< "PartDesign_Groove"
|
||||
<< "PartDesign_Fillet"
|
||||
<< "PartDesign_Chamfer";
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user