add part design thickness

This commit is contained in:
Stefan Tröger 2015-05-21 07:10:40 +02:00
parent 7971bdbb8e
commit c3f35d9f05
16 changed files with 1136 additions and 17 deletions

View File

@ -542,14 +542,12 @@ PROPERTY_SOURCE(Part::Thickness, Part::Feature)
Thickness::Thickness()
{
ADD_PROPERTY_TYPE(Faces,(0),"Thickness",App::Prop_None,"Source shape");
ADD_PROPERTY_TYPE(Faces,(0),"Thickness",App::Prop_None,"Faces to be removed");
ADD_PROPERTY_TYPE(Value,(1.0),"Thickness",App::Prop_None,"Thickness value");
ADD_PROPERTY_TYPE(Mode,(long(0)),"Thickness",App::Prop_None,"Mode");
Mode.setEnums(ModeEnums);
ADD_PROPERTY_TYPE(Join,(long(0)),"Thickness",App::Prop_None,"Join type");
Join.setEnums(JoinEnums);
ADD_PROPERTY_TYPE(Intersection,(false),"Thickness",App::Prop_None,"Intersection");
ADD_PROPERTY_TYPE(SelfIntersection,(false),"Thickness",App::Prop_None,"Self Intersection");
}
short Thickness::mustExecute() const

View File

@ -53,6 +53,7 @@
#include "FeatureBoolean.h"
#include "FeaturePrimitive.h"
#include "DatumCS.h"
#include "FeatureThickness.h"
namespace PartDesign {
extern PyObject* initModule();
@ -99,6 +100,7 @@ PyMODINIT_FUNC init_PartDesign()
PartDesign::Groove ::init();
PartDesign::Chamfer ::init();
PartDesign::Draft ::init();
PartDesign::Thickness ::init();
PartDesign::Plane ::init();
PartDesign::Line ::init();
PartDesign::Point ::init();
@ -114,21 +116,21 @@ PyMODINIT_FUNC init_PartDesign()
PartDesign::Sphere ::init();
PartDesign::AdditiveSphere ::init();
PartDesign::SubtractiveSphere ::init();
PartDesign::Cone ::init();
PartDesign::AdditiveCone ::init();
PartDesign::SubtractiveCone ::init();
PartDesign::Ellipsoid ::init();
PartDesign::AdditiveEllipsoid ::init();
PartDesign::Cone ::init();
PartDesign::AdditiveCone ::init();
PartDesign::SubtractiveCone ::init();
PartDesign::Ellipsoid ::init();
PartDesign::AdditiveEllipsoid ::init();
PartDesign::SubtractiveEllipsoid ::init();
PartDesign::Torus ::init();
PartDesign::AdditiveTorus ::init();
PartDesign::SubtractiveTorus ::init();
PartDesign::Prism ::init();
PartDesign::AdditivePrism ::init();
PartDesign::SubtractivePrism ::init();
PartDesign::Wedge ::init();
PartDesign::AdditiveWedge ::init();
PartDesign::SubtractiveWedge ::init();
PartDesign::Torus ::init();
PartDesign::AdditiveTorus ::init();
PartDesign::SubtractiveTorus ::init();
PartDesign::Prism ::init();
PartDesign::AdditivePrism ::init();
PartDesign::SubtractivePrism ::init();
PartDesign::Wedge ::init();
PartDesign::AdditiveWedge ::init();
PartDesign::SubtractiveWedge ::init();
PartDesign::Point ::initHints();
PartDesign::Line ::initHints();

View File

@ -76,6 +76,8 @@ SET(FeaturesDressUp_SRCS
FeatureChamfer.h
FeatureDraft.cpp
FeatureDraft.h
FeatureThickness.cpp
FeatureThickness.h
)
SOURCE_GROUP("DressUpFeatures" FILES ${FeaturesDressUp_SRCS})

View File

@ -0,0 +1,96 @@
/***************************************************************************
* 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_
#endif
#include "FeatureThickness.h"
#include <Base/Exception.h>
#include <TopoDS.hxx>
#include <Precision.hxx>
using namespace PartDesign;
const char* PartDesign::Thickness::ModeEnums[] = {"Skin","Pipe", "RectoVerso",NULL};
const char* PartDesign::Thickness::JoinEnums[] = {"Arc", "Intersection",NULL};
namespace PartDesign {
const App::PropertyQuantityConstraint::Constraints quantityRange = {0.0,FLT_MAX,0.1};
}
PROPERTY_SOURCE(PartDesign::Thickness, PartDesign::DressUp)
Thickness::Thickness()
{
ADD_PROPERTY_TYPE(Value,(1.0),"Thickness",App::Prop_None,"Thickness value");
ADD_PROPERTY_TYPE(Mode,(long(0)),"Thickness",App::Prop_None,"Mode");
Mode.setEnums(ModeEnums);
ADD_PROPERTY_TYPE(Join,(long(0)),"Thickness",App::Prop_None,"Join type");
Join.setEnums(JoinEnums);
ADD_PROPERTY_TYPE(Reversed,(false),"Thickness",App::Prop_None,"Apply the thickness towards the solids interior");
}
short Thickness::mustExecute() const
{
if (Placement.isTouched() ||
Value.isTouched() ||
Mode.isTouched() ||
Join.isTouched())
return 1;
return DressUp::mustExecute();
}
App::DocumentObjectExecReturn *Thickness::execute(void)
{
// Base shape
Part::TopoShape TopShape;
try {
TopShape = getBaseShape();
} catch (Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
TopTools_ListOfShape closingFaces;
const std::vector<std::string>& subStrings = Base.getSubValues();
for (std::vector<std::string>::const_iterator it = subStrings.begin(); it != subStrings.end(); ++it) {
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(it->c_str()));
closingFaces.Append(face);
}
bool reversed = Reversed.getValue();
double thickness = (reversed ? -1. : 1. )*Value.getValue();
double tol = Precision::Confusion();
short mode = (short)Mode.getValue();
short join = (short)Join.getValue();
//we do not offer tangent join type
if(join == 1)
join = 2;
if (fabs(thickness) > 2*tol)
this->Shape.setValue(TopShape.makeThickSolid(closingFaces, thickness, tol, false, false, mode, join));
else
this->Shape.setValue(TopShape._Shape);
return App::DocumentObject::StdReturn;
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
* 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_FEATURETHICKNESS_H
#define PARTDESIGN_FEATURETHICKNESS_H
#include <App/PropertyStandard.h>
#include <App/PropertyLinks.h>
#include <App/PropertyUnits.h>
#include "FeatureDressUp.h"
namespace PartDesign
{
class PartDesignExport Thickness : public DressUp
{
PROPERTY_HEADER(PartDesign::Thickness);
public:
Thickness();
App::PropertyLength Value;
App::PropertyBool Reversed;
App::PropertyEnumeration Mode;
App::PropertyEnumeration Join;
/** @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::ViewProviderThickness";
}
//@}
private:
static const char* ModeEnums[];
static const char* JoinEnums[];
};
} //namespace PartDesign
#endif // PARTDESIGN_FEATURETHICKNESS_H

View File

@ -56,6 +56,7 @@
#include "ViewProviderBoolean.h"
#include "ViewProviderPrimitive.h"
#include "ViewProviderDatumCS.h"
#include "ViewProviderThickness.h"
// use a different name to CreateCommand()
void CreatePartDesignCommands(void);
@ -125,6 +126,7 @@ PyMODINIT_FUNC initPartDesignGui()
PartDesignGui::ViewProviderChamfer ::init();
PartDesignGui::ViewProviderFillet ::init();
PartDesignGui::ViewProviderDraft ::init();
PartDesignGui::ViewProviderThickness ::init();
PartDesignGui::ViewProviderTransformed ::init();
PartDesignGui::ViewProviderMirrored ::init();
PartDesignGui::ViewProviderLinearPattern ::init();

View File

@ -35,6 +35,7 @@ set(PartDesignGui_MOC_HDRS
TaskChamferParameters.h
TaskFilletParameters.h
TaskDraftParameters.h
TaskThicknessParameters.h
TaskDressUpParameters.h
TaskHoleParameters.h
TaskRevolutionParameters.h
@ -62,6 +63,7 @@ set(PartDesignGui_UIC_SRCS
TaskChamferParameters.ui
TaskFilletParameters.ui
TaskDraftParameters.ui
TaskThicknessParameters.ui
TaskBooleanParameters.ui
TaskHoleParameters.ui
TaskRevolutionParameters.ui
@ -94,6 +96,8 @@ SET(PartDesignGuiViewProvider_SRCS CommandPrimitive.cpp
ViewProviderFillet.h
ViewProviderDraft.cpp
ViewProviderDraft.h
ViewProviderThickness.cpp
ViewProviderThickness.h
ViewProviderDressUp.cpp
ViewProviderDressUp.h
ViewProviderRevolution.cpp
@ -152,6 +156,9 @@ SET(PartDesignGuiTaskDlgs_SRCS
TaskDraftParameters.ui
TaskDraftParameters.cpp
TaskDraftParameters.h
TaskThicknessParameters.ui
TaskThicknessParameters.cpp
TaskThicknessParameters.h
TaskDressUpParameters.cpp
TaskDressUpParameters.h
TaskRevolutionParameters.ui

View File

@ -1468,6 +1468,108 @@ bool CmdPartDesignDraft::isActive(void)
return hasActiveDocument();
}
//===========================================================================
// PartDesign_Thickness
//===========================================================================
DEF_STD_CMD_A(CmdPartDesignThickness);
CmdPartDesignThickness::CmdPartDesignThickness()
:Command("PartDesign_Thickness")
{
sAppModule = "PartDesign";
sGroup = QT_TR_NOOP("PartDesign");
sMenuText = QT_TR_NOOP("Thickness");
sToolTipText = QT_TR_NOOP("Make a thick solid");
sWhatsThis = "PartDesign_Thickness";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Thickness";
}
void CmdPartDesignThickness::activated(int iMsg)
{
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
if (!pcActiveBody) return;
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
if (selection.size() < 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select one or more faces."));
return;
}
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
QObject::tr("Thickness works only on parts"));
return;
}
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
if (base != pcActiveBody->getPrevSolidFeature(NULL, true)) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong base feature"),
QObject::tr("Only the current Tip of the active Body can be selected as the base feature"));
return;
}
const Part::TopoShape& TopShape = base->Shape.getShape();
if (TopShape._Shape.IsNull()){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Shape of selected Part is empty"));
return;
}
std::vector<std::string> SubNames = std::vector<std::string>(selection[0].getSubNames());
unsigned int i = 0;
while(i < SubNames.size())
{
std::string aSubName = static_cast<std::string>(SubNames.at(i));
if(aSubName.size() > 4 && aSubName.substr(0,4) != "Face") {
// empty name or any other sub-element
SubNames.erase(SubNames.begin()+i);
}
i++;
}
if (SubNames.size() == 0) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("No thickness possible with selected faces"));
return;
}
std::string SelString;
SelString += "(App.";
SelString += "ActiveDocument";
SelString += ".";
SelString += selection[0].getFeatName();
SelString += ",[";
for(std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
SelString += "\"";
SelString += *it;
SelString += "\"";
if(it != --SubNames.end())
SelString += ",";
}
SelString += "])";
std::string FeatName = getUniqueObjectName("Thickness");
openCommand("Make Thickness");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Thickness\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
doCommand(Doc,"App.activeDocument().%s.Value = %f",FeatName.c_str(), 1.);
finishFeature(this, FeatName);
}
bool CmdPartDesignThickness::isActive(void)
{
return hasActiveDocument();
}
//===========================================================================
// Common functions for all Transformed features
//===========================================================================
@ -1930,6 +2032,7 @@ void CreatePartDesignCommands(void)
rcCmdMgr.addCommand(new CmdPartDesignFillet());
rcCmdMgr.addCommand(new CmdPartDesignDraft());
rcCmdMgr.addCommand(new CmdPartDesignChamfer());
rcCmdMgr.addCommand(new CmdPartDesignThickness());
rcCmdMgr.addCommand(new CmdPartDesignMirrored());
rcCmdMgr.addCommand(new CmdPartDesignLinearPattern());

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>

View File

@ -0,0 +1,243 @@
<?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="svg3364"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
sodipodi:docname="PartDesign_Thickness.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs3366">
<linearGradient
id="linearGradient3835">
<stop
id="stop3837"
offset="0"
style="stop-color:#637dca;stop-opacity:1;" />
<stop
id="stop3839"
offset="1"
style="stop-color:#9eaede;stop-opacity:1;" />
</linearGradient>
<linearGradient
id="linearGradient3827">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop3829" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop3831" />
</linearGradient>
<linearGradient
id="linearGradient3864">
<stop
id="stop3866"
offset="0"
style="stop-color:#840000;stop-opacity:0.80392158;" />
<stop
id="stop3868"
offset="1"
style="stop-color:#ff2b1e;stop-opacity:0.80392158;" />
</linearGradient>
<linearGradient
id="linearGradient3593">
<stop
style="stop-color:#00aff9;stop-opacity:1;"
offset="0"
id="stop3595" />
<stop
style="stop-color:#001ccc;stop-opacity:1;"
offset="1"
id="stop3597" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-24.909091 : 16.545455 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="116.36364 : 23.818182 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective3372" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="radialGradient2998"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.6696601,0.63911498,-0.09121381,0.31244488,-540.88725,-258.46199)"
cx="342.58258"
cy="27.256668"
fx="342.58258"
fy="27.256668"
r="19.571428" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3593-0"
id="radialGradient3004-8"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-320.59978,-6.63068)"
cx="330.63791"
cy="39.962704"
fx="330.63791"
fy="39.962704"
r="19.571428" />
<linearGradient
id="linearGradient3593-0">
<stop
style="stop-color:#c8e0f9;stop-opacity:1;"
offset="0"
id="stop3595-2" />
<stop
style="stop-color:#637dca;stop-opacity:1;"
offset="1"
id="stop3597-1" />
</linearGradient>
<radialGradient
r="19.571428"
fy="39.962704"
fx="330.63791"
cy="39.962704"
cx="330.63791"
gradientTransform="matrix(-0.93227784,0,0,1.3554421,396.33347,-27.208207)"
gradientUnits="userSpaceOnUse"
id="radialGradient3036"
xlink:href="#linearGradient3593-0"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3593"
id="linearGradient3799"
x1="5.3636365"
y1="34"
x2="57"
y2="34"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.2844364,0,0,1.2700541,2.2183889,-14.517545)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="linearGradient4197"
x1="39.950768"
y1="31.536736"
x2="29.981667"
y2="46.740166"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="linearGradient4205"
x1="46.065845"
y1="19.958494"
x2="21.922672"
y2="27.790565"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-0.31061817,0)" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="radialGradient4207"
cx="50.132446"
cy="27.713734"
fx="50.132446"
fy="27.713734"
r="14.365044"
gradientTransform="matrix(1.5201261,1.5831472,-1.7680406,1.6598532,15.723871,-96.993682)"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.7781746"
inkscape:cx="11.820739"
inkscape:cy="25.130096"
inkscape:current-layer="g3780"
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" />
<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">
<g
id="g3780"
transform="matrix(0.82780005,0,0,0.83717425,-0.2499405,9.0601524)">
<path
style="fill:url(#linearGradient3799);fill-opacity:1;stroke:#000137;stroke-width:2.4024775;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 5.2059665,45.69132 40.658977,64.094456 74.142267,48.364111 74.612755,5.1901669 41.995094,-4.0465895 19.858087,2.0177168 C 14.659774,18.643962 11.167617,26.355311 5.2059665,45.69132 Z"
id="path3783"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000137;stroke-width:2.4024775;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 16.609387,43.357692 28.723496,4.6580442 40.526987,0.81879404 66.929532,9.1115748 65.842369,44.432682 41.769461,56.104004 Z"
id="path4161"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<path
style="fill:url(#linearGradient4205);fill-opacity:1;fill-rule:evenodd;stroke:#000137;stroke-width:1.20123875px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 16.609388,43.511262 38.818587,32.454219 40.837605,0.97236431 28.568188,4.5044743 Z"
id="path4167"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:url(#linearGradient4197);fill-rule:evenodd;stroke:#000137;stroke-width:1.20123875px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
d="M 17.075315,43.357692 39.129205,32.60779 65.53175,44.432682 42.080078,55.950434 Z"
id="path4169"
inkscape:connector-curvature="0" />
<path
style="fill:url(#radialGradient4207);fill-rule:evenodd;stroke:#000137;stroke-width:1.20123875px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
d="M 41.148224,1.4330742 39.439823,32.454219 65.53175,44.739822 66.929532,9.2651453 Z"
id="path4171"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.20123875px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 40.216369,63.936075 1.863708,-7.83207"
id="path4260"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.20123875px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 20.802733,2.0473538 c 7.765454,2.3035503 7.765454,2.3035503 7.765454,2.3035503"
id="path4264"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.20123875px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 67.550768,9.2651453 74.850295,5.4258942"
id="path4266"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -0,0 +1,260 @@
/***************************************************************************
* 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_
#endif
#include "ui_TaskThicknessParameters.h"
#include "TaskThicknessParameters.h"
#include "Workbench.h"
#include <Base/UnitsApi.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 <Gui/MainWindow.h>
#include <Mod/PartDesign/App/FeatureThickness.h>
#include <Mod/PartDesign/Gui/ReferenceSelection.h>
using namespace PartDesignGui;
using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskThicknessParameters */
TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView,QWidget *parent)
: TaskDressUpParameters(DressUpView, false, true, parent)
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui = new Ui_TaskThicknessParameters();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->Value, SIGNAL(valueChanged(double)),
this, SLOT(onValueChanged(double)));
connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onReversedChanged(bool)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
connect(ui->modeComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(onModeChanged(int)));
connect(ui->joinComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(onJoinTypeChanged(int)));
this->groupLayout()->addWidget(proxy);
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
double a = pcThickness->Value.getValue();
ui->Value->setMinimum(0.0);
ui->Value->setMaximum(89.99);
ui->Value->setValue(a);
ui->Value->selectAll();
QMetaObject::invokeMethod(ui->Value, "setFocus", Qt::QueuedConnection);
bool r = pcThickness->Reversed.getValue();
ui->checkReverse->setChecked(r);
std::vector<std::string> strings = pcThickness->Base.getSubValues();
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
{
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
}
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
ui->listWidgetReferences->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
int mode = pcThickness->Mode.getValue();
ui->modeComboBox->setCurrentIndex(mode);
int join = pcThickness->Join.getValue();
ui->modeComboBox->setCurrentIndex(join);
}
void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (selectionMode == none)
return;
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd)
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
else
removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName);
clearButtons(none);
exitSelectionMode();
}
}
}
void TaskThicknessParameters::clearButtons(const selectionModes notThis)
{
if (notThis != refAdd) ui->buttonRefAdd->setChecked(false);
if (notThis != refRemove) ui->buttonRefRemove->setChecked(false);
DressUpView->highlightReferences(false);
}
void TaskThicknessParameters::onRefDeleted(void)
{
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
App::DocumentObject* base = pcThickness->Base.getValue();
std::vector<std::string> faces = pcThickness->Base.getSubValues();
faces.erase(faces.begin() + ui->listWidgetReferences->currentRow());
pcThickness->Base.setValue(base, faces);
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
pcThickness->getDocument()->recomputeFeature(pcThickness);
}
void TaskThicknessParameters::onValueChanged(double angle)
{
clearButtons(none);
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
pcThickness->Value.setValue(angle);
pcThickness->getDocument()->recomputeFeature(pcThickness);
}
void TaskThicknessParameters::onJoinTypeChanged(int join) {
clearButtons(none);
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
pcThickness->Join.setValue(join);
pcThickness->getDocument()->recomputeFeature(pcThickness);
}
void TaskThicknessParameters::onModeChanged(int mode) {
clearButtons(none);
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
pcThickness->Mode.setValue(mode);
pcThickness->getDocument()->recomputeFeature(pcThickness);
}
const double TaskThicknessParameters::getValue(void) const
{
return ui->Value->value().getValue();
}
void TaskThicknessParameters::onReversedChanged(const bool on) {
clearButtons(none);
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
pcThickness->Reversed.setValue(on);
pcThickness->getDocument()->recomputeFeature(pcThickness);
}
const bool TaskThicknessParameters::getReversed(void) const
{
return ui->checkReverse->isChecked();
}
const int TaskThicknessParameters::getJoinType(void) const {
return ui->joinComboBox->currentIndex();
}
const int TaskThicknessParameters::getMode(void) const {
return ui->modeComboBox->currentIndex();
}
TaskThicknessParameters::~TaskThicknessParameters()
{
Gui::Selection().rmvSelectionGate();
delete ui;
}
void TaskThicknessParameters::changeEvent(QEvent *e)
{
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(proxy);
}
}
//**************************************************************************
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgThicknessParameters::TaskDlgThicknessParameters(ViewProviderThickness *DressUpView)
: TaskDlgDressUpParameters(DressUpView)
{
parameter = new TaskThicknessParameters(DressUpView);
Content.push_back(parameter);
}
TaskDlgThicknessParameters::~TaskDlgThicknessParameters()
{
}
//==== calls from the TaskView ===============================================================
//void TaskDlgThicknessParameters::open()
//{
// // a transaction is already open at creation time of the draft
// if (!Gui::Command::hasPendingCommand()) {
// QString msg = QObject::tr("Edit draft");
// Gui::Command::openCommand((const char*)msg.toUtf8());
// }
//}
//
//void TaskDlgThicknessParameters::clicked(int)
//{
//
//}
bool TaskDlgThicknessParameters::accept()
{
parameter->showObject();
TaskThicknessParameters* draftparameter = static_cast<TaskThicknessParameters*>(parameter);
std::string name = DressUpView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Value = %f",name.c_str(),draftparameter->getValue());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),draftparameter->getReversed());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Mode = %u",name.c_str(),draftparameter->getMode());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Join = %u",name.c_str(),draftparameter->getJoinType());
return TaskDlgDressUpParameters::accept();
}
#include "moc_TaskThicknessParameters.cpp"

View File

@ -0,0 +1,79 @@
/***************************************************************************
* 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_TaskThicknessParameters_H
#define GUI_TASKVIEW_TaskThicknessParameters_H
#include "TaskDressUpParameters.h"
#include "ViewProviderThickness.h"
class Ui_TaskThicknessParameters;
namespace PartDesignGui {
class TaskThicknessParameters : public TaskDressUpParameters
{
Q_OBJECT
public:
TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0);
~TaskThicknessParameters();
const double getValue(void) const;
const bool getReversed(void) const;
const int getMode(void) const;
const int getJoinType(void) const;
private Q_SLOTS:
void onValueChanged(double angle);
void onModeChanged(int mode);
void onJoinTypeChanged(int join);
void onReversedChanged(bool reversed);
void onRefDeleted(void);
protected:
virtual void clearButtons(const selectionModes notThis);
void changeEvent(QEvent *e);
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
private:
Ui_TaskThicknessParameters* ui;
};
/// simulation dialog for the TaskView
class TaskDlgThicknessParameters : public TaskDlgDressUpParameters
{
Q_OBJECT
public:
TaskDlgThicknessParameters(ViewProviderThickness *ThicknessView);
~TaskDlgThicknessParameters();
public:
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
};
} //namespace PartDesignGui
#endif // GUI_TASKVIEW_TASKAPPERANCE_H

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskThicknessParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskThicknessParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>321</width>
<height>509</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 face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Draft angle</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="Value" native="true">
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="minimum" stdset="0">
<double>0.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep" stdset="0">
<double>0.100000000000000</double>
</property>
<property name="value" stdset="0">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Join Type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="modeComboBox">
<item>
<property name="text">
<string>Skin</string>
</property>
</item>
<item>
<property name="text">
<string>Pipe</string>
</property>
</item>
<item>
<property name="text">
<string>Recto Verso</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="joinComboBox">
<item>
<property name="text">
<string>Arc</string>
</property>
</item>
<item>
<property name="text">
<string>Intersection</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkReverse">
<property name="text">
<string>Make thickness inwards</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,69 @@
/***************************************************************************
* 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 <TopTools_IndexedMapOfShape.hxx>
# include <TopExp.hxx>
#endif
#include "ViewProviderThickness.h"
#include "TaskThicknessParameters.h"
#include <Mod/PartDesign/App/FeatureThickness.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::ViewProviderThickness,PartDesignGui::ViewProviderDressUp)
bool ViewProviderThickness::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
TaskDlgDressUpParameters *dressUpDlg = NULL;
if (checkDlgOpen(dressUpDlg)) {
// always change to PartDesign WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
// start the edit dialog
if (dressUpDlg)
Gui::Control().showDialog(dressUpDlg);
else
Gui::Control().showDialog(new TaskDlgThicknessParameters(this));
return true;
} else {
return false;
}
}
else {
return ViewProviderDressUp::setEdit(ModNum);
}
}

View File

@ -0,0 +1,49 @@
/***************************************************************************
* 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_ViewProviderThickness_H
#define PARTGUI_ViewProviderThickness_H
#include "ViewProviderDressUp.h"
namespace PartDesignGui {
class PartDesignGuiExport ViewProviderThickness : public ViewProviderDressUp
{
PROPERTY_HEADER(PartDesignGui::ViewProviderThickness);
public:
/// constructor
ViewProviderThickness()
{ featureName = std::string("Thickness");
sPixmap = "PartDesign_Thickness.svg"; }
protected:
virtual bool setEdit(int ModNum);
};
} // namespace PartDesignGui
#endif // PARTGUI_ViewProviderThickness_H

View File

@ -494,6 +494,7 @@ void Workbench::activated()
"PartDesign_Fillet",
"PartDesign_Chamfer",
"PartDesign_Draft",
"PartDesign_Thickness",
"PartDesign_Plane",
"PartDesign_Line",
"PartDesign_Point",
@ -587,6 +588,7 @@ void Workbench::activated()
"PartDesign_Fillet",
"PartDesign_Chamfer",
"PartDesign_Draft",
"PartDesign_Thickness",
0};
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
"SELECT Part::Feature SUBELEMENT Face COUNT 2..",
@ -698,6 +700,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "PartDesign_Fillet"
<< "PartDesign_Chamfer"
<< "PartDesign_Draft"
<< "PartDesign_Thickness"
<< "PartDesign_Mirrored"
<< "PartDesign_LinearPattern"
<< "PartDesign_PolarPattern"
@ -752,6 +755,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "PartDesign_Fillet"
<< "PartDesign_Chamfer"
<< "PartDesign_Draft"
<< "PartDesign_Thickness"
<< "PartDesign_Mirrored"
<< "PartDesign_LinearPattern"
<< "PartDesign_PolarPattern"