Sketcher: Extension of Copy/Array functionality to clone

=============================================================

This commit allows the user to select in advance whether he wants a simple copy or a clone.

This involves substitution of dimensional constraints in the copies by equality and parallel constraints.

Terminology change for Arrays, now it is Rectangular array
This commit is contained in:
Abdullah Tahiri 2015-08-13 15:27:24 +02:00 committed by wmayer
parent 6ea93a4a04
commit 97d551b551
12 changed files with 150 additions and 74 deletions

View File

@ -2011,7 +2011,7 @@ int SketchObject::addSymmetric(const std::vector<int> &geoIdList, int refGeoId,
return Geometry.getSize()-1; return Geometry.getSize()-1;
} }
int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3d& displacement, int csize/*=2*/, int rsize/*=1*/, int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3d& displacement, bool clone /*=false*/, int csize/*=2*/, int rsize/*=1*/,
bool constraindisplacement /*= false*/, double perpscale /*= 1.0*/) bool constraindisplacement /*= false*/, double perpscale /*= 1.0*/)
{ {
const std::vector< Part::Geometry * > &geovals = getInternalGeometry(); const std::vector< Part::Geometry * > &geovals = getInternalGeometry();
@ -2153,10 +2153,29 @@ int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3
if( (*it)->Second == Constraint::GeoUndef /*&& (*it)->Third == Constraint::GeoUndef*/) { if( (*it)->Second == Constraint::GeoUndef /*&& (*it)->Third == Constraint::GeoUndef*/) {
if( ((*it)->Type != Sketcher::DistanceX && (*it)->Type != Sketcher::DistanceY ) || if( ((*it)->Type != Sketcher::DistanceX && (*it)->Type != Sketcher::DistanceY ) ||
(*it)->FirstPos == Sketcher::none ) { // if it is not a point locking DistanceX/Y (*it)->FirstPos == Sketcher::none ) { // if it is not a point locking DistanceX/Y
Constraint *constNew = (*it)->clone(); if (((*it)->Type == Sketcher::DistanceX ||
constNew->First = geoIdMap[(*it)->First]; (*it)->Type == Sketcher::DistanceY ||
newconstrVals.push_back(constNew); (*it)->Type == Sketcher::Distance ||
(*it)->Type == Sketcher::Radius ) && clone ) {
// Distances on a single Element are mapped to equality constraints in clone mode
Constraint *constNew = (*it)->clone();
constNew->Type = Sketcher::Equal;
constNew->Second = geoIdMap[(*it)->First]; // first is already (*it->First)
newconstrVals.push_back(constNew);
}
else if ((*it)->Type == Sketcher::Angle && clone){
// Angles on a single Element are mapped to parallel constraints in clone mode
Constraint *constNew = (*it)->clone();
constNew->Type = Sketcher::Parallel;
constNew->Second = geoIdMap[(*it)->First]; // first is already (*it->First)
newconstrVals.push_back(constNew);
}
else {
Constraint *constNew = (*it)->clone();
constNew->First = geoIdMap[(*it)->First];
newconstrVals.push_back(constNew);
}
} }
} }
else { // other geoids intervene in this constraint else { // other geoids intervene in this constraint
@ -2165,10 +2184,23 @@ int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3
if(sit != geoIdList.end()) { // Second is also in the list if(sit != geoIdList.end()) { // Second is also in the list
if( (*it)->Third == Constraint::GeoUndef ) { if( (*it)->Third == Constraint::GeoUndef ) {
Constraint *constNew = (*it)->clone(); if (((*it)->Type == Sketcher::DistanceX ||
constNew->First = geoIdMap[(*it)->First]; (*it)->Type == Sketcher::DistanceY ||
constNew->Second = geoIdMap[(*it)->Second]; (*it)->Type == Sketcher::Distance) && ((*it)->First == (*it)->Second) && clone ) {
newconstrVals.push_back(constNew); // Distances on a two Elements, which must be points of the same line are mapped to equality constraints in clone mode
Constraint *constNew = (*it)->clone();
constNew->Type = Sketcher::Equal;
constNew->FirstPos = Sketcher::none;
constNew->Second = geoIdMap[(*it)->First]; // first is already (*it->First)
constNew->SecondPos = Sketcher::none;
newconstrVals.push_back(constNew);
}
else {
Constraint *constNew = (*it)->clone();
constNew->First = geoIdMap[(*it)->First];
constNew->Second = geoIdMap[(*it)->Second];
newconstrVals.push_back(constNew);
}
} }
else { else {
std::vector<int>::const_iterator tit=std::find(geoIdList.begin(), geoIdList.end(), (*it)->Third); std::vector<int>::const_iterator tit=std::find(geoIdList.begin(), geoIdList.end(), (*it)->Third);
@ -2188,7 +2220,6 @@ int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3
} }
// handle inter-geometry constraints // handle inter-geometry constraints
// example: App.ActiveDocument.Sketch.addArray([0,1], App.Vector(150,150,0),3,4,True)
if(constraindisplacement){ if(constraindisplacement){
// add a construction line // add a construction line

View File

@ -155,7 +155,7 @@ public:
/// with default parameters adds a copy of the geometric elements displaced by the displacement vector. /// with default parameters adds a copy of the geometric elements displaced by the displacement vector.
/// It creates an array of csize elements in the direction of the displacement vector by rsize elements in the /// It creates an array of csize elements in the direction of the displacement vector by rsize elements in the
/// direction perpendicular to the displacement vector, wherein the modulus of this perpendicular vector is scaled by perpscale. /// direction perpendicular to the displacement vector, wherein the modulus of this perpendicular vector is scaled by perpscale.
int addCopy(const std::vector<int> &geoIdList, const Base::Vector3d& displacement, int csize=2, int rsize=1, bool constraindisplacement = false, double perpscale = 1.0); int addCopy(const std::vector<int> &geoIdList, const Base::Vector3d& displacement, bool clone=false, int csize=2, int rsize=1, bool constraindisplacement = false, double perpscale = 1.0);
/// Exposes all internal geometry of an object supporting internal geometry /// Exposes all internal geometry of an object supporting internal geometry
/*! /*!
* \return -1 on error * \return -1 on error

View File

@ -142,7 +142,7 @@
<UserDocu>add a copy of geometric objects to the sketch displaced by a vector3d</UserDocu> <UserDocu>add a copy of geometric objects to the sketch displaced by a vector3d</UserDocu>
</Documentation> </Documentation>
</Methode> </Methode>
<Methode Name="addArray"> <Methode Name="addRectangularArray">
<Documentation> <Documentation>
<UserDocu>add an array of size cols by rows where each element is a copy of the selected geometric objects displaced by a vector3d in the cols direction and by a vector perpendicular to it in the rows direction</UserDocu> <UserDocu>add an array of size cols by rows where each element is a copy of the selected geometric objects displaced by a vector3d in the cols direction and by a vector perpendicular to it in the rows direction</UserDocu>
</Documentation> </Documentation>

View File

@ -759,6 +759,7 @@ PyObject* SketchObjectPy::addSymmetric(PyObject *args)
PyObject *pcObj; PyObject *pcObj;
int refGeoId; int refGeoId;
int refPosId = Sketcher::none; int refPosId = Sketcher::none;
if (!PyArg_ParseTuple(args, "Oi|i", &pcObj, &refGeoId, &refPosId)) if (!PyArg_ParseTuple(args, "Oi|i", &pcObj, &refGeoId, &refPosId))
return 0; return 0;
@ -795,8 +796,9 @@ PyObject* SketchObjectPy::addSymmetric(PyObject *args)
PyObject* SketchObjectPy::addCopy(PyObject *args) PyObject* SketchObjectPy::addCopy(PyObject *args)
{ {
PyObject *pcObj, *pcVect; PyObject *pcObj, *pcVect;
PyObject* clone= Py_False;
if (!PyArg_ParseTuple(args, "OO!", &pcObj, &(Base::VectorPy::Type), &pcVect)) if (!PyArg_ParseTuple(args, "OO!|O!", &pcObj, &(Base::VectorPy::Type), &pcVect, &PyBool_Type, &clone))
return 0; return 0;
Base::Vector3d vect = static_cast<Base::VectorPy*>(pcVect)->value(); Base::Vector3d vect = static_cast<Base::VectorPy*>(pcVect)->value();
@ -810,7 +812,7 @@ PyObject* SketchObjectPy::addCopy(PyObject *args)
geoIdList.push_back(PyInt_AsLong((*it).ptr())); geoIdList.push_back(PyInt_AsLong((*it).ptr()));
} }
int ret = this->getSketchObjectPtr()->addCopy(geoIdList,vect) + 1; int ret = this->getSketchObjectPtr()->addCopy(geoIdList, vect, PyObject_IsTrue(clone) ? true : false) + 1;
if(ret == -1) if(ret == -1)
throw Py::TypeError("Copy operation unsuccessful!"); throw Py::TypeError("Copy operation unsuccessful!");
@ -830,14 +832,16 @@ PyObject* SketchObjectPy::addCopy(PyObject *args)
throw Py::TypeError(error); throw Py::TypeError(error);
} }
PyObject* SketchObjectPy::addArray(PyObject *args) PyObject* SketchObjectPy::addRectangularArray(PyObject *args)
{ {
PyObject *pcObj, *pcVect; PyObject *pcObj, *pcVect;
int rows,cols; int rows,cols;
double perpscale=1.0; double perpscale=1.0;
PyObject* constraindisplacement= Py_False; PyObject* constraindisplacement= Py_False;
PyObject* clone= Py_False;
if (!PyArg_ParseTuple(args, "OO!ii|O!d", &pcObj, &(Base::VectorPy::Type), &pcVect,&rows,&cols, &PyBool_Type, &constraindisplacement,&perpscale)) if (!PyArg_ParseTuple(args, "OO!O!ii|O!d", &pcObj, &(Base::VectorPy::Type), &pcVect,
&PyBool_Type, &clone, &rows, &cols, &PyBool_Type, &constraindisplacement,&perpscale))
return 0; return 0;
Base::Vector3d vect = static_cast<Base::VectorPy*>(pcVect)->value(); Base::Vector3d vect = static_cast<Base::VectorPy*>(pcVect)->value();
@ -851,7 +855,8 @@ PyObject* SketchObjectPy::addArray(PyObject *args)
geoIdList.push_back(PyInt_AsLong((*it).ptr())); geoIdList.push_back(PyInt_AsLong((*it).ptr()));
} }
int ret = this->getSketchObjectPtr()->addCopy(geoIdList,vect,rows,cols, PyObject_IsTrue(constraindisplacement) ? true : false, perpscale) + 1; int ret = this->getSketchObjectPtr()->addCopy(geoIdList,vect, PyObject_IsTrue(clone) ? true : false,
rows, cols, PyObject_IsTrue(constraindisplacement) ? true : false, perpscale) + 1;
if(ret == -1) if(ret == -1)
throw Py::TypeError("Copy operation unsuccessful!"); throw Py::TypeError("Copy operation unsuccessful!");

View File

@ -37,7 +37,7 @@ set(SketcherGui_MOC_HDRS
TaskDlgEditSketch.h TaskDlgEditSketch.h
SketchOrientationDialog.h SketchOrientationDialog.h
SketcherSettings.h SketcherSettings.h
SketchLinearArrayDialog.h SketchRectangularArrayDialog.h
PropertyConstraintListItem.h PropertyConstraintListItem.h
) )
fc_wrap_cpp(SketcherGui_MOC_SRCS ${SketcherGui_MOC_HDRS}) fc_wrap_cpp(SketcherGui_MOC_SRCS ${SketcherGui_MOC_HDRS})
@ -55,7 +55,7 @@ set(SketcherGui_UIC_SRCS
InsertDatum.ui InsertDatum.ui
SketchOrientationDialog.ui SketchOrientationDialog.ui
SketcherSettings.ui SketcherSettings.ui
SketchLinearArrayDialog.ui SketchRectangularArrayDialog.ui
) )
qt4_wrap_ui(SketcherGui_UIC_HDRS ${SketcherGui_UIC_SRCS}) qt4_wrap_ui(SketcherGui_UIC_HDRS ${SketcherGui_UIC_SRCS})
@ -112,8 +112,8 @@ SET(SketcherGui_SRCS
SketchOrientationDialog.h SketchOrientationDialog.h
SketcherSettings.cpp SketcherSettings.cpp
SketcherSettings.h SketcherSettings.h
SketchLinearArrayDialog.h SketchRectangularArrayDialog.h
SketchLinearArrayDialog.cpp SketchRectangularArrayDialog.cpp
TaskDlgEditSketch.cpp TaskDlgEditSketch.cpp
TaskDlgEditSketch.h TaskDlgEditSketch.h
ViewProviderPython.cpp ViewProviderPython.cpp

View File

@ -28,6 +28,8 @@
# include <Precision.hxx> # include <Precision.hxx>
#endif #endif
# include <QMessageBox>
#include <Base/Console.h> #include <Base/Console.h>
#include <App/Application.h> #include <App/Application.h>
#include <Gui/Application.h> #include <Gui/Application.h>
@ -47,7 +49,7 @@
#include <Mod/Sketcher/App/SketchObject.h> #include <Mod/Sketcher/App/SketchObject.h>
#include "ViewProviderSketch.h" #include "ViewProviderSketch.h"
#include "SketchLinearArrayDialog.h" #include "SketchRectangularArrayDialog.h"
using namespace std; using namespace std;
using namespace SketcherGui; using namespace SketcherGui;
@ -1232,8 +1234,8 @@ static const char *cursor_createcopy[]={
class DrawSketchHandlerCopy: public DrawSketchHandler class DrawSketchHandlerCopy: public DrawSketchHandler
{ {
public: public:
DrawSketchHandlerCopy(string geoidlist, int origingeoid, Sketcher::PointPos originpos, int nelements): geoIdList(geoidlist), OriginGeoId (origingeoid), DrawSketchHandlerCopy(string geoidlist, int origingeoid, Sketcher::PointPos originpos, int nelements, bool clone): geoIdList(geoidlist), OriginGeoId (origingeoid),
OriginPos(originpos), nElements(nelements), Mode(STATUS_SEEK_First), EditCurve(2){} OriginPos(originpos), nElements(nelements), Clone(clone), Mode(STATUS_SEEK_First), EditCurve(2){}
virtual ~DrawSketchHandlerCopy(){} virtual ~DrawSketchHandlerCopy(){}
/// mode table /// mode table
enum SelectMode { enum SelectMode {
@ -1295,10 +1297,10 @@ static const char *cursor_createcopy[]={
try{ try{
Gui::Command::doCommand( Gui::Command::doCommand(
Gui::Command::Doc, "App.ActiveDocument.%s.addCopy(%s,App.Vector(%f,%f,0))", Gui::Command::Doc, "App.ActiveDocument.%s.addCopy(%s,App.Vector(%f,%f,0),%s)",
sketchgui->getObject()->getNameInDocument(), sketchgui->getObject()->getNameInDocument(),
geoIdList.c_str(), vector.fX, vector.fY geoIdList.c_str(), vector.fX, vector.fY,
); (Clone?"True":"False"));
Gui::Command::commitCommand(); Gui::Command::commitCommand();
} }
@ -1332,6 +1334,7 @@ static const char *cursor_createcopy[]={
int OriginGeoId; int OriginGeoId;
Sketcher::PointPos OriginPos; Sketcher::PointPos OriginPos;
int nElements; int nElements;
bool Clone;
std::vector<Base::Vector2D> EditCurve; std::vector<Base::Vector2D> EditCurve;
std::vector<AutoConstraint> sugConstr1; std::vector<AutoConstraint> sugConstr1;
}; };
@ -1455,7 +1458,22 @@ void CmdSketcherCopy::activated(int iMsg)
} }
} }
ActivateAcceleratorHandler(getActiveGuiDocument(),new DrawSketchHandlerCopy(geoIdList, LastGeoId, LastPointPos, geoids)); bool clone=false;
// Ask the user if he wants to clone or to simple copy
int ret = QMessageBox::question(Gui::getMainWindow(), QObject::tr("Dimensional/Geometric constraints"),
QObject::tr("Do you want to clone the object, i.e. substitute dimensional constraints by geometric constraints?"),
QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
// use an equality constraint
if (ret == QMessageBox::Yes) {
clone = true;
}
else if (ret == QMessageBox::Cancel) {
// do nothing
return;
}
ActivateAcceleratorHandler(getActiveGuiDocument(),new DrawSketchHandlerCopy(geoIdList, LastGeoId, LastPointPos, geoids, clone));
} }
@ -1466,7 +1484,7 @@ bool CmdSketcherCopy::isActive(void)
} }
/* XPM */ /* XPM */
static const char *cursor_createlineararray[]={ static const char *cursor_createrectangulararray[]={
"32 32 3 1", "32 32 3 1",
"+ c white", "+ c white",
"# c red", "# c red",
@ -1504,15 +1522,15 @@ static const char *cursor_createlineararray[]={
"................................", "................................",
"................................"}; "................................"};
class DrawSketchHandlerLinearArray: public DrawSketchHandler class DrawSketchHandlerRectangularArray: public DrawSketchHandler
{ {
public: public:
DrawSketchHandlerLinearArray(string geoidlist, int origingeoid, Sketcher::PointPos originpos, int nelements, DrawSketchHandlerRectangularArray(string geoidlist, int origingeoid, Sketcher::PointPos originpos, int nelements, bool clone,
int rows,int cols,bool constraintSeparation, int rows, int cols, bool constraintSeparation,
bool equalVerticalHorizontalSpacing ): geoIdList(geoidlist), OriginGeoId (origingeoid), bool equalVerticalHorizontalSpacing ): geoIdList(geoidlist), OriginGeoId (origingeoid), Clone(clone),
Rows(rows), Cols(cols), ConstraintSeparation(constraintSeparation), EqualVerticalHorizontalSpacing(equalVerticalHorizontalSpacing), Rows(rows), Cols(cols), ConstraintSeparation(constraintSeparation), EqualVerticalHorizontalSpacing(equalVerticalHorizontalSpacing),
OriginPos(originpos), nElements(nelements), Mode(STATUS_SEEK_First), EditCurve(2){} OriginPos(originpos), nElements(nelements), Mode(STATUS_SEEK_First), EditCurve(2){}
virtual ~DrawSketchHandlerLinearArray(){} virtual ~DrawSketchHandlerRectangularArray(){}
/// mode table /// mode table
enum SelectMode { enum SelectMode {
STATUS_SEEK_First, /**< enum value ----. */ STATUS_SEEK_First, /**< enum value ----. */
@ -1521,7 +1539,7 @@ static const char *cursor_createlineararray[]={
virtual void activated(ViewProviderSketch *sketchgui) virtual void activated(ViewProviderSketch *sketchgui)
{ {
setCursor(QPixmap(cursor_createlineararray),7,7); setCursor(QPixmap(cursor_createrectangulararray),7,7);
Origin = static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->getPoint(OriginGeoId, OriginPos); Origin = static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->getPoint(OriginGeoId, OriginPos);
EditCurve[0] = Base::Vector2D(Origin.x,Origin.y); EditCurve[0] = Base::Vector2D(Origin.x,Origin.y);
} }
@ -1573,9 +1591,10 @@ static const char *cursor_createlineararray[]={
try{ try{
Gui::Command::doCommand( Gui::Command::doCommand(
Gui::Command::Doc, "App.ActiveDocument.%s.addArray(%s, App.Vector(%f,%f,0),%d,%d,%s,%f)", Gui::Command::Doc, "App.ActiveDocument.%s.addRectangularArray(%s, App.Vector(%f,%f,0),%s,%d,%d,%s,%f)",
sketchgui->getObject()->getNameInDocument(), sketchgui->getObject()->getNameInDocument(),
geoIdList.c_str(), vector.fX, vector.fY, geoIdList.c_str(), vector.fX, vector.fY,
(Clone?"True":"False"),
Cols, Rows, Cols, Rows,
(ConstraintSeparation?"True":"False"), (ConstraintSeparation?"True":"False"),
(EqualVerticalHorizontalSpacing?1.0:0.5)); (EqualVerticalHorizontalSpacing?1.0:0.5));
@ -1612,6 +1631,7 @@ static const char *cursor_createlineararray[]={
int OriginGeoId; int OriginGeoId;
Sketcher::PointPos OriginPos; Sketcher::PointPos OriginPos;
int nElements; int nElements;
bool Clone;
int Rows; int Rows;
int Cols; int Cols;
bool ConstraintSeparation; bool ConstraintSeparation;
@ -1621,23 +1641,23 @@ static const char *cursor_createlineararray[]={
}; };
DEF_STD_CMD_A(CmdSketcherLinearArray); DEF_STD_CMD_A(CmdSketcherRectangularArray);
CmdSketcherLinearArray::CmdSketcherLinearArray() CmdSketcherRectangularArray::CmdSketcherRectangularArray()
:Command("Sketcher_LinearArray") :Command("Sketcher_RectangularArray")
{ {
sAppModule = "Sketcher"; sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher"); sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("LinearArray"); sMenuText = QT_TR_NOOP("Rectangular Array");
sToolTipText = QT_TR_NOOP("Creates a lineararray of the geometry taking as reference the last selected point"); sToolTipText = QT_TR_NOOP("Creates an rectangular array pattern of the geometry taking as reference the last selected point");
sWhatsThis = sToolTipText; sWhatsThis = sToolTipText;
sStatusTip = sToolTipText; sStatusTip = sToolTipText;
sPixmap = "Sketcher_LinearArray"; sPixmap = "Sketcher_RectangularArray";
sAccel = ""; sAccel = "";
eType = ForEdit; eType = ForEdit;
} }
void CmdSketcherLinearArray::activated(int iMsg) void CmdSketcherRectangularArray::activated(int iMsg)
{ {
// get the selection // get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx(); std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
@ -1741,11 +1761,11 @@ void CmdSketcherLinearArray::activated(int iMsg)
} }
// Pop-up asking for values // Pop-up asking for values
SketchLinearArrayDialog * slad = new SketchLinearArrayDialog(); SketchRectangularArrayDialog * slad = new SketchRectangularArrayDialog();
if( slad->exec() == QDialog::Accepted ) if( slad->exec() == QDialog::Accepted )
ActivateAcceleratorHandler(getActiveGuiDocument(), ActivateAcceleratorHandler(getActiveGuiDocument(),
new DrawSketchHandlerLinearArray(geoIdList, LastGeoId, LastPointPos, geoids, new DrawSketchHandlerRectangularArray(geoIdList, LastGeoId, LastPointPos, geoids, slad->Clone,
slad->Rows, slad->Cols, slad->ConstraintSeparation, slad->Rows, slad->Cols, slad->ConstraintSeparation,
slad->EqualVerticalHorizontalSpacing)); slad->EqualVerticalHorizontalSpacing));
@ -1755,7 +1775,7 @@ void CmdSketcherLinearArray::activated(int iMsg)
bool CmdSketcherLinearArray::isActive(void) bool CmdSketcherRectangularArray::isActive(void)
{ {
return isSketcherAcceleratorActive( getActiveGuiDocument(), true ); return isSketcherAcceleratorActive( getActiveGuiDocument(), true );
} }
@ -1776,5 +1796,5 @@ void CreateSketcherCommandsConstraintAccel(void)
rcCmdMgr.addCommand(new CmdSketcherRestoreInternalAlignmentGeometry()); rcCmdMgr.addCommand(new CmdSketcherRestoreInternalAlignmentGeometry());
rcCmdMgr.addCommand(new CmdSketcherSymmetry()); rcCmdMgr.addCommand(new CmdSketcherSymmetry());
rcCmdMgr.addCommand(new CmdSketcherCopy()); rcCmdMgr.addCommand(new CmdSketcherCopy());
rcCmdMgr.addCommand(new CmdSketcherLinearArray()); rcCmdMgr.addCommand(new CmdSketcherRectangularArray());
} }

View File

@ -118,11 +118,11 @@
<file>icons/Sketcher_Elliptical_Arc_Constr.svg</file> <file>icons/Sketcher_Elliptical_Arc_Constr.svg</file>
<file>icons/Sketcher_External.svg</file> <file>icons/Sketcher_External.svg</file>
<file>icons/Sketcher_LeaveSketch.svg</file> <file>icons/Sketcher_LeaveSketch.svg</file>
<file>icons/Sketcher_LinearArray.svg</file>
<file>icons/Sketcher_MapSketch.svg</file> <file>icons/Sketcher_MapSketch.svg</file>
<file>icons/Sketcher_MergeSketch.svg</file> <file>icons/Sketcher_MergeSketch.svg</file>
<file>icons/Sketcher_NewSketch.svg</file> <file>icons/Sketcher_NewSketch.svg</file>
<file>icons/Sketcher_ProfilesHexagon1.svg</file> <file>icons/Sketcher_ProfilesHexagon1.svg</file>
<file>icons/Sketcher_RectangularArray.svg</file>
<file>icons/Sketcher_SelectConflictingConstraints.svg</file> <file>icons/Sketcher_SelectConflictingConstraints.svg</file>
<file>icons/Sketcher_SelectConstraints.svg</file> <file>icons/Sketcher_SelectConstraints.svg</file>
<file>icons/Sketcher_SelectElementsAssociatedWithConstraints.svg</file> <file>icons/Sketcher_SelectElementsAssociatedWithConstraints.svg</file>

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -32,13 +32,13 @@
#include <Base/Tools.h> #include <Base/Tools.h>
#include <Base/UnitsApi.h> #include <Base/UnitsApi.h>
#include "ui_SketchLinearArrayDialog.h" #include "ui_SketchRectangularArrayDialog.h"
#include "SketchLinearArrayDialog.h" #include "SketchRectangularArrayDialog.h"
using namespace SketcherGui; using namespace SketcherGui;
SketchLinearArrayDialog::SketchLinearArrayDialog(void) SketchRectangularArrayDialog::SketchRectangularArrayDialog(void)
: QDialog(Gui::getMainWindow()), ui(new Ui_SketchLinearArrayDialog) : QDialog(Gui::getMainWindow()), ui(new Ui_SketchRectangularArrayDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -46,33 +46,36 @@ SketchLinearArrayDialog::SketchLinearArrayDialog(void)
ui->ColsQuantitySpinBox->onRestore(); ui->ColsQuantitySpinBox->onRestore();
ui->ConstraintSeparationCheckBox->onRestore(); ui->ConstraintSeparationCheckBox->onRestore();
ui->EqualVerticalHorizontalSpacingCheckBox->onRestore(); ui->EqualVerticalHorizontalSpacingCheckBox->onRestore();
ui->CloneCheckBox->onRestore();
updateValues(); updateValues();
} }
SketchLinearArrayDialog::~SketchLinearArrayDialog() SketchRectangularArrayDialog::~SketchRectangularArrayDialog()
{ {
} }
void SketchLinearArrayDialog::accept() void SketchRectangularArrayDialog::accept()
{ {
ui->RowsQuantitySpinBox->onSave(); ui->RowsQuantitySpinBox->onSave();
ui->ColsQuantitySpinBox->onSave(); ui->ColsQuantitySpinBox->onSave();
ui->ConstraintSeparationCheckBox->onSave(); ui->ConstraintSeparationCheckBox->onSave();
ui->EqualVerticalHorizontalSpacingCheckBox->onSave(); ui->EqualVerticalHorizontalSpacingCheckBox->onSave();
ui->CloneCheckBox->onSave();
updateValues(); updateValues();
QDialog::accept(); QDialog::accept();
} }
void SketchLinearArrayDialog::updateValues(void) void SketchRectangularArrayDialog::updateValues(void)
{ {
Rows = ui->RowsQuantitySpinBox->value(); Rows = ui->RowsQuantitySpinBox->value();
Cols = ui->ColsQuantitySpinBox->value(); Cols = ui->ColsQuantitySpinBox->value();
ConstraintSeparation = ui->ConstraintSeparationCheckBox->isChecked(); ConstraintSeparation = ui->ConstraintSeparationCheckBox->isChecked();
EqualVerticalHorizontalSpacing = ui->EqualVerticalHorizontalSpacingCheckBox->isChecked(); EqualVerticalHorizontalSpacing = ui->EqualVerticalHorizontalSpacingCheckBox->isChecked();
Clone = ui->CloneCheckBox->isChecked();
} }
#include "moc_SketchLinearArrayDialog.cpp" #include "moc_SketchRectangularArrayDialog.cpp"

View File

@ -20,36 +20,37 @@
* * * *
***************************************************************************/ ***************************************************************************/
#ifndef SKETCHERGUI_SketchLinearArrayDialog_H #ifndef SKETCHERGUI_SketchRectangularArrayDialog_H
#define SKETCHERGUI_SketchLinearArrayDialog_H #define SKETCHERGUI_SketchRectangularArrayDialog_H
#include <Base/Placement.h> #include <Base/Placement.h>
#include <QDialog> #include <QDialog>
namespace SketcherGui { namespace SketcherGui {
class Ui_SketchLinearArrayDialog; class Ui_SketchRectangularArrayDialog;
class SketchLinearArrayDialog : public QDialog class SketchRectangularArrayDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SketchLinearArrayDialog(void); SketchRectangularArrayDialog(void);
~SketchLinearArrayDialog(); ~SketchRectangularArrayDialog();
void accept(); void accept();
int Rows; int Rows;
int Cols; int Cols;
bool ConstraintSeparation; bool ConstraintSeparation;
bool EqualVerticalHorizontalSpacing; bool EqualVerticalHorizontalSpacing;
bool Clone;
protected: protected:
void updateValues(void); void updateValues(void);
private: private:
Ui_SketchLinearArrayDialog* ui; Ui_SketchRectangularArrayDialog* ui;
}; };
} }
#endif // SKETCHERGUI_SketchLinearArrayDialog_H #endif // SKETCHERGUI_SketchRectangularArrayDialog_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>SketcherGui::SketchLinearArrayDialog</class> <class>SketcherGui::SketchRectangularArrayDialog</class>
<widget class="QDialog" name="SketcherGui::SketchLinearArrayDialog"> <widget class="QDialog" name="SketcherGui::SketchRectangularArrayDialog">
<property name="windowModality"> <property name="windowModality">
<enum>Qt::ApplicationModal</enum> <enum>Qt::ApplicationModal</enum>
</property> </property>
@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>287</width> <width>287</width>
<height>177</height> <height>205</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -109,6 +109,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="Gui::PrefCheckBox" name="CloneCheckBox">
<property name="toolTip">
<string>If checked it substitutes dimensional constraints by geometric constraints in the copies, so that a change in the original element is directly reflected on copies</string>
</property>
<property name="text">
<string>Clone</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>CloneOnCopy</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@ -154,7 +170,7 @@
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>SketcherGui::SketchLinearArrayDialog</receiver> <receiver>SketcherGui::SketchRectangularArrayDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
@ -170,7 +186,7 @@
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>SketcherGui::SketchLinearArrayDialog</receiver> <receiver>SketcherGui::SketchRectangularArrayDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">

View File

@ -248,7 +248,7 @@ inline void SketcherAddWorkbenchTools<Gui::MenuItem>(Gui::MenuItem& consaccel){
<< "Sketcher_RestoreInternalAlignmentGeometry" << "Sketcher_RestoreInternalAlignmentGeometry"
<< "Sketcher_Symmetry" << "Sketcher_Symmetry"
<< "Sketcher_Copy" << "Sketcher_Copy"
<< "Sketcher_LinearArray"; << "Sketcher_RectangularArray";
} }
template <> template <>
@ -259,7 +259,7 @@ inline void SketcherAddWorkbenchTools<Gui::ToolBarItem>(Gui::ToolBarItem& consac
<< "Sketcher_RestoreInternalAlignmentGeometry" << "Sketcher_RestoreInternalAlignmentGeometry"
<< "Sketcher_Symmetry" << "Sketcher_Symmetry"
<< "Sketcher_Copy" << "Sketcher_Copy"
<< "Sketcher_LinearArray"; << "Sketcher_RectangularArray";
} }
template <typename T> template <typename T>