add basic part design pipe infrastructure

This commit is contained in:
Stefan Tröger 2015-05-27 08:08:26 +02:00
parent 0f30096cec
commit e7803eca61
16 changed files with 1328 additions and 4 deletions

View File

@ -54,6 +54,7 @@
#include "FeaturePrimitive.h"
#include "DatumCS.h"
#include "FeatureThickness.h"
#include "FeaturePipe.h"
namespace PartDesign {
extern PyObject* initModule();
@ -101,6 +102,9 @@ PyMODINIT_FUNC init_PartDesign()
PartDesign::Chamfer ::init();
PartDesign::Draft ::init();
PartDesign::Thickness ::init();
PartDesign::Pipe ::init();
PartDesign::AdditivePipe ::init();
PartDesign::SubtractivePipe ::init();
PartDesign::Plane ::init();
PartDesign::Line ::init();
PartDesign::Point ::init();

View File

@ -100,6 +100,8 @@ SET(FeaturesSketchBased_SRCS
FeatureBoolean.cpp
FeaturePrimitive.h
FeaturePrimitive.cpp
FeaturePipe.h
FeaturePipe.cpp
)
SOURCE_GROUP("SketchBasedFeatures" FILES ${FeaturesSketchBased_SRCS})

View File

@ -0,0 +1,104 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.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 <BRep_Tool.hxx>
# include <BRepBndLib.hxx>
# include <BRepFeat_MakePrism.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
# include <Handle_Geom_Surface.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Solid.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS_Wire.hxx>
# include <TopExp_Explorer.hxx>
# include <BRepAlgoAPI_Fuse.hxx>
# include <Precision.hxx>
# include <BRepPrimAPI_MakeHalfSpace.hxx>
# include <BRepAlgoAPI_Common.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <gp_Pln.hxx>
# include <GeomAPI_ProjectPointOnSurf.hxx>
#endif
#include <Base/Exception.h>
#include <Base/Placement.h>
#include <Base/Console.h>
#include <Base/Reader.h>
#include <App/Document.h>
//#include "Body.h"
#include "FeaturePipe.h"
using namespace PartDesign;
const char* Pipe::TypeEnums[] = {"FullPath","UpToFace",NULL};
const char* Pipe::TransitionEnums[] = {"Transformed","Right corner", "Round corner",NULL};
const char* Pipe::ModeEnums[] = {"Standart", "Fixed", "Binormal", "Frenet", NULL};
PROPERTY_SOURCE(PartDesign::Pipe, PartDesign::SketchBased)
Pipe::Pipe()
{
ADD_PROPERTY_TYPE(Sections,(0),"Sweep",App::Prop_None,"List of sections");
Sections.setSize(0);
ADD_PROPERTY_TYPE(Spine,(0,0),"Sweep",App::Prop_None,"Path to sweep along");
ADD_PROPERTY_TYPE(Mode,(long(1)),"Sweep",App::Prop_None,"Profile mode");
ADD_PROPERTY_TYPE(Transition,(long(1)),"Sweep",App::Prop_None,"Transition mode");
Transition.setEnums(TransitionEnums);
}
short Pipe::mustExecute() const
{
if (Sections.isTouched())
return 1;
if (Spine.isTouched())
return 1;
if (Mode.isTouched())
return 1;
if (Transition.isTouched())
return 1;
return SketchBased::mustExecute();
}
App::DocumentObjectExecReturn *Pipe::execute(void)
{
return SketchBased::execute();
}
PROPERTY_SOURCE(PartDesign::AdditivePipe, PartDesign::Pipe)
AdditivePipe::AdditivePipe() {
addSubType = Additive;
}
PROPERTY_SOURCE(PartDesign::SubtractivePipe, PartDesign::Pipe)
SubtractivePipe::SubtractivePipe() {
addSubType = Subtractive;
}

View File

@ -0,0 +1,76 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.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_Pipe_H
#define PARTDESIGN_Pipe_H
#include <App/PropertyStandard.h>
#include "FeatureSketchBased.h"
namespace PartDesign
{
class PartDesignExport Pipe : public SketchBased
{
PROPERTY_HEADER(PartDesign::Pad);
public:
Pipe();
App::PropertyLinkList Sections;
App::PropertyLinkSubList Spine;
App::PropertyEnumeration Mode;
App::PropertyEnumeration Transition;
App::DocumentObjectExecReturn *execute(void);
short mustExecute() const;
/// returns the type name of the view provider
const char* getViewProviderName(void) const {
return "PartDesignGui::ViewProviderPipe";
}
//@}
private:
static const char* TypeEnums[];
static const char* TransitionEnums[];
static const char* ModeEnums[];
};
class PartDesignExport AdditivePipe : public Pipe {
PROPERTY_HEADER(PartDesign::AdditivePipe);
public:
AdditivePipe();
};
class PartDesignExport SubtractivePipe : public Pipe {
PROPERTY_HEADER(PartDesign::SubtractivePipe);
public:
SubtractivePipe();
};
} //namespace PartDesign
#endif // PART_Pad_H

View File

@ -57,6 +57,7 @@
#include "ViewProviderPrimitive.h"
#include "ViewProviderDatumCS.h"
#include "ViewProviderThickness.h"
#include "ViewProviderPipe.h"
// use a different name to CreateCommand()
void CreatePartDesignCommands(void);
@ -140,6 +141,7 @@ PyMODINIT_FUNC initPartDesignGui()
PartDesignGui::ViewProviderDatumCoordinateSystem::init();
PartDesignGui::ViewProviderBoolean ::init();
PartDesignGui::ViewProviderPrimitive ::init();
PartDesignGui::ViewProviderPipe ::init();
// add resources and reloads the translators
loadPartDesignResource();

View File

@ -50,6 +50,7 @@ set(PartDesignGui_MOC_HDRS
TaskDatumParameters.h
TaskBooleanParameters.h
TaskPrimitiveParameters.h
TaskPipeParameters.h
)
fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS})
SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS})
@ -76,6 +77,7 @@ set(PartDesignGui_UIC_SRCS
TaskMultiTransformParameters.ui
TaskDatumParameters.ui
TaskPrimitiveParameters.ui
TaskPipeParameters.ui
)
qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS})
@ -130,6 +132,8 @@ SET(PartDesignGuiViewProvider_SRCS CommandPrimitive.cpp
ViewProviderBoolean.h
ViewProviderPrimitive.h
ViewProviderPrimitive.cpp
ViewProviderPipe.h
ViewProviderPipe.cpp
)
SOURCE_GROUP("ViewProvider" FILES ${PartDesignGuiViewProvider_SRCS})
@ -198,6 +202,9 @@ SET(PartDesignGuiTaskDlgs_SRCS
TaskBooleanParameters.h
TaskPrimitiveParameters.h
TaskPrimitiveParameters.cpp
TaskPipeParameters.ui
TaskPipeParameters.h
TaskPipeParameters.cpp
)
SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS})

View File

@ -1284,6 +1284,101 @@ bool CmdPartDesignGroove::isActive(void)
return hasActiveDocument();
}
//===========================================================================
// PartDesign_Additive_Pipe
//===========================================================================
DEF_STD_CMD_A(CmdPartDesignAdditivePipe);
CmdPartDesignAdditivePipe::CmdPartDesignAdditivePipe()
: Command("PartDesign_AdditivePipe")
{
sAppModule = "PartDesign";
sGroup = QT_TR_NOOP("PartDesign");
sMenuText = QT_TR_NOOP("Additive pipe");
sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a path or to other profiles");
sWhatsThis = "PartDesign_Additive_Pipe";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Additive_Pipe";
}
void CmdPartDesignAdditivePipe::activated(int iMsg)
{
Gui::Command* cmd = this;
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
if (FeatName.empty()) return;
// specific parameters for Pad
//Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
App::DocumentObjectGroup* grp = sketch->getGroup();
if (grp) {
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
Gui::Command::doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
,grp->getNameInDocument(),sketch->getNameInDocument());
}
Gui::Command::updateActive();
finishSketchBased(cmd, sketch, FeatName);
//adjustCameraPosition();
};
prepareSketchBased(this, "AdditivePipe", worker);
}
bool CmdPartDesignAdditivePipe::isActive(void)
{
return hasActiveDocument();
}
//===========================================================================
// PartDesign_Subtractive_Pipe
//===========================================================================
DEF_STD_CMD_A(CmdPartDesignSubtractivePipe);
CmdPartDesignSubtractivePipe::CmdPartDesignSubtractivePipe()
: Command("PartDesign_SubtractivePipe")
{
sAppModule = "PartDesign";
sGroup = QT_TR_NOOP("PartDesign");
sMenuText = QT_TR_NOOP("Subtractive pipe");
sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a path or to other profiles and remove it from the body");
sWhatsThis = "PartDesign_Subtractive_Pipe";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Subtractive_Pipe";
}
void CmdPartDesignSubtractivePipe::activated(int iMsg)
{
Gui::Command* cmd = this;
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
if (FeatName.empty()) return;
// specific parameters for Pad
//Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
App::DocumentObjectGroup* grp = sketch->getGroup();
if (grp) {
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
Gui::Command::doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
,grp->getNameInDocument(),sketch->getNameInDocument());
}
Gui::Command::updateActive();
finishSketchBased(cmd, sketch, FeatName);
//adjustCameraPosition();
};
prepareSketchBased(this, "SubtractivePipe", worker);
}
bool CmdPartDesignSubtractivePipe::isActive(void)
{
return hasActiveDocument();
}
//===========================================================================
// Common utility functions for Dressup features
//===========================================================================
@ -2091,4 +2186,6 @@ void CreatePartDesignCommands(void)
rcCmdMgr.addCommand(new CmdPartDesignMultiTransform());
rcCmdMgr.addCommand(new CmdPartDesignBoolean());
rcCmdMgr.addCommand(new CmdPartDesignAdditivePipe);
rcCmdMgr.addCommand(new CmdPartDesignSubtractivePipe);
}

View File

@ -26,8 +26,9 @@
<file>icons/PartDesign_InternalExternalGear.svg</file>
<file>icons/PartDesign_InvoluteGear.svg</file>
<file>icons/PartDesignWorkbench.svg</file>
<file>icons/PartDesign_Body_Create_New.svg</file>
<file>icons/PartDesign_Body_Create_New.svg</file>
<file>icons/PartDesign_Body_Tree.svg</file>
<file>icons/PartDesign_Additive_Pipe.svg</file>
<file>icons/PartDesign_Additive_Box.svg</file>
<file>icons/PartDesign_Additive_Cylinder.svg</file>
<file>icons/PartDesign_Additive_Sphere.svg</file>

View File

@ -3,6 +3,7 @@
<file>icons/PartDesign_Chamfer.svg</file>
<file>icons/PartDesign_Fillet.svg</file>
<file>icons/PartDesign_Draft.svg</file>
<file>icons/PartDesign_Thickness.svg</file>
<file>icons/PartDesign_Groove.svg</file>
<file>icons/PartDesign_Pad.svg</file>
<file>icons/PartDesign_Pocket.svg</file>
@ -18,16 +19,36 @@
<file>icons/PartDesign_Plane.svg</file>
<file>icons/PartDesign_Line.svg</file>
<file>icons/PartDesign_Point.svg</file>
<file>icons/PartDesign_CoordinateSystem.svg</file>
<file>icons/PartDesign_MoveTip.svg</file>
<file>icons/Tree_PartDesign_Pad.svg</file>
<file>icons/Tree_PartDesign_Revolution.svg</file>
<file>icons/PartDesign_InternalExternalGear.svg</file>
<file>icons/PartDesign_InvoluteGear.svg</file>
<<<<<<< bca167ff77a62818ebcd8c2d7030915aa2c9d282
<<<<<<< a6cae97ea944460d610fe5b54eee2890a927dc00
<file>icons/PartDesignWorkbench.svg</file>
=======
<file>icons/PartDesign_Body_Create_New.svg</file>
=======
<file>icons/PartDesign_Body_Create_New.svg</file>
>>>>>>> add basic part design pipe infrastructure
<file>icons/PartDesign_Body_Tree.svg</file>
>>>>>>> Add new icons to Assembly work bench
<file>icons/PartDesign_Additive_Pipe.svg</file>
<file>icons/PartDesign_Additive_Box.svg</file>
<file>icons/PartDesign_Additive_Cylinder.svg</file>
<file>icons/PartDesign_Additive_Sphere.svg</file>
<file>icons/PartDesign_Additive_Cone.svg</file>
<file>icons/PartDesign_Additive_Torus.svg</file>
<file>icons/PartDesign_Additive_Ellipsoid.svg</file>
<file>icons/PartDesign_Additive_Prism.svg</file>
<file>icons/PartDesign_Additive_Wedge.svg</file>
<file>icons/PartDesign_Subtractive_Box.svg</file>
<file>icons/PartDesign_Subtractive_Cylinder.svg</file>
<file>icons/PartDesign_Subtractive_Sphere.svg</file>
<file>icons/PartDesign_Subtractive_Cone.svg</file>
<file>icons/PartDesign_Subtractive_Torus.svg</file>
<file>icons/PartDesign_Subtractive_Ellipsoid.svg</file>
<file>icons/PartDesign_Subtractive_Prism.svg</file>
<file>icons/PartDesign_Subtractive_Wedge.svg</file>
<file>translations/PartDesign_af.qm</file>
<file>translations/PartDesign_de.qm</file>
<file>translations/PartDesign_fi.qm</file>

View File

@ -0,0 +1,256 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
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="svg3364"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
sodipodi:docname="PartDesign_Additive_Pipe.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs3366">
<linearGradient
osb:paint="gradient"
id="linearGradient4178">
<stop
style="stop-color:#d3cc00;stop-opacity:0.44313726"
offset="0"
id="stop4180" />
<stop
style="stop-color:#ffef00;stop-opacity:1"
offset="1"
id="stop4182" />
</linearGradient>
<linearGradient
id="linearGradient4166">
<stop
style="stop-color:#7a6600;stop-opacity:1"
offset="0"
id="stop4168" />
<stop
style="stop-color:#ffe400;stop-opacity:1"
offset="1"
id="stop4170" />
</linearGradient>
<linearGradient
id="linearGradient4513"
osb:paint="solid">
<stop
style="stop-color:#ff0900;stop-opacity:1;"
offset="0"
id="stop4515" />
</linearGradient>
<marker
inkscape:stockid="Arrow2Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Lstart"
style="overflow:visible">
<path
id="path3909"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(1.1) translate(1,0)" />
</marker>
<linearGradient
id="linearGradient3864"
osb:paint="gradient">
<stop
id="stop3866"
offset="0"
style="stop-color:#71b2f8;stop-opacity:0.44347826;" />
<stop
id="stop3868"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="radialGradient2571"
gradientUnits="userSpaceOnUse"
cx="342.58258"
cy="27.256668"
fx="342.58258"
fy="27.256668"
r="19.571428"
gradientTransform="matrix(1.6258409,0.5434973,-8.8819886e-2,0.2656996,-215.02413,-170.90186)" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3593"
id="radialGradient3352"
gradientUnits="userSpaceOnUse"
cx="345.28433"
cy="15.560534"
fx="345.28433"
fy="15.560534"
r="19.571428"
gradientTransform="translate(-0.1767767,-2.6516504)" />
<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="translate(-0.1767767,-2.6516504)" />
<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="perspective3372" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="radialGradient3369"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.6258409,0.5434973,-8.8819886e-2,0.2656996,-461.81066,-173.06271)"
cx="342.58258"
cy="27.256668"
fx="342.58258"
fy="27.256668"
r="19.571428" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4178"
id="linearGradient3828"
x1="20.383333"
y1="32.634235"
x2="52.726578"
y2="32.634235"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.1630793,0,0,1.1396343,-2.5165983,3.4151415)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3864-1"
id="linearGradient3828-2"
x1="20.383333"
y1="32.634235"
x2="52.726578"
y2="32.634235"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3864-1">
<stop
id="stop3866-6"
offset="0"
style="stop-color:#71b2f8;stop-opacity:1;" />
<stop
id="stop3868-7"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<linearGradient
gradientTransform="matrix(1.1630793,0,0,1.1396343,-26.255988,14.322778)"
y2="32.634235"
x2="52.726578"
y1="32.634235"
x1="20.383333"
gradientUnits="userSpaceOnUse"
id="linearGradient3845"
xlink:href="#linearGradient4166"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="9.0078335"
inkscape:cx="15.654969"
inkscape:cy="23.838428"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1848"
inkscape:window-height="1043"
inkscape:window-x="66"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="false" />
<metadata
id="metadata3369">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="opacity:0.85;fill:url(#linearGradient3845);fill-opacity:1;stroke:#090909;stroke-width:2.18746471;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 11.201557,37.130882 c 0.252178,-0.07113 10.905391,3.84229 14.378208,5.296596 C 45.31682,39.628785 46.26631,22.510259 52.095791,10.58178 L 28.627124,6.652762 c -1.621192,11.174906 -3.334532,23.98441 -17.425567,30.47812 z"
id="path3820-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;stroke:#ff0900;stroke-width:2.55285668;stroke-linecap:round;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"
d="m 11.414852,53.329345 c -0.162971,-6.91565 0.10332,-4.922865 -0.144914,-16.265896"
id="path3918-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#ff0900;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:30.29999923999999822;stroke-opacity:1;stroke-dasharray:18, 6;stroke-dashoffset:0;marker-start:none"
d="M 0.88417837,48.039022 C 11.330775,48.513224 32.686249,53.004323 42.745293,41.872435 51.278061,32.429606 53.4974,19.758654 61.595219,2.2398862"
id="path3885"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csc" />
<path
style="fill:url(#linearGradient3828);fill-opacity:1;fill-rule:nonzero;stroke:#090909;stroke-width:2.18746471;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 26.040147,42.43608 0.226329,18.152407 C 44.9786,59.94313 58.160467,44.639618 60.629125,31.212185 L 51.67214,11.437294 C 43.6375,30.278349 43.168055,38.742321 26.040147,42.43608 z"
id="path3820"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;stroke:#ff0c00;stroke-width:2.87824273;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 28.798855,6.2907134 23.256841,4.5887046 8.726353,20.099536"
id="path3864"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;stroke:#ff0900;stroke-width:2.55299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 11.380951,37.174463 14.558836,5.397865 0.389553,17.96064 C 22.550473,59.403098 14.498258,55.027369 11.414853,53.551374"
id="path3918-3-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -0,0 +1,391 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.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 <sstream>
# include <QRegExp>
# include <QTextStream>
# include <QMessageBox>
# include <Precision.hxx>
#endif
#include "ui_TaskPipeParameters.h"
#include "TaskPipeParameters.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/FeaturePipe.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Mod/PartDesign/App/Body.h>
#include "TaskSketchBasedParameters.h"
#include "ReferenceSelection.h"
#include "Workbench.h"
using namespace PartDesignGui;
using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskPipeParameters */
TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj, QWidget *parent)
: TaskSketchBasedParameters(PipeView, parent, "PartDesign_Pipe",tr("Pipe parameters"))
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui = new Ui_TaskPipeParameters();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
/*
connect(ui->lengthEdit, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
this, SLOT(onMidplane(bool)));
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
this, SLOT(onReversed(bool)));
connect(ui->lengthEdit2, SIGNAL(valueChanged(double)),
this, SLOT(onLength2Changed(double)));
connect(ui->spinOffset, SIGNAL(valueChanged(double)),
this, SLOT(onOffsetChanged(double)));
connect(ui->changeMode, SIGNAL(currentIndexChanged(int)),
this, SLOT(onModeChanged(int)));
connect(ui->buttonFace, SIGNAL(clicked()),
this, SLOT(onButtonFace()));
connect(ui->lineFaceName, SIGNAL(textEdited(QString)),
this, SLOT(onFaceName(QString)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
*/
this->groupLayout()->addWidget(proxy);
/*
// Temporarily prevent unnecessary feature recomputes
ui->lengthEdit->blockSignals(true);
ui->lengthEdit2->blockSignals(true);
ui->checkBoxMidplane->blockSignals(true);
ui->checkBoxReversed->blockSignals(true);
ui->buttonFace->blockSignals(true);
ui->lineFaceName->blockSignals(true);
ui->changeMode->blockSignals(true);
// set the history path
ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PipeLength"));
ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PipeLength2"));
// Get the feature data
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
Base::Quantity l = pcPipe->Length.getQuantityValue();
bool midplane = pcPipe->Midplane.getValue();
bool reversed = pcPipe->Reversed.getValue();
Base::Quantity l2 = pcPipe->Length2.getQuantityValue();
int index = pcPipe->Type.getValue(); // must extract value here, clear() kills it!
App::DocumentObject* obj = pcPipe->UpToFace.getValue();
std::vector<std::string> subStrings = pcPipe->UpToFace.getSubValues();
std::string upToFace;
int faceId = -1;
if ((obj != NULL) && !subStrings.empty()) {
upToFace = subStrings.front();
if (upToFace.substr(0,4) == "Face")
faceId = std::atoi(&upToFace[4]);
}
// Fill data into dialog elements
ui->lengthEdit->setMinimum(0);
ui->lengthEdit->setMaximum(INT_MAX);
ui->lengthEdit->setValue(l);
ui->lengthEdit2->setMinimum(0);
ui->lengthEdit2->setMaximum(INT_MAX);
ui->lengthEdit2->setValue(l2);
ui->checkBoxMidplane->setChecked(midplane);
// According to bug #0000521 the reversed option
// shouldn't be de-activated if the pad has a support face
ui->checkBoxReversed->setChecked(reversed);
if ((obj != NULL) && PartDesign::Feature::isDatum(obj))
ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument()));
else if (faceId >= 0)
ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument()) + QString::fromAscii(":") + tr("Face") +
QString::number(faceId));
else
ui->lineFaceName->setText(tr("No face selected"));
ui->lineFaceName->setProperty("FaceName", QByteArray(upToFace.c_str()));
ui->changeMode->clear();
ui->changeMode->insertItem(0, tr("Dimension"));
ui->changeMode->insertItem(1, tr("To last"));
ui->changeMode->insertItem(2, tr("To first"));
ui->changeMode->insertItem(3, tr("Up to face"));
ui->changeMode->insertItem(4, tr("Two dimensions"));
ui->changeMode->setCurrentIndex(index);
// activate and de-activate dialog elements as appropriate
ui->lengthEdit->blockSignals(false);
ui->lengthEdit2->blockSignals(false);
ui->checkBoxMidplane->blockSignals(false);
ui->checkBoxReversed->blockSignals(false);
ui->buttonFace->blockSignals(false);
ui->lineFaceName->blockSignals(false);
ui->changeMode->blockSignals(false);
updateUI(index);
// if it is a newly created object use the last value of the history
if(newObj){
ui->lengthEdit->setToLastUsedValue();
ui->lengthEdit->selectNumber();
ui->lengthEdit2->setToLastUsedValue();
ui->lengthEdit2->selectNumber();
}*/
}
void TaskPipeParameters::updateUI(int index)
{/*
if (index == 0) { // dimension
ui->labelLength->setVisible(true);
ui->spinOffset->setVisible(false);
ui->spinOffset->setEnabled(false);
ui->labelOffset->setVisible(false);
ui->lengthEdit->setEnabled(true);
ui->lengthEdit->selectNumber();
// Make sure that the spin box has the focus to get key events
// Calling setFocus() directly doesn't work because the spin box is not
// yet visible.
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
ui->checkBoxMidplane->setEnabled(true);
// Reverse only makes sense if Midplane is not true
ui->checkBoxReversed->setEnabled(!ui->checkBoxMidplane->isChecked());
ui->lengthEdit2->setEnabled(false);
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
onButtonFace(false);
} else if (index == 1 || index == 2) { // up to first/last
ui->labelLength->setVisible(false);
ui->spinOffset->setVisible(true);
ui->spinOffset->setEnabled(true);
ui->labelOffset->setVisible(true);
ui->lengthEdit->setEnabled(false);
ui->checkBoxMidplane->setEnabled(false);
ui->checkBoxReversed->setEnabled(true);
ui->lengthEdit2->setEnabled(false);
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
onButtonFace(false);
} else if (index == 3) { // up to face
ui->labelLength->setVisible(false);
ui->spinOffset->setVisible(true);
ui->spinOffset->setEnabled(true);
ui->labelOffset->setVisible(true);
ui->lengthEdit->setEnabled(false);
ui->checkBoxMidplane->setEnabled(false);
ui->checkBoxReversed->setEnabled(false);
ui->lengthEdit2->setEnabled(false);
ui->buttonFace->setEnabled(true);
ui->lineFaceName->setEnabled(true);
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
// Go into reference selection mode if no face has been selected yet
if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected")))
onButtonFace(true);
} else { // two dimensions
ui->labelLength->setVisible(true);
ui->spinOffset->setVisible(false);
ui->spinOffset->setEnabled(false);
ui->labelOffset->setVisible(false);
ui->lengthEdit->setEnabled(true);
ui->lengthEdit->selectNumber();
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
ui->checkBoxMidplane->setEnabled(false);
ui->checkBoxReversed->setEnabled(false);
ui->lengthEdit2->setEnabled(true);
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
onButtonFace(false);
}*/
}
void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{/*
if (msg.Type == Gui::SelectionChanges::AddSelection) {
QString refText = onAddSelection(msg);
if (refText.length() != 0) {
ui->lineFaceName->blockSignals(true);
ui->lineFaceName->setText(refText);
ui->lineFaceName->setProperty("FaceName", QByteArray(msg.pSubName));
ui->lineFaceName->blockSignals(false);
// Turn off reference selection mode
onButtonFace(false);
} else {
ui->lineFaceName->blockSignals(true);
ui->lineFaceName->setText(tr("No face selected"));
ui->lineFaceName->setProperty("FaceName", QByteArray());
ui->lineFaceName->blockSignals(false);
}
}
else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
ui->lineFaceName->blockSignals(true);
ui->lineFaceName->setText(tr(""));
ui->lineFaceName->setProperty("FaceName", QByteArray());
ui->lineFaceName->blockSignals(false);
}*/
}
TaskPipeParameters::~TaskPipeParameters()
{
delete ui;
}
void TaskPipeParameters::changeEvent(QEvent *e)
{/*
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->spinOffset->blockSignals(true);
ui->lengthEdit->blockSignals(true);
ui->lengthEdit2->blockSignals(true);
ui->lineFaceName->blockSignals(true);
ui->changeMode->blockSignals(true);
int index = ui->changeMode->currentIndex();
ui->retranslateUi(proxy);
ui->changeMode->clear();
ui->changeMode->addItem(tr("Dimension"));
ui->changeMode->addItem(tr("To last"));
ui->changeMode->addItem(tr("To first"));
ui->changeMode->addItem(tr("Up to face"));
ui->changeMode->addItem(tr("Two dimensions"));
ui->changeMode->setCurrentIndex(index);
QStringList parts = ui->lineFaceName->text().split(QChar::fromAscii(':'));
QByteArray upToFace = ui->lineFaceName->property("FaceName").toByteArray();
int faceId = -1;
bool ok = false;
if (upToFace.indexOf("Face") == 0) {
faceId = upToFace.remove(0,4).toInt(&ok);
}
#if QT_VERSION >= 0x040700
ui->lineFaceName->setPlaceholderText(tr("No face selected"));
#endif
ui->lineFaceName->setText(ok ?
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
tr("No face selected"));
ui->spinOffset->blockSignals(false);
ui->lengthEdit->blockSignals(false);
ui->lengthEdit2->blockSignals(false);
ui->lineFaceName->blockSignals(false);
ui->changeMode->blockSignals(false);
}*/
}
//**************************************************************************
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgPipeParameters::TaskDlgPipeParameters(ViewProviderPipe *PipeView,bool newObj)
: TaskDlgSketchBasedParameters(PipeView)
{
assert(PipeView);
parameter = new TaskPipeParameters(PipeView,newObj);
Content.push_back(parameter);
}
TaskDlgPipeParameters::~TaskDlgPipeParameters()
{
}
//==== calls from the TaskView ===============================================================
bool TaskDlgPipeParameters::accept()
{/*
std::string name = vp->getObject()->getNameInDocument();
// save the history
parameter->saveHistory();
try {
//Gui::Command::openCommand("Pipe 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.%s.Reversed = %i",name.c_str(),parameter->getReversed()?1:0);
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.Length2 = %f",name.c_str(),parameter->getLength2());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Offset = %f",name.c_str(),parameter->getOffset());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),parameter->getMode());
std::string facename = (const char*)parameter->getFaceName();
if (!facename.empty()) {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), facename.c_str());
} else
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!vp->getObject()->isValid())
throw Base::Exception(vp->getObject()->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what()));
return false;
}
return true;*/
}
//bool TaskDlgPipeParameters::reject()
//{
// // get the support and Sketch
// PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
// Sketcher::SketchObject *pcSketch = 0;
// App::DocumentObject *pcSupport = 0;
// if (pcPipe->Sketch.getValue()) {
// pcSketch = static_cast<Sketcher::SketchObject*>(pcPipe->Sketch.getValue());
// pcSupport = pcSketch->Support.getValue();
// }
//
// // roll 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(pcPipe)) {
// 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_TaskPipeParameters.cpp"

View File

@ -0,0 +1,95 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.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_TaskPipeParameters_H
#define GUI_TASKVIEW_TaskPipeParameters_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h>
#include "TaskSketchBasedParameters.h"
#include "ViewProviderPipe.h"
class Ui_TaskPipeParameters;
namespace App {
class Property;
}
namespace Gui {
class ViewProvider;
}
namespace PartDesignGui {
class TaskPipeParameters : public TaskSketchBasedParameters
{
Q_OBJECT
public:
TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj=false,QWidget *parent = 0);
~TaskPipeParameters();
private Q_SLOTS:
protected:
void changeEvent(QEvent *e);
private:
void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI(int index);
private:
QWidget* proxy;
Ui_TaskPipeParameters* ui;
};
/// simulation dialog for the TaskView
class TaskDlgPipeParameters : public TaskDlgSketchBasedParameters
{
Q_OBJECT
public:
TaskDlgPipeParameters(ViewProviderPipe *PipeView,bool newObj=false);
~TaskDlgPipeParameters();
ViewProviderPipe* getPipeView() const
{ return static_cast<ViewProviderPipe*>(vp); }
public:
/// 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)
protected:
TaskPipeParameters *parameter;
};
} //namespace PartDesignGui
#endif // GUI_TASKVIEW_TASKAPPERANCE_H

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskPipeParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskPipeParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>257</width>
<height>305</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="text">
<string>Add Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Profile orientation</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Transition type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_2"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,135 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.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 <QMessageBox>
#endif
#include "ViewProviderPipe.h"
//#include "TaskPipeParameters.h"
#include "Workbench.h"
#include "TaskPipeParameters.h"
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/FeaturePipe.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Application.h>
using namespace PartDesignGui;
PROPERTY_SOURCE(PartDesignGui::ViewProviderPipe,PartDesignGui::ViewProvider)
ViewProviderPipe::ViewProviderPipe()
{
sPixmap = "PartDesign_Additive_Pipe.svg";
}
ViewProviderPipe::~ViewProviderPipe()
{
}
std::vector<App::DocumentObject*> ViewProviderPipe::claimChildren(void)const
{
std::vector<App::DocumentObject*> temp;
App::DocumentObject* sketch = static_cast<PartDesign::Pipe*>(getObject())->Sketch.getValue();
if (sketch != NULL)
temp.push_back(sketch);
return temp;
}
void ViewProviderPipe::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{/*
QAction* act;
act = menu->addAction(QObject::tr("Edit pad"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);*/
}
bool ViewProviderPipe::doubleClicked(void)
{
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument());
return true;
}
bool ViewProviderPipe::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default || ModNum == 1 ) {
// 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();
TaskDlgPipeParameters *padDlg = qobject_cast<TaskDlgPipeParameters *>(dlg);
if (padDlg && padDlg->getPipeView() != 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().reject();
else
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// always change to PartDesign WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
// start the edit dialog
if (padDlg)
Gui::Control().showDialog(padDlg);
else
Gui::Control().showDialog(new TaskDlgPipeParameters(this,ModNum == 1));
return true;
}
else {
return ViewProviderPart::setEdit(ModNum);
}
}
bool ViewProviderPipe::onDelete(const std::vector<std::string> &s)
{/*
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(getObject());
// get the Sketch
Sketcher::SketchObject *pcSketch = 0;
if (pcPipe->Sketch.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(pcPipe->Sketch.getValue());
// if abort command deleted the object the sketch is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
return ViewProvider::onDelete(s);*/
}

View File

@ -0,0 +1,57 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.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_ViewProviderPipe_H
#define PARTGUI_ViewProviderPipe_H
#include "ViewProvider.h"
namespace PartDesignGui {
class PartDesignGuiExport ViewProviderPipe : public ViewProvider
{
PROPERTY_HEADER(PartDesignGui::ViewProviderPipe);
public:
/// constructor
ViewProviderPipe();
/// destructor
virtual ~ViewProviderPipe();
/// grouping handling
std::vector<App::DocumentObject*> claimChildren(void)const;
void setupContextMenu(QMenu*, QObject*, const char*);
bool doubleClicked();
virtual bool onDelete(const std::vector<std::string> &);
protected:
virtual bool setEdit(int ModNum);
};
} // namespace PartDesignGui
#endif // PARTGUI_ViewProviderPipe_H

View File

@ -747,6 +747,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "PartDesign_Pocket"
<< "PartDesign_Revolution"
<< "PartDesign_Groove"
<< "PartDesign_AdditivePipe"
<< "PartDesign_SubtractivePipe"
<< "PartDesign_Fillet"
<< "PartDesign_Chamfer"
<< "PartDesign_Draft"
@ -803,6 +805,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "PartDesign_Pocket"
<< "PartDesign_Revolution"
<< "PartDesign_Groove"
<< "PartDesign_AdditivePipe"
<< "PartDesign_SubtractivePipe"
<< "PartDesign_Fillet"
<< "PartDesign_Chamfer"
<< "PartDesign_Draft"