basic infrastructure for part design primitives
This commit is contained in:
parent
7194413d6b
commit
52c8a19d4d
|
@ -51,6 +51,7 @@
|
|||
#include "DatumLine.h"
|
||||
#include "DatumPoint.h"
|
||||
#include "FeatureBoolean.h"
|
||||
#include "FeaturePrimitive.h"
|
||||
|
||||
namespace PartDesign {
|
||||
extern PyObject* initModule();
|
||||
|
@ -101,6 +102,10 @@ PyMODINIT_FUNC init_PartDesign()
|
|||
PartDesign::Line ::init();
|
||||
PartDesign::Point ::init();
|
||||
PartDesign::Boolean ::init();
|
||||
PartDesign::FeaturePrimitive ::init();
|
||||
PartDesign::Box ::init();
|
||||
PartDesign::AdditiveBox ::init();
|
||||
PartDesign::SubtractiveBox ::init();
|
||||
|
||||
PartDesign::Point::initHints();
|
||||
PartDesign::Line ::initHints();
|
||||
|
|
|
@ -94,6 +94,8 @@ SET(FeaturesSketchBased_SRCS
|
|||
FeatureHole.cpp
|
||||
FeatureBoolean.h
|
||||
FeatureBoolean.cpp
|
||||
FeaturePrimitive.h
|
||||
FeaturePrimitive.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP("SketchBasedFeatures" FILES ${FeaturesSketchBased_SRCS})
|
||||
|
|
159
src/Mod/PartDesign/App/FeaturePrimitive.cpp
Normal file
159
src/Mod/PartDesign/App/FeaturePrimitive.cpp
Normal file
|
@ -0,0 +1,159 @@
|
|||
/***************************************************************************
|
||||
* 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 "FeaturePrimitive.h"
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepBuilderAPI_GTransform.hxx>
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <BRepAlgoAPI_Cut.hxx>
|
||||
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::FeaturePrimitive, PartDesign::FeatureAddSub)
|
||||
|
||||
FeaturePrimitive::FeaturePrimitive()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(References, (0,0), "Primitive", (App::PropertyType)(App::Prop_None), "References to build the location of the primitive");
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& primitiveShape)
|
||||
{
|
||||
try {
|
||||
//transform the primitive in the correct coordinance
|
||||
BRepBuilderAPI_GTransform mkTrf(primitiveShape, getLocation().Transformation());
|
||||
const TopoDS_Shape primitiveShape = mkTrf.Shape();
|
||||
|
||||
//if we have no base we just add the standart primitive shape
|
||||
const TopoDS_Shape base = getBaseShape();
|
||||
if(base.IsNull()) {
|
||||
if(getAddSubType() == FeatureAddSub::Additive)
|
||||
Shape.setValue(primitiveShape);
|
||||
else
|
||||
return new App::DocumentObjectExecReturn("Cannot subtract primitive feature without base feature");
|
||||
|
||||
AddSubShape.setValue(base);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
if(getAddSubType() == FeatureAddSub::Additive) {
|
||||
BRepAlgoAPI_Fuse mkFuse(base, primitiveShape);
|
||||
if (!mkFuse.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Adding the primitive failed");
|
||||
// we have to get the solids (fuse sometimes creates compounds)
|
||||
TopoDS_Shape boolOp = this->getSolid(mkFuse.Shape());
|
||||
// lets check if the result is a solid
|
||||
if (boolOp.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
|
||||
|
||||
Shape.setValue(boolOp);
|
||||
AddSubShape.setValue(primitiveShape);
|
||||
}
|
||||
else if(getAddSubType() == FeatureAddSub::Subtractive) {
|
||||
|
||||
BRepAlgoAPI_Cut mkCut(base, primitiveShape);
|
||||
if (!mkCut.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Subtracting the primitive failed");
|
||||
// we have to get the solids (fuse sometimes creates compounds)
|
||||
TopoDS_Shape boolOp = this->getSolid(mkCut.Shape());
|
||||
// lets check if the result is a solid
|
||||
if (boolOp.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
|
||||
|
||||
Shape.setValue(boolOp);
|
||||
AddSubShape.setValue(primitiveShape);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
TopLoc_Location FeaturePrimitive::calculateLocation()
|
||||
{
|
||||
return TopLoc_Location();
|
||||
}
|
||||
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Box, PartDesign::FeaturePrimitive)
|
||||
|
||||
Box::Box()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Length,(10.0f),"Box",App::Prop_None,"The length of the box");
|
||||
ADD_PROPERTY_TYPE(Width ,(10.0f),"Box",App::Prop_None,"The width of the box");
|
||||
ADD_PROPERTY_TYPE(Height,(10.0f),"Box",App::Prop_None,"The height of the box");
|
||||
|
||||
primitiveType = FeaturePrimitive::Box;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* Box::execute(void)
|
||||
{
|
||||
double L = Length.getValue();
|
||||
double W = Width.getValue();
|
||||
double H = Height.getValue();
|
||||
|
||||
if (L < Precision::Confusion())
|
||||
return new App::DocumentObjectExecReturn("Length of box too small");
|
||||
|
||||
if (W < Precision::Confusion())
|
||||
return new App::DocumentObjectExecReturn("Width of box too small");
|
||||
|
||||
if (H < Precision::Confusion())
|
||||
return new App::DocumentObjectExecReturn("Height of box too small");
|
||||
|
||||
try {
|
||||
// Build a box using the dimension attributes
|
||||
BRepPrimAPI_MakeBox mkBox(L, W, H);
|
||||
return FeaturePrimitive::execute(mkBox.Shape());
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
short int Box::mustExecute() const
|
||||
{
|
||||
if ( Length.isTouched() ||
|
||||
Height.isTouched() ||
|
||||
Width.isTouched() )
|
||||
return 1;
|
||||
|
||||
return FeaturePrimitive::mustExecute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::AdditiveBox, PartDesign::Box)
|
||||
PROPERTY_SOURCE(PartDesign::SubtractiveBox, PartDesign::Box)
|
||||
|
||||
}
|
105
src/Mod/PartDesign/App/FeaturePrimitive.h
Normal file
105
src/Mod/PartDesign/App/FeaturePrimitive.h
Normal file
|
@ -0,0 +1,105 @@
|
|||
/***************************************************************************
|
||||
* 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_FeaturePrimitive_H
|
||||
#define PARTDESIGN_FeaturePrimitive_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
|
||||
#include "FeatureAddSub.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class PartDesignExport FeaturePrimitive : public PartDesign::FeatureAddSub
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::FeaturePrimitive);
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
Box=0,
|
||||
Cylinder,
|
||||
Sphere
|
||||
};
|
||||
|
||||
FeaturePrimitive();
|
||||
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "getViewProviderPrimitive";
|
||||
}
|
||||
Type getPrimitiveType() {return primitiveType;};
|
||||
|
||||
/// The references defining the primtive base
|
||||
App::PropertyLinkSubList References;
|
||||
|
||||
protected:
|
||||
//make the boolean ops with the primitives provided by the derived features
|
||||
App::DocumentObjectExecReturn* execute(const TopoDS_Shape& primitiveShape);
|
||||
|
||||
//calculate the position of the primitive from the support and the exis
|
||||
TopLoc_Location calculateLocation();
|
||||
|
||||
Type primitiveType = Box;
|
||||
};
|
||||
|
||||
class PartDesignExport Box : public PartDesign::FeaturePrimitive {
|
||||
|
||||
PROPERTY_HEADER(Part::Box);
|
||||
|
||||
public:
|
||||
|
||||
Box();
|
||||
|
||||
App::PropertyLength Length,Height,Width;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
class PartDesignExport AdditiveBox : public Box {
|
||||
PROPERTY_HEADER(PartDesign::AdditiveBox);
|
||||
|
||||
AdditiveBox() {
|
||||
addSubType = FeatureAddSub::Additive;
|
||||
}
|
||||
};
|
||||
|
||||
class PartDesignExport SubtractiveBox : public Box {
|
||||
PROPERTY_HEADER(PartDesign::SubtractiveBox);
|
||||
|
||||
SubtractiveBox() {
|
||||
addSubType = FeatureAddSub::Subtractive;
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FeaturePrimitive_H
|
|
@ -54,9 +54,11 @@
|
|||
#include "ViewProviderDatumLine.h"
|
||||
#include "ViewProviderDatumPlane.h"
|
||||
#include "ViewProviderBoolean.h"
|
||||
#include "ViewProviderPrimitive.h"
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreatePartDesignCommands(void);
|
||||
void CreatePartDesignPrimitiveCommands(void);
|
||||
|
||||
void loadPartDesignResource()
|
||||
{
|
||||
|
@ -109,6 +111,7 @@ PyMODINIT_FUNC initPartDesignGui()
|
|||
|
||||
// instantiating the commands
|
||||
CreatePartDesignCommands();
|
||||
CreatePartDesignPrimitiveCommands();
|
||||
|
||||
PartDesignGui::Workbench ::init();
|
||||
PartDesignGui::ViewProvider ::init();
|
||||
|
@ -132,6 +135,7 @@ PyMODINIT_FUNC initPartDesignGui()
|
|||
PartDesignGui::ViewProviderDatumLine ::init();
|
||||
PartDesignGui::ViewProviderDatumPlane ::init();
|
||||
PartDesignGui::ViewProviderBoolean ::init();
|
||||
PartDesignGui::ViewProviderPrimitive ::init();
|
||||
|
||||
// add resources and reloads the translators
|
||||
loadPartDesignResource();
|
||||
|
|
|
@ -75,7 +75,7 @@ set(PartDesignGui_UIC_SRCS
|
|||
)
|
||||
qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS})
|
||||
|
||||
SET(PartDesignGuiViewProvider_SRCS
|
||||
SET(PartDesignGuiViewProvider_SRCS CommandPrimitive.cpp
|
||||
ViewProvider.cpp
|
||||
ViewProvider.h
|
||||
ViewProviderBody.cpp
|
||||
|
@ -120,6 +120,8 @@ SET(PartDesignGuiViewProvider_SRCS
|
|||
ViewProviderDatumPlane.h
|
||||
ViewProviderBoolean.cpp
|
||||
ViewProviderBoolean.h
|
||||
ViewProviderPrimitive.h
|
||||
ViewProviderPrimitive.cpp
|
||||
)
|
||||
SOURCE_GROUP("ViewProvider" FILES ${PartDesignGuiViewProvider_SRCS})
|
||||
|
||||
|
@ -189,6 +191,7 @@ SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS})
|
|||
SET(PartDesignGuiModule_SRCS
|
||||
AppPartDesignGui.cpp
|
||||
Command.cpp
|
||||
CommandPrimitive.cpp
|
||||
Resources/PartDesign.qrc
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
|
|
209
src/Mod/PartDesign/Gui/CommandPrimitive.cpp
Normal file
209
src/Mod/PartDesign/Gui/CommandPrimitive.cpp
Normal file
|
@ -0,0 +1,209 @@
|
|||
/***************************************************************************
|
||||
* 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"
|
||||
#include "Workbench.h"
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/nodes/SoPickStyle.h>
|
||||
# include <QApplication>
|
||||
#endif
|
||||
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Action.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
DEF_STD_CMD_ACL(CmdPrimtiveCompAdditive);
|
||||
|
||||
CmdPrimtiveCompAdditive::CmdPrimtiveCompAdditive()
|
||||
: Command("PartDesign_CompPrimitiveAdditive")
|
||||
{
|
||||
sAppModule = "PartDesign";
|
||||
sGroup = QT_TR_NOOP("PartDesign");
|
||||
sMenuText = QT_TR_NOOP("Create an additive primitive");
|
||||
sToolTipText = QT_TR_NOOP("Create an additive primitive");
|
||||
sWhatsThis = "Sketcher_CompPrimitiveAdditive";
|
||||
sStatusTip = sToolTipText;
|
||||
eType = ForEdit;
|
||||
}
|
||||
|
||||
void CmdPrimtiveCompAdditive::activated(int iMsg)
|
||||
{
|
||||
Base::Console().Message("activated msg %i\n", iMsg);
|
||||
|
||||
PartDesign::Body *pcActiveBody = PartDesignGui::getBody();
|
||||
if (!pcActiveBody) return;
|
||||
|
||||
if(iMsg == 0) {
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Box");
|
||||
|
||||
Gui::Command::openCommand("Make additive box");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\'PartDesign::AdditiveBox\',\'%s\')",
|
||||
FeatName.c_str());
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
|
||||
,pcActiveBody->getNameInDocument(), FeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().setEdit(\'%s\')", FeatName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Gui::Action * CmdPrimtiveCompAdditive::createAction(void)
|
||||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* p1 = pcAction->addAction(QString());
|
||||
p1->setIcon(Gui::BitmapFactory().pixmap("Part_Box"));
|
||||
QAction* p2 = pcAction->addAction(QString());
|
||||
p2->setIcon(Gui::BitmapFactory().pixmap("Part_Cylinder"));
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
|
||||
pcAction->setIcon(p1->icon());
|
||||
int defaultId = 0;
|
||||
pcAction->setProperty("defaultAction", QVariant(defaultId));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
void CmdPrimtiveCompAdditive::languageChange()
|
||||
{
|
||||
Command::languageChange();
|
||||
|
||||
if (!_pcAction)
|
||||
return;
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
QAction* arc1 = a[0];
|
||||
arc1->setText(QApplication::translate("CmdSketcherCompCreateArc","Center and end points"));
|
||||
arc1->setToolTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points"));
|
||||
arc1->setStatusTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points"));
|
||||
QAction* arc2 = a[1];
|
||||
arc2->setText(QApplication::translate("CmdSketcherCompCreateArc","End points and rim point"));
|
||||
arc2->setToolTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc"));
|
||||
arc2->setStatusTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc"));
|
||||
}
|
||||
|
||||
bool CmdPrimtiveCompAdditive::isActive(void)
|
||||
{
|
||||
if (getActiveGuiDocument())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_ACL(CmdPrimtiveCompSubtractive);
|
||||
|
||||
CmdPrimtiveCompSubtractive::CmdPrimtiveCompSubtractive()
|
||||
: Command("PartDesign_CompPrimitiveSubtractive")
|
||||
{
|
||||
sAppModule = "PartDesign";
|
||||
sGroup = QT_TR_NOOP("PartDesign");
|
||||
sMenuText = QT_TR_NOOP("Create an subtractive primitive");
|
||||
sToolTipText = QT_TR_NOOP("Create an subtractive primitive");
|
||||
sWhatsThis = "PartDesign_CompPrimitiveSubtractive";
|
||||
sStatusTip = sToolTipText;
|
||||
eType = ForEdit;
|
||||
}
|
||||
|
||||
void CmdPrimtiveCompSubtractive::activated(int iMsg)
|
||||
{
|
||||
Base::Console().Message("activated msg %i\n", iMsg);
|
||||
return;
|
||||
|
||||
// Since the default icon is reset when enabing/disabling the command we have
|
||||
// to explicitly set the icon of the used command.
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
assert(iMsg < a.size());
|
||||
pcAction->setIcon(a[iMsg]->icon());
|
||||
}
|
||||
|
||||
Gui::Action * CmdPrimtiveCompSubtractive::createAction(void)
|
||||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* p1 = pcAction->addAction(QString());
|
||||
p1->setIcon(Gui::BitmapFactory().pixmap("Part_Box"));
|
||||
QAction* p2 = pcAction->addAction(QString());
|
||||
p2->setIcon(Gui::BitmapFactory().pixmap("Part_Cylinder"));
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
|
||||
pcAction->setIcon(p1->icon());
|
||||
int defaultId = 0;
|
||||
pcAction->setProperty("defaultAction", QVariant(defaultId));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
void CmdPrimtiveCompSubtractive::languageChange()
|
||||
{
|
||||
Command::languageChange();
|
||||
|
||||
if (!_pcAction)
|
||||
return;
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
QAction* arc1 = a[0];
|
||||
arc1->setText(QApplication::translate("CmdSketcherCompCreateArc","Center and end points"));
|
||||
arc1->setToolTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points"));
|
||||
arc1->setStatusTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points"));
|
||||
QAction* arc2 = a[1];
|
||||
arc2->setText(QApplication::translate("CmdSketcherCompCreateArc","End points and rim point"));
|
||||
arc2->setToolTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc"));
|
||||
arc2->setStatusTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc"));
|
||||
}
|
||||
|
||||
bool CmdPrimtiveCompSubtractive::isActive(void)
|
||||
{
|
||||
if (getActiveGuiDocument())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Initialization
|
||||
//===========================================================================
|
||||
|
||||
void CreatePartDesignPrimitiveCommands(void)
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
|
||||
rcCmdMgr.addCommand(new CmdPrimtiveCompAdditive);
|
||||
rcCmdMgr.addCommand(new CmdPrimtiveCompSubtractive);
|
||||
}
|
93
src/Mod/PartDesign/Gui/ViewProviderPrimitive.cpp
Normal file
93
src/Mod/PartDesign/Gui/ViewProviderPrimitive.cpp
Normal file
|
@ -0,0 +1,93 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer <jrheinlaender@users.sourceforge.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 "ViewProviderPrimitive.h"
|
||||
#include <Mod/PartDesign/App/FeaturePrimitive.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderPrimitive,PartDesignGui::ViewProvider)
|
||||
|
||||
ViewProviderPrimitive::ViewProviderPrimitive()
|
||||
{
|
||||
sPixmap = "Part_Box.svg";
|
||||
}
|
||||
|
||||
ViewProviderPrimitive::~ViewProviderPrimitive()
|
||||
{
|
||||
}
|
||||
|
||||
bool ViewProviderPrimitive::setEdit(int ModNum)
|
||||
{/*
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// When double-clicking on the item for this fillet the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgBooleanParameters *booleanDlg = qobject_cast<TaskDlgBooleanParameters *>(dlg);
|
||||
if (booleanDlg && booleanDlg->getBooleanView() != this)
|
||||
booleanDlg = 0; // another pad left open its task panel
|
||||
if (dlg && !booleanDlg) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
|
||||
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
int ret = msgBox.exec();
|
||||
if (ret == QMessageBox::Yes)
|
||||
Gui::Control().closeDialog();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
// always change to PartDesign WB, remember where we come from
|
||||
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// start the edit dialog
|
||||
if (booleanDlg)
|
||||
Gui::Control().showDialog(booleanDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgBooleanParameters(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return PartGui::ViewProviderPart::setEdit(ModNum);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
49
src/Mod/PartDesign/Gui/ViewProviderPrimitive.h
Normal file
49
src/Mod/PartDesign/Gui/ViewProviderPrimitive.h
Normal 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_ViewProviderPrimitive_H
|
||||
#define PARTGUI_ViewProviderPrimitive_H
|
||||
|
||||
#include "ViewProvider.h"
|
||||
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class PartDesignGuiExport ViewProviderPrimitive : public ViewProvider
|
||||
{
|
||||
PROPERTY_HEADER(PartDesignGui::ViewProviderPrimitive);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderPrimitive();
|
||||
/// destructor
|
||||
virtual ~ViewProviderPrimitive();
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
};
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
||||
|
||||
#endif // PARTGUI_ViewProviderBoolean_H
|
|
@ -746,6 +746,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
<< "PartDesign_Pocket"
|
||||
<< "PartDesign_Revolution"
|
||||
<< "PartDesign_Groove"
|
||||
<< "PartDesign_CompPrimitiveAdditive"
|
||||
<< "PartDesign_CompPrimitiveSubtractive"
|
||||
<< "PartDesign_Fillet"
|
||||
<< "PartDesign_Chamfer"
|
||||
<< "PartDesign_Draft"
|
||||
|
|
Loading…
Reference in New Issue
Block a user