Offset function
This commit is contained in:
parent
271308e56c
commit
3a0067d19a
|
@ -24,6 +24,7 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "TaskDialog.h"
|
||||
|
@ -57,6 +58,20 @@ const std::vector<QWidget*> &TaskDialog::getDialogContent(void) const
|
|||
return Content;
|
||||
}
|
||||
|
||||
bool TaskDialog::canClose() const
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(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)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
void TaskDialog::open()
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
ButtonPosition buttonPosition() const
|
||||
{ return pos; }
|
||||
const std::vector<QWidget*> &getDialogContent(void) const;
|
||||
bool canClose() const;
|
||||
|
||||
/// tells the framework which buttons whisched for the dialog
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
|
|
|
@ -198,6 +198,7 @@ void PartExport initPart()
|
|||
Part::RuledSurface ::init();
|
||||
Part::Loft ::init();
|
||||
Part::Sweep ::init();
|
||||
Part::Offset ::init();
|
||||
|
||||
// Geometry types
|
||||
Part::Geometry ::init();
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
# include <BRepBuilderAPI_MakeWire.hxx>
|
||||
# include <BRepOffsetAPI_MakePipeShell.hxx>
|
||||
# include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
# include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -334,3 +335,67 @@ App::DocumentObjectExecReturn *Sweep::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const char* Part::Offset::ModeEnums[]= {"Skin","Pipe", "RectoVerso",NULL};
|
||||
const char* Part::Offset::JoinEnums[]= {"Arc","Tangent", "Intersection",NULL};
|
||||
|
||||
PROPERTY_SOURCE(Part::Offset, Part::Feature)
|
||||
|
||||
Offset::Offset()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Source,(0),"Offset",App::Prop_None,"Source shape");
|
||||
ADD_PROPERTY_TYPE(Value,(1.0),"Offset",App::Prop_None,"Offset value");
|
||||
ADD_PROPERTY_TYPE(Mode,(long(0)),"Offset",App::Prop_None,"Mode");
|
||||
Mode.setEnums(ModeEnums);
|
||||
ADD_PROPERTY_TYPE(Join,(long(0)),"Offset",App::Prop_None,"Join type");
|
||||
Join.setEnums(JoinEnums);
|
||||
ADD_PROPERTY_TYPE(Intersection,(false),"Offset",App::Prop_None,"Intersection");
|
||||
ADD_PROPERTY_TYPE(SelfIntersection,(false),"Offset",App::Prop_None,"Self Intersection");
|
||||
ADD_PROPERTY_TYPE(Fill,(false),"Offset",App::Prop_None,"Fill offset");
|
||||
}
|
||||
|
||||
short Offset::mustExecute() const
|
||||
{
|
||||
if (Source.isTouched())
|
||||
return 1;
|
||||
if (Value.isTouched())
|
||||
return 1;
|
||||
if (Mode.isTouched())
|
||||
return 1;
|
||||
if (Join.isTouched())
|
||||
return 1;
|
||||
if (Intersection.isTouched())
|
||||
return 1;
|
||||
if (SelfIntersection.isTouched())
|
||||
return 1;
|
||||
if (Fill.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Offset::onChanged(const App::Property* prop)
|
||||
{
|
||||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Offset::execute(void)
|
||||
{
|
||||
App::DocumentObject* source = Source.getValue();
|
||||
if (!(source && source->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
|
||||
return new App::DocumentObjectExecReturn("No source shape linked.");
|
||||
double offset = Value.getValue();
|
||||
double tol = Precision::Confusion();
|
||||
bool inter = Intersection.getValue();
|
||||
bool self = SelfIntersection.getValue();
|
||||
short mode = (short)Mode.getValue();
|
||||
short join = (short)Join.getValue();
|
||||
bool fill = Fill.getValue();
|
||||
const TopoShape& shape = static_cast<Part::Feature*>(source)->Shape.getShape();
|
||||
if (fabs(offset) > 2*tol)
|
||||
this->Shape.setValue(shape.makeOffsetShape(offset, tol, inter, self, mode, join, fill));
|
||||
else
|
||||
this->Shape.setValue(shape);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define PART_FEATURES_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
namespace Part
|
||||
|
@ -106,6 +107,39 @@ private:
|
|||
static const char* TransitionEnums[];
|
||||
};
|
||||
|
||||
class Offset : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Part::Offset);
|
||||
|
||||
public:
|
||||
Offset();
|
||||
|
||||
App::PropertyLink Source;
|
||||
App::PropertyFloat Value;
|
||||
App::PropertyEnumeration Mode;
|
||||
App::PropertyEnumeration Join;
|
||||
App::PropertyBool Intersection;
|
||||
App::PropertyBool SelfIntersection;
|
||||
App::PropertyBool Fill;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartGui::ViewProviderOffset";
|
||||
}
|
||||
//@}
|
||||
|
||||
protected:
|
||||
void onChanged (const App::Property* prop);
|
||||
|
||||
private:
|
||||
static const char* ModeEnums[];
|
||||
static const char* JoinEnums[];
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ void PartGuiExport initPartGui()
|
|||
PartGui::ViewProviderRevolution ::init();
|
||||
PartGui::ViewProviderLoft ::init();
|
||||
PartGui::ViewProviderSweep ::init();
|
||||
PartGui::ViewProviderOffset ::init();
|
||||
PartGui::ViewProviderCustom ::init();
|
||||
PartGui::ViewProviderCustomPython ::init();
|
||||
PartGui::ViewProviderBoolean ::init();
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#include "TaskShapeBuilder.h"
|
||||
#include "TaskLoft.h"
|
||||
#include "TaskSweep.h"
|
||||
#include "TaskOffset.h"
|
||||
#include "TaskCheckGeometry.h"
|
||||
|
||||
|
||||
|
@ -1007,7 +1006,24 @@ CmdPartOffset::CmdPartOffset()
|
|||
|
||||
void CmdPartOffset::activated(int iMsg)
|
||||
{
|
||||
Gui::Control().showDialog(new PartGui::TaskOffset());
|
||||
App::DocumentObject* shape = getSelection().getObjectsOfType(Part::Feature::getClassTypeId()).front();
|
||||
std::string offset = getUniqueObjectName("Offset");
|
||||
|
||||
openCommand("Make Offset");
|
||||
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Offset\",\"%s\")",offset.c_str());
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Source = App.ActiveDocument.%s" ,offset.c_str(), shape->getNameInDocument());
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Value = 1.0",offset.c_str());
|
||||
updateActive();
|
||||
//if (isActiveObjectValid())
|
||||
// doCommand(Gui,"Gui.ActiveDocument.hide(\"%s\")",shape->getNameInDocument());
|
||||
doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",offset.c_str());
|
||||
|
||||
//commitCommand();
|
||||
adjustCameraPosition();
|
||||
|
||||
copyVisual(offset.c_str(), "ShapeColor", shape->getNameInDocument());
|
||||
copyVisual(offset.c_str(), "LineColor" , shape->getNameInDocument());
|
||||
copyVisual(offset.c_str(), "PointColor", shape->getNameInDocument());
|
||||
}
|
||||
|
||||
bool CmdPartOffset::isActive(void)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<file>icons/Part_Loft.svg</file>
|
||||
<file>icons/Part_Mirror.svg</file>
|
||||
<file>icons/Part_MirrorPNG.png</file>
|
||||
<file>icons/Part_Offset.svg</file>
|
||||
<file>icons/Part_Revolve.svg</file>
|
||||
<file>icons/Part_RuledSurface.svg</file>
|
||||
<file>icons/Part_Section.svg</file>
|
||||
|
|
185
src/Mod/Part/Gui/Resources/icons/Part_Offset.svg
Normal file
185
src/Mod/Part/Gui/Resources/icons/Part_Offset.svg
Normal file
|
@ -0,0 +1,185 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="64px"
|
||||
height="64px"
|
||||
id="svg2682"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.48.0 r9654"
|
||||
sodipodi:docname="Part_Offset.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
version="1.1">
|
||||
<defs
|
||||
id="defs2684">
|
||||
<linearGradient
|
||||
id="linearGradient3593">
|
||||
<stop
|
||||
style="stop-color:#c8e0f9;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3595" />
|
||||
<stop
|
||||
style="stop-color:#637dca;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3597" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3593"
|
||||
id="radialGradient3354"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cx="330.63791"
|
||||
cy="39.962704"
|
||||
fx="330.63791"
|
||||
fy="39.962704"
|
||||
r="19.571428"
|
||||
gradientTransform="matrix(0.9327663,0,0,0.9327663,-298.15651,8.1913381)" />
|
||||
<linearGradient
|
||||
id="linearGradient3864">
|
||||
<stop
|
||||
id="stop3866"
|
||||
offset="0"
|
||||
style="stop-color:#71b2f8;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3868"
|
||||
offset="1"
|
||||
style="stop-color:#002795;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 32 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="64 : 32 : 1"
|
||||
inkscape:persp3d-origin="32 : 21.333333 : 1"
|
||||
id="perspective2690" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3864"
|
||||
id="radialGradient2401"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.959337,0.05179994,0,0.7352325,-29.610908,-1.231413)"
|
||||
cx="51.105499"
|
||||
cy="23.807407"
|
||||
fx="51.105499"
|
||||
fy="23.807407"
|
||||
r="19.571428" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3864"
|
||||
id="radialGradient2404"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(2.2993671,-1.5757258e-2,8.4161044e-3,0.9850979,-94.354208,-10.998387)"
|
||||
cx="48.288067"
|
||||
cy="46.74614"
|
||||
fx="48.288067"
|
||||
fy="46.74614"
|
||||
r="19.571428" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3593"
|
||||
id="radialGradient3377"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.9327663,0,0,0.9327663,-267.16323,12.515981)"
|
||||
cx="317.68173"
|
||||
cy="35.227276"
|
||||
fx="317.68173"
|
||||
fy="35.227276"
|
||||
r="19.571428" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3864-7"
|
||||
id="radialGradient2404-1"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(2.2993671,-0.01575726,0.0084161,0.9850979,-94.354208,-10.998387)"
|
||||
cx="48.288067"
|
||||
cy="46.74614"
|
||||
fx="48.288067"
|
||||
fy="46.74614"
|
||||
r="19.571428" />
|
||||
<linearGradient
|
||||
id="linearGradient3864-7">
|
||||
<stop
|
||||
id="stop3866-4"
|
||||
offset="0"
|
||||
style="stop-color:#71b2f8;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3868-0"
|
||||
offset="1"
|
||||
style="stop-color:#002795;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
r="19.571428"
|
||||
fy="46.74614"
|
||||
fx="48.288067"
|
||||
cy="46.74614"
|
||||
cx="48.288067"
|
||||
gradientTransform="matrix(2.2993671,-0.01575726,0.0084161,0.9850979,-94.867845,6.893181)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="radialGradient3014"
|
||||
xlink:href="#linearGradient3864-7"
|
||||
inkscape:collect="always" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.75"
|
||||
inkscape:cx="61.342448"
|
||||
inkscape:cy="37.42735"
|
||||
inkscape:current-layer="g3381"
|
||||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:window-width="1280"
|
||||
inkscape:window-height="758"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="19"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata2687">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<g
|
||||
id="g3381">
|
||||
<path
|
||||
sodipodi:nodetypes="ccccc"
|
||||
id="rect3633"
|
||||
d="M 23.530174,28.496274 L 55.6968,30.8755 L 36.406189,40.084227 L 4.2395647,37.705001 L 23.530174,28.496274 z"
|
||||
style="fill:url(#radialGradient2404);fill-opacity:1;fill-rule:evenodd;stroke:#000137;stroke-width:2.2;stroke-linecap:butt;stroke-linejoin:bevel;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
<path
|
||||
id="rect3638"
|
||||
d="m 28.577651,5.423645 -15.10716,13.814131 10.450664,0.564291 0,14.041034 10.794612,0.58286 0,-14.041035 8.969043,0.484289 -15.107159,-15.44557 z"
|
||||
style="fill:url(#radialGradient2401);fill-opacity:1;fill-rule:evenodd;stroke:#000137;stroke-width:2.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
sodipodi:nodetypes="cccccccc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
id="rect3633-9"
|
||||
d="M 23.016537,46.387842 55.183163,48.767068 35.892552,57.975795 3.725928,55.596569 23.016537,46.387842 z"
|
||||
style="fill:url(#radialGradient3014);fill-opacity:1;fill-rule:evenodd;stroke:#000137;stroke-width:2.20000005;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.7 KiB |
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
|
@ -43,7 +44,7 @@
|
|||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/PartFeatures.h>
|
||||
|
||||
|
||||
using namespace PartGui;
|
||||
|
@ -52,7 +53,7 @@ class OffsetWidget::Private
|
|||
{
|
||||
public:
|
||||
Ui_TaskOffset ui;
|
||||
std::string document;
|
||||
Part::Offset* offset;
|
||||
Private()
|
||||
{
|
||||
}
|
||||
|
@ -63,13 +64,17 @@ public:
|
|||
|
||||
/* TRANSLATOR PartGui::OffsetWidget */
|
||||
|
||||
OffsetWidget::OffsetWidget(QWidget* parent)
|
||||
OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
|
||||
d->offset = offset;
|
||||
d->ui.setupUi(this);
|
||||
d->ui.spinOffset->setValue(d->offset->Value.getValue());
|
||||
d->ui.spinOffset->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.spinOffset->setSingleStep(0.1);
|
||||
}
|
||||
|
||||
OffsetWidget::~OffsetWidget()
|
||||
|
@ -77,13 +82,102 @@ OffsetWidget::~OffsetWidget()
|
|||
delete d;
|
||||
}
|
||||
|
||||
Part::Offset* OffsetWidget::getObject() const
|
||||
{
|
||||
return d->offset;
|
||||
}
|
||||
|
||||
void OffsetWidget::on_spinOffset_valueChanged(double val)
|
||||
{
|
||||
d->offset->Value.setValue((float)val);
|
||||
if (d->ui.updateView->isChecked())
|
||||
d->offset->getDocument()->recomputeFeature(d->offset);
|
||||
}
|
||||
|
||||
void OffsetWidget::on_modeType_activated(int val)
|
||||
{
|
||||
d->offset->Mode.setValue(val);
|
||||
if (d->ui.updateView->isChecked())
|
||||
d->offset->getDocument()->recomputeFeature(d->offset);
|
||||
}
|
||||
|
||||
void OffsetWidget::on_joinType_activated(int val)
|
||||
{
|
||||
d->offset->Join.setValue((float)val);
|
||||
if (d->ui.updateView->isChecked())
|
||||
d->offset->getDocument()->recomputeFeature(d->offset);
|
||||
}
|
||||
|
||||
void OffsetWidget::on_intersection_toggled(bool on)
|
||||
{
|
||||
d->offset->Intersection.setValue(on);
|
||||
if (d->ui.updateView->isChecked())
|
||||
d->offset->getDocument()->recomputeFeature(d->offset);
|
||||
}
|
||||
|
||||
void OffsetWidget::on_selfIntersection_toggled(bool on)
|
||||
{
|
||||
d->offset->SelfIntersection.setValue(on);
|
||||
if (d->ui.updateView->isChecked())
|
||||
d->offset->getDocument()->recomputeFeature(d->offset);
|
||||
}
|
||||
|
||||
void OffsetWidget::on_fillOffset_toggled(bool on)
|
||||
{
|
||||
d->offset->Fill.setValue(on);
|
||||
if (d->ui.updateView->isChecked())
|
||||
d->offset->getDocument()->recomputeFeature(d->offset);
|
||||
}
|
||||
|
||||
void OffsetWidget::on_updateView_toggled(bool on)
|
||||
{
|
||||
if (on) {
|
||||
d->offset->getDocument()->recomputeFeature(d->offset);
|
||||
}
|
||||
}
|
||||
|
||||
bool OffsetWidget::accept()
|
||||
{
|
||||
std::string name = d->offset->getNameInDocument();
|
||||
|
||||
try {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Value = %f",
|
||||
name.c_str(),d->ui.spinOffset->value());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Mode = %i",
|
||||
name.c_str(),d->ui.modeType->currentIndex());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Join = %i",
|
||||
name.c_str(),d->ui.joinType->currentIndex());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Intersection = %s",
|
||||
name.c_str(),d->ui.intersection->isChecked() ? "True" : "False");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.SelfIntersection = %s",
|
||||
name.c_str(),d->ui.selfIntersection->isChecked() ? "True" : "False");
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
if (!d->offset->isValid())
|
||||
throw Base::Exception(d->offset->getStatusString());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(this, tr("Input error"), QString::fromAscii(e.what()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OffsetWidget::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
App::DocumentObject* source = d->offset->Source.getValue();
|
||||
if (source){
|
||||
Gui::Application::Instance->getViewProvider(source)->show();
|
||||
}
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -98,9 +192,9 @@ void OffsetWidget::changeEvent(QEvent *e)
|
|||
|
||||
/* TRANSLATOR PartGui::TaskOffset */
|
||||
|
||||
TaskOffset::TaskOffset()
|
||||
TaskOffset::TaskOffset(Part::Offset* offset)
|
||||
{
|
||||
widget = new OffsetWidget();
|
||||
widget = new OffsetWidget(offset);
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
Gui::BitmapFactory().pixmap("Part_Offset"),
|
||||
widget->windowTitle(), true, 0);
|
||||
|
@ -112,6 +206,11 @@ TaskOffset::~TaskOffset()
|
|||
{
|
||||
}
|
||||
|
||||
Part::Offset* TaskOffset::getObject() const
|
||||
{
|
||||
return widget->getObject();
|
||||
}
|
||||
|
||||
void TaskOffset::open()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
namespace Part { class Offset; }
|
||||
namespace PartGui {
|
||||
|
||||
class OffsetWidget : public QWidget
|
||||
|
@ -34,11 +35,21 @@ class OffsetWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OffsetWidget(QWidget* parent = 0);
|
||||
OffsetWidget(Part::Offset*, QWidget* parent = 0);
|
||||
~OffsetWidget();
|
||||
|
||||
bool accept();
|
||||
bool reject();
|
||||
Part::Offset* getObject() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_spinOffset_valueChanged(double);
|
||||
void on_modeType_activated(int);
|
||||
void on_joinType_activated(int);
|
||||
void on_intersection_toggled(bool);
|
||||
void on_selfIntersection_toggled(bool);
|
||||
void on_fillOffset_toggled(bool);
|
||||
void on_updateView_toggled(bool);
|
||||
|
||||
private:
|
||||
void changeEvent(QEvent *e);
|
||||
|
@ -53,7 +64,7 @@ class TaskOffset : public Gui::TaskView::TaskDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskOffset();
|
||||
TaskOffset(Part::Offset*);
|
||||
~TaskOffset();
|
||||
|
||||
public:
|
||||
|
@ -61,6 +72,7 @@ public:
|
|||
bool accept();
|
||||
bool reject();
|
||||
void clicked(int);
|
||||
Part::Offset* getObject() const;
|
||||
|
||||
QDialogButtonBox::StandardButtons getStandardButtons() const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>256</width>
|
||||
<height>217</height>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -25,24 +25,14 @@
|
|||
<widget class="QDoubleSpinBox" name="spinOffset"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Tolerance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinTolerance"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="modeType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Skin</string>
|
||||
|
@ -60,15 +50,15 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Join type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBox_2">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="joinType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Arc</string>
|
||||
|
@ -86,29 +76,52 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="intersection">
|
||||
<property name="text">
|
||||
<string>Intersection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="selfIntersection">
|
||||
<property name="text">
|
||||
<string>Self-intersection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="updateView">
|
||||
<property name="text">
|
||||
<string>Update view</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="fillOffset">
|
||||
<property name="text">
|
||||
<string>Fill offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>spinOffset</tabstop>
|
||||
<tabstop>spinTolerance</tabstop>
|
||||
<tabstop>comboBox</tabstop>
|
||||
<tabstop>comboBox_2</tabstop>
|
||||
<tabstop>checkBox</tabstop>
|
||||
<tabstop>checkBox_2</tabstop>
|
||||
<tabstop>modeType</tabstop>
|
||||
<tabstop>joinType</tabstop>
|
||||
<tabstop>intersection</tabstop>
|
||||
<tabstop>selfIntersection</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <Gui/Document.h>
|
||||
#include "ViewProviderMirror.h"
|
||||
#include "DlgFilletEdges.h"
|
||||
#include "TaskOffset.h"
|
||||
|
||||
using namespace PartGui;
|
||||
|
||||
|
@ -395,3 +396,84 @@ bool ViewProviderSweep::onDelete(const std::vector<std::string> &)
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
PROPERTY_SOURCE(PartGui::ViewProviderOffset, PartGui::ViewProviderPart)
|
||||
|
||||
ViewProviderOffset::ViewProviderOffset()
|
||||
{
|
||||
sPixmap = "Part_Offset";
|
||||
}
|
||||
|
||||
ViewProviderOffset::~ViewProviderOffset()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderOffset::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit offset"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderOffset::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskOffset* offsetDlg = qobject_cast<TaskOffset*>(dlg);
|
||||
if (offsetDlg && offsetDlg->getObject() != this->getObject())
|
||||
offsetDlg = 0; // another pad left open its task panel
|
||||
if (dlg && !offsetDlg) {
|
||||
if (dlg->canClose())
|
||||
Gui::Control().closeDialog();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
// start the edit dialog
|
||||
if (offsetDlg)
|
||||
Gui::Control().showDialog(offsetDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskOffset(static_cast<Part::Offset*>(getObject())));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return ViewProviderPart::setEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderOffset::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderOffset::claimChildren() const
|
||||
{
|
||||
std::vector<App::DocumentObject*> child;
|
||||
child.push_back(static_cast<Part::Offset*>(getObject())->Source.getValue());
|
||||
return child;
|
||||
}
|
||||
|
||||
bool ViewProviderOffset::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// get the support and Sketch
|
||||
Part::Offset* offset = static_cast<Part::Offset*>(getObject());
|
||||
App::DocumentObject* source = offset->Source.getValue();
|
||||
if (source){
|
||||
Gui::Application::Instance->getViewProvider(source)->show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -138,6 +138,26 @@ public:
|
|||
bool onDelete(const std::vector<std::string> &);
|
||||
};
|
||||
|
||||
class ViewProviderOffset : public ViewProviderPart
|
||||
{
|
||||
PROPERTY_HEADER(PartGui::ViewProviderOffset);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderOffset();
|
||||
/// destructor
|
||||
virtual ~ViewProviderOffset();
|
||||
|
||||
/// grouping handling
|
||||
std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
Gui::ToolBarItem* tool = new Gui::ToolBarItem(root);
|
||||
tool->setCommand("Part tools");
|
||||
*tool << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet"
|
||||
<< "Part_Chamfer" << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep";
|
||||
<< "Part_Chamfer" << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep"
|
||||
<< "Part_Offset";
|
||||
|
||||
Gui::ToolBarItem* boolop = new Gui::ToolBarItem(root);
|
||||
boolop->setCommand("Boolean");
|
||||
|
|
Loading…
Reference in New Issue
Block a user