replace hard coded numbers with static constants

This commit is contained in:
wmayer 2016-10-23 13:44:26 +02:00
parent d259aa0784
commit 222e9b6b46
8 changed files with 83 additions and 74 deletions

View File

@ -52,7 +52,7 @@
# include <Standard_Version.hxx>
# include <cmath>
# include <vector>
#endif // #ifndef _PreComp_
#endif
#include <boost/bind.hpp>
@ -72,8 +72,8 @@
#include <Mod/Part/App/BodyBase.h>
#include "SketchObject.h"
#include "SketchObjectPy.h"
#include "Sketch.h"
#include <Mod/Sketcher/App/SketchObjectPy.h>
using namespace Sketcher;
using namespace Base;
@ -760,8 +760,8 @@ int SketchObject::delConstraintOnPoint(int VertexId, bool onlyCoincident)
{
int GeoId;
PointPos PosId;
if (VertexId == -1) { // RootPoint
GeoId = -1;
if (VertexId == GeoEnum::RtPnt) { // RootPoint
GeoId = Sketcher::GeoEnum::RtPnt;
PosId = start;
} else
getGeoVertexIndex(VertexId, GeoId, PosId);
@ -2839,7 +2839,7 @@ int SketchObject::delExternal(int ExtGeoId)
const std::vector< Constraint * > &constraints = Constraints.getValues();
std::vector< Constraint * > newConstraints(0);
int GeoId = -3 - ExtGeoId;
int GeoId = GeoEnum::RefExt - ExtGeoId;
for (std::vector<Constraint *>::const_iterator it = constraints.begin();
it != constraints.end(); ++it) {
if ((*it)->First != GeoId && (*it)->Second != GeoId && (*it)->Third != GeoId) {
@ -2893,9 +2893,9 @@ int SketchObject::delAllExternal()
std::vector< Constraint * > newConstraints(0);
for (std::vector<Constraint *>::const_iterator it = constraints.begin(); it != constraints.end(); ++it) {
if ((*it)->First > -3 &&
((*it)->Second > -3 || (*it)->Second == Constraint::GeoUndef ) &&
((*it)->Third > -3 || (*it)->Third == Constraint::GeoUndef) ) {
if ((*it)->First > GeoEnum::RefExt &&
((*it)->Second > GeoEnum::RefExt || (*it)->Second == Constraint::GeoUndef ) &&
((*it)->Third > GeoEnum::RefExt || (*it)->Third == Constraint::GeoUndef) ) {
Constraint *copiedConstr = (*it)->clone();
newConstraints.push_back(copiedConstr);
@ -2924,7 +2924,7 @@ int SketchObject::delConstraintsToExternal()
{
const std::vector< Constraint * > &constraints = Constraints.getValuesForce();
std::vector< Constraint * > newConstraints(0);
int GeoId = -3, NullId = -2000;
int GeoId = GeoEnum::RefExt, NullId = Constraint::GeoUndef;
for (std::vector<Constraint *>::const_iterator it = constraints.begin();
it != constraints.end(); ++it) {
if ( (*it)->First > GeoId
@ -3042,7 +3042,7 @@ void SketchObject::validateExternalLinks(void)
const std::vector< Constraint * > &constraints = Constraints.getValues();
std::vector< Constraint * > newConstraints(0);
int GeoId = -3 - i;
int GeoId = GeoEnum::RefExt - i;
for (std::vector<Constraint *>::const_iterator it = constraints.begin();
it != constraints.end(); ++it) {
if ((*it)->First != GeoId && (*it)->Second != GeoId && (*it)->Third != GeoId) {
@ -4085,7 +4085,7 @@ int SketchObject::port_reversedExternalArcs(bool justAnalyze)
case 3: geoId=newVals[ic]->Third; posId = newVals[ic]->ThirdPos; break;
}
if ( geoId <= -3 &&
if ( geoId <= GeoEnum::RefExt &&
(posId==Sketcher::start || posId==Sketcher::end)){
//we are dealing with a link to an endpoint of external geom
Part::Geometry* g = this->ExternalGeo[-geoId-1];

View File

@ -38,6 +38,14 @@
namespace Sketcher
{
struct GeoEnum
{
static const int RtPnt = -1;
static const int HAxis = -1;
static const int VAxis = -2;
static const int RefExt = -3;
};
class SketcherExport SketchObject : public Part::Part2DObject
{
PROPERTY_HEADER(Sketcher::SketchObject);

View File

@ -747,14 +747,14 @@ void CmdSketcherMirrorSketch::activated(int iMsg)
std::vector<Part::Geometry *> mirrorgeo (tempgeo.begin()+addedGeometries+1,tempgeo.end());
std::vector<Sketcher::Constraint *> mirrorconstr (tempconstr.begin()+addedConstraints+1,tempconstr.end());
for(std::vector<Sketcher::Constraint *>::const_iterator itc=mirrorconstr.begin(); itc != mirrorconstr.end(); ++itc) {
for (std::vector<Sketcher::Constraint *>::const_iterator itc=mirrorconstr.begin(); itc != mirrorconstr.end(); ++itc) {
if((*itc)->First!=Sketcher::Constraint::GeoUndef || (*itc)->First==-1 || (*itc)->First==-2) // not x, y axes or origin
if ((*itc)->First!=Sketcher::Constraint::GeoUndef || (*itc)->First==Sketcher::GeoEnum::HAxis || (*itc)->First==Sketcher::GeoEnum::VAxis) // not x, y axes or origin
(*itc)->First-=(addedGeometries+1);
if((*itc)->Second!=Sketcher::Constraint::GeoUndef || (*itc)->Second==-1 || (*itc)->Second==-2) // not x, y axes or origin
if ((*itc)->Second!=Sketcher::Constraint::GeoUndef || (*itc)->Second==Sketcher::GeoEnum::HAxis || (*itc)->Second==Sketcher::GeoEnum::VAxis) // not x, y axes or origin
(*itc)->Second-=(addedGeometries+1);
if((*itc)->Third!=Sketcher::Constraint::GeoUndef || (*itc)->Third==-1 || (*itc)->Third==-2) // not x, y axes or origin
if ((*itc)->Third!=Sketcher::Constraint::GeoUndef || (*itc)->Third==Sketcher::GeoEnum::HAxis || (*itc)->Third==Sketcher::GeoEnum::VAxis) // not x, y axes or origin
(*itc)->Third-=(addedGeometries+1);
}
@ -818,14 +818,14 @@ void CmdSketcherMergeSketches::activated(int iMsg)
int addedConstraints=mergesketch->addConstraints(Obj->Constraints.getValues());
for(int i=0; i<=(addedConstraints-baseConstraints); i++){
for (int i=0; i<=(addedConstraints-baseConstraints); i++){
Sketcher::Constraint * constraint= mergesketch->Constraints.getValues()[i+baseConstraints];
if(constraint->First!=Sketcher::Constraint::GeoUndef || constraint->First==-1 || constraint->First==-2) // not x, y axes or origin
if (constraint->First!=Sketcher::Constraint::GeoUndef || constraint->First==Sketcher::GeoEnum::HAxis || constraint->First==Sketcher::GeoEnum::VAxis) // not x, y axes or origin
constraint->First+=baseGeometry;
if(constraint->Second!=Sketcher::Constraint::GeoUndef || constraint->Second==-1 || constraint->Second==-2) // not x, y axes or origin
if (constraint->Second!=Sketcher::Constraint::GeoUndef || constraint->Second==Sketcher::GeoEnum::HAxis || constraint->Second==Sketcher::GeoEnum::VAxis) // not x, y axes or origin
constraint->Second+=baseGeometry;
if(constraint->Third!=Sketcher::Constraint::GeoUndef || constraint->Third==-1 || constraint->Third==-2) // not x, y axes or origin
if (constraint->Third!=Sketcher::Constraint::GeoUndef || constraint->Third==Sketcher::GeoEnum::HAxis || constraint->Third==Sketcher::GeoEnum::VAxis) // not x, y axes or origin
constraint->Third+=baseGeometry;
}

View File

@ -259,15 +259,15 @@ void getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj,
GeoId = std::atoi(name.substr(4,4000).c_str()) - 1;
}
else if (name.size() == 9 && name.substr(0,9) == "RootPoint") {
GeoId = -1;
GeoId = Sketcher::GeoEnum::RtPnt;
PosId = Sketcher::start;
}
else if (name.size() == 6 && name.substr(0,6) == "H_Axis")
GeoId = -1;
GeoId = Sketcher::GeoEnum::HAxis;
else if (name.size() == 6 && name.substr(0,6) == "V_Axis")
GeoId = -2;
GeoId = Sketcher::GeoEnum::VAxis;
else if (name.size() > 12 && name.substr(0,12) == "ExternalEdge")
GeoId = -2 - std::atoi(name.substr(12,4000).c_str());
GeoId = Sketcher::GeoEnum::RefExt + 1 - std::atoi(name.substr(12,4000).c_str());
else if (name.size() > 6 && name.substr(0,6) == "Vertex") {
int VtId = std::atoi(name.substr(6,4000).c_str()) - 1;
Obj->getGeoVertexIndex(VtId,GeoId,PosId);
@ -286,7 +286,7 @@ bool inline isEdge(int GeoId, PointPos PosId)
bool isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, PointPos PosId)
{
if (PosId == Sketcher::start && (GeoId == -1 || GeoId == -2))
if (PosId == Sketcher::start && (GeoId == Sketcher::GeoEnum::HAxis || GeoId == Sketcher::GeoEnum::VAxis))
return true;
const Part::Geometry *geo = Obj->getGeometry(GeoId);
if (geo->getTypeId() == Part::GeomPoint::getClassTypeId())
@ -781,7 +781,7 @@ void CmdSketcherConstrainLock::activated(int iMsg)
Sketcher::PointPos PosId;
getIdsFromName(SubNames[0], Obj, GeoId, PosId);
if (isEdge(GeoId,PosId) || (GeoId < 0 && GeoId >= -2)) {
if (isEdge(GeoId,PosId) || (GeoId < 0 && GeoId >= Sketcher::GeoEnum::VAxis)) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select one vertex from the sketch other than the origin."));
return;
@ -798,7 +798,7 @@ void CmdSketcherConstrainLock::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%f)) ",
selection[0].getFeatName(),GeoId,PosId,pnt.y);
if (GeoId < -2 || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
if (GeoId <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
const std::vector<Sketcher::Constraint *> &ConStr = Obj->Constraints.getValues();
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)",
@ -981,24 +981,24 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
bool bothexternal=checkBothExternal(GeoId1, GeoId2);
if (isVertex(GeoId1,PosId1) && (GeoId2 == -2 || GeoId2 == -1)) {
if (isVertex(GeoId1,PosId1) && (GeoId2 == Sketcher::GeoEnum::VAxis || GeoId2 == Sketcher::GeoEnum::HAxis)) {
std::swap(GeoId1,GeoId2);
std::swap(PosId1,PosId2);
}
if ((isVertex(GeoId1,PosId1) || GeoId1 == -2 || GeoId1 == -1) &&
if ((isVertex(GeoId1,PosId1) || GeoId1 == Sketcher::GeoEnum::VAxis || GeoId1 == Sketcher::GeoEnum::HAxis) &&
isVertex(GeoId2,PosId2)) { // point to point distance
Base::Vector3d pnt2 = Obj->getPoint(GeoId2,PosId2);
if (GeoId1 == -1 && PosId1 == Sketcher::none) {
if (GeoId1 == Sketcher::GeoEnum::HAxis && PosId1 == Sketcher::none) {
PosId1 = Sketcher::start;
openCommand("add distance from horizontal axis constraint");
Gui::Command::doCommand(
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ",
selection[0].getFeatName(),GeoId1,PosId1,GeoId2,PosId2,pnt2.y);
}
else if (GeoId1 == -2 && PosId1 == Sketcher::none) {
else if (GeoId1 == Sketcher::GeoEnum::VAxis && PosId1 == Sketcher::none) {
PosId1 = Sketcher::start;
openCommand("add distance from vertical axis constraint");
Gui::Command::doCommand(
@ -1060,7 +1060,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
}
}
else if (isEdge(GeoId1,PosId1)) { // line length
if (GeoId1 < 0 && GeoId1 >= -2) {
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a length constraint on an axis!"));
return;
@ -1077,7 +1077,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Distance',%d,%f)) ",
selection[0].getFeatName(),GeoId1,ActLength);
if (GeoId1 < -2 || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
const std::vector<Sketcher::Constraint *> &ConStr = Obj->Constraints.getValues();
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)",
@ -1250,20 +1250,20 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
bool bothexternal=checkBothExternal(GeoId1, GeoId2);
if (GeoId2 == -1 || GeoId2 == -2) {
if (GeoId2 == Sketcher::GeoEnum::HAxis || GeoId2 == Sketcher::GeoEnum::VAxis) {
std::swap(GeoId1,GeoId2);
std::swap(PosId1,PosId2);
}
if (GeoId1 == -1 && PosId1 == Sketcher::none) // reject horizontal axis from selection
if (GeoId1 == Sketcher::GeoEnum::HAxis && PosId1 == Sketcher::none) // reject horizontal axis from selection
GeoId1 = Constraint::GeoUndef;
else if (GeoId1 == -2 && PosId1 == Sketcher::none) {
GeoId1 = -1;
else if (GeoId1 == Sketcher::GeoEnum::VAxis && PosId1 == Sketcher::none) {
GeoId1 = Sketcher::GeoEnum::HAxis;
PosId1 = Sketcher::start;
}
if (isEdge(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) { // horizontal length of a line
if (GeoId1 < 0 && GeoId1 >= -2) {
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a horizontal length constraint on an axis!"));
return;
@ -1310,7 +1310,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
}
else if (isVertex(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) { // point on fixed x-coordinate
if (GeoId1 < 0 && GeoId1 >= -2) {
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a fixed x-coordinate constraint on the root point!"));
return;
@ -1324,7 +1324,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%f)) ",
selection[0].getFeatName(),GeoId1,PosId1,ActX);
if (GeoId1 < -2 || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
const std::vector<Sketcher::Constraint *> &ConStr = Obj->Constraints.getValues();
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)",
@ -1409,18 +1409,18 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
bool bothexternal=checkBothExternal(GeoId1, GeoId2);
if (GeoId2 == -1 || GeoId2 == -2) {
if (GeoId2 == Sketcher::GeoEnum::HAxis || GeoId2 == Sketcher::GeoEnum::VAxis) {
std::swap(GeoId1,GeoId2);
std::swap(PosId1,PosId2);
}
if (GeoId1 == -2 && PosId1 == Sketcher::none) // reject vertical axis from selection
if (GeoId1 == Sketcher::GeoEnum::VAxis && PosId1 == Sketcher::none) // reject vertical axis from selection
GeoId1 = Constraint::GeoUndef;
else if (GeoId1 == -1 && PosId1 == Sketcher::none)
else if (GeoId1 == Sketcher::GeoEnum::HAxis && PosId1 == Sketcher::none)
PosId1 = Sketcher::start;
if (isEdge(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) { // vertical length of a line
if (GeoId1 < 0 && GeoId1 >= -2) {
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a vertical length constraint on an axis!"));
return;
@ -1468,7 +1468,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
}
else if (isVertex(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) { // point on fixed y-coordinate
if (GeoId1 < 0 && GeoId1 >= -2) {
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a fixed y-coordinate constraint on the root point!"));
return;
@ -1482,7 +1482,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%f)) ",
selection[0].getFeatName(),GeoId1,PosId1,ActY);
if (GeoId1 < -2 || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
const std::vector<Sketcher::Constraint *> &ConStr = Obj->Constraints.getValues();
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)",
@ -2715,7 +2715,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
return;
}
} else if (isEdge(GeoId1,PosId1)) { // line angle
if (GeoId1 < 0 && GeoId1 >= -2) {
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add an angle constraint on an axis!"));
return;
@ -2733,7 +2733,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Angle',%d,%f)) ",
selection[0].getFeatName(),GeoId1,ActAngle);
if (GeoId1 < -2 || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
const std::vector<Sketcher::Constraint *> &ConStr = Obj->Constraints.getValues();
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)",
@ -2757,7 +2757,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Angle',%d,%f)) ",
selection[0].getFeatName(),GeoId1,angle);
if (GeoId1 < -2 || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving
const std::vector<Sketcher::Constraint *> &ConStr = Obj->Constraints.getValues();
Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)",
@ -2852,7 +2852,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
return;
}
else if (GeoId < 0) {
if (GeoId == -1 || GeoId == -2) {
if (GeoId == Sketcher::GeoEnum::HAxis || GeoId == Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Sketch axes cannot be used in equality constraints"));
return;
@ -3290,7 +3290,7 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg)
getIdsFromName(*it, Obj, GeoId, PosId);
if (GeoId < 0) {
if (GeoId == -1 || GeoId == -2) {
if (GeoId == Sketcher::GeoEnum::HAxis || GeoId == Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Sketch axes cannot be used in internal alignment constraint"));
return;

View File

@ -1101,21 +1101,21 @@ void CmdSketcherSymmetry::activated(int iMsg)
}
// check if last selected element is horizontal axis
else if(SubNames.rbegin()->size() == 6 && SubNames.rbegin()->substr(0,6) == "H_Axis"){
LastGeoId = -1;
LastGeoId = Sketcher::GeoEnum::HAxis;
LastPointPos = Sketcher::none;
lastgeotype = line;
lastvertexoraxis=true;
}
// check if last selected element is vertical axis
else if(SubNames.rbegin()->size() == 6 && SubNames.rbegin()->substr(0,6) == "V_Axis"){
LastGeoId = -2;
LastGeoId = Sketcher::GeoEnum::VAxis;
LastPointPos = Sketcher::none;
lastgeotype = line;
lastvertexoraxis=true;
}
// check if last selected element is the root point
else if(SubNames.rbegin()->size() == 9 && SubNames.rbegin()->substr(0,9) == "RootPoint"){
LastGeoId = -1;
LastGeoId = Sketcher::GeoEnum::RtPnt;
LastPointPos = Sketcher::start;
lastgeotype = point;
lastvertexoraxis=true;

View File

@ -162,16 +162,16 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
}
else if (preSelCrs == 0) { // root point
GeoId = -1;
GeoId = Sketcher::GeoEnum::RtPnt;
PosId = Sketcher::start;
}
else if (preSelCrs == 1){ // x axis
GeoId = -1;
GeoId = Sketcher::GeoEnum::HAxis;
hitShapeDir = Base::Vector3d(1,0,0);
}
else if (preSelCrs == 2){ // y axis
GeoId = -2;
GeoId = Sketcher::GeoEnum::VAxis;
hitShapeDir = Base::Vector3d(0,1,0);
}
@ -196,7 +196,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
// the angle between the line and the hitting direction are over around 6 degrees (it is substantially parallel)
// or if it is an sketch axis (that can not move to accomodate to the shape), then only if it is around 6 degrees with the normal (around 84 degrees)
if (fabs(cosangle) < 0.995f || ((GeoId==-1 || GeoId==-2) && fabs(cosangle) < 0.1))
if (fabs(cosangle) < 0.995f || ((GeoId==Sketcher::GeoEnum::HAxis || GeoId==Sketcher::GeoEnum::VAxis) && fabs(cosangle) < 0.1))
suggestedConstraints.push_back(constr);

View File

@ -34,6 +34,7 @@
#include "ui_SketchMirrorDialog.h"
#include "SketchMirrorDialog.h"
#include <Mod/Sketcher/App/SketchObject.h>
using namespace SketcherGui;
@ -54,15 +55,15 @@ SketchMirrorDialog::~SketchMirrorDialog()
void SketchMirrorDialog::accept()
{
if (ui->XAxisRadioButton->isChecked()) {
RefGeoid=-1;
RefGeoid=Sketcher::GeoEnum::HAxis;
RefPosid=Sketcher::none;
}
else if (ui->YAxisRadioButton->isChecked()) {
RefGeoid=-2;
RefGeoid=Sketcher::GeoEnum::VAxis;
RefPosid=Sketcher::none;
}
else if (ui->OriginRadioButton->isChecked()) {
RefGeoid=-1;
RefGeoid=Sketcher::GeoEnum::RtPnt;
RefPosid=Sketcher::start;
}

View File

@ -1446,15 +1446,15 @@ void ViewProviderSketch::onSelectionChanged(const Gui::SelectionChanges& msg)
this->updateColor();
}
else if (shapetype == "RootPoint") {
addSelectPoint(-1);
addSelectPoint(Sketcher::GeoEnum::RtPnt);
this->updateColor();
}
else if (shapetype == "H_Axis") {
edit->SelCurvSet.insert(-1);
edit->SelCurvSet.insert(Sketcher::GeoEnum::HAxis);
this->updateColor();
}
else if (shapetype == "V_Axis") {
edit->SelCurvSet.insert(-2);
edit->SelCurvSet.insert(Sketcher::GeoEnum::VAxis);
this->updateColor();
}
else if (shapetype.size() > 10 && shapetype.substr(0,10) == "Constraint") {
@ -1491,15 +1491,15 @@ void ViewProviderSketch::onSelectionChanged(const Gui::SelectionChanges& msg)
this->updateColor();
}
else if (shapetype == "RootPoint") {
removeSelectPoint(-1);
removeSelectPoint(Sketcher::GeoEnum::RtPnt);
this->updateColor();
}
else if (shapetype == "H_Axis") {
edit->SelCurvSet.erase(-1);
edit->SelCurvSet.erase(Sketcher::GeoEnum::HAxis);
this->updateColor();
}
else if (shapetype == "V_Axis") {
edit->SelCurvSet.erase(-2);
edit->SelCurvSet.erase(Sketcher::GeoEnum::VAxis);
this->updateColor();
}
else if (shapetype.size() > 10 && shapetype.substr(0,10) == "Constraint") {
@ -1658,7 +1658,7 @@ bool ViewProviderSketch::detectPreselection(const SoPickedPoint *Point,
// get the index
PtIndex = static_cast<const SoPointDetail *>(point_detail)->getCoordinateIndex();
PtIndex -= 1; // shift corresponding to RootPoint
if (PtIndex == -1)
if (PtIndex == Sketcher::GeoEnum::RtPnt)
CrossIndex = 0; // RootPoint was hit
}
} else {
@ -1709,7 +1709,7 @@ bool ViewProviderSketch::detectPreselection(const SoPickedPoint *Point,
if (GeoIndex >= 0)
ss << "Edge" << GeoIndex + 1;
else // external geometry
ss << "ExternalEdge" << -GeoIndex - 2; // convert index start from -3 to 1
ss << "ExternalEdge" << -GeoIndex + Sketcher::GeoEnum::RefExt + 1; // convert index start from -3 to 1
bool accepted =
Gui::Selection().setPreselect(getSketchObject()->getDocument()->getName()
,getSketchObject()->getNameInDocument()
@ -2262,7 +2262,7 @@ void ViewProviderSketch::updateColor(void)
verts[j] = SbVec3f(x,y,zHighLine);
}
}
else if (GeoId < -2) { // external Geometry
else if (GeoId <= Sketcher::GeoEnum::RefExt) { // external Geometry
color[i] = CurveExternalColor;
for (int k=j; j<k+indexes; j++) {
verts[j].getValue(x,y,z);
@ -2300,7 +2300,7 @@ void ViewProviderSketch::updateColor(void)
else
crosscolor[0] = CrossColorH;
if (edit->SelCurvSet.find(-2) != edit->SelCurvSet.end())
if (edit->SelCurvSet.find(Sketcher::GeoEnum::VAxis) != edit->SelCurvSet.end())
crosscolor[1] = SelectColor;
else if (edit->PreselectCross == 2)
crosscolor[1] = PreselectColor;
@ -4874,7 +4874,7 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
if( GeoId >= 0 )
delInternalGeometries.insert(GeoId);
else
delExternalGeometries.insert(-3-GeoId);
delExternalGeometries.insert(Sketcher::GeoEnum::RefExt - GeoId);
} else if (it->size() > 12 && it->substr(0,12) == "ExternalEdge") {
int GeoId = std::atoi(it->substr(12,4000).c_str()) - 1;
delExternalGeometries.insert(GeoId);
@ -4888,12 +4888,12 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
if(GeoId>=0)
delInternalGeometries.insert(GeoId);
else
delExternalGeometries.insert(-3-GeoId);
delExternalGeometries.insert(Sketcher::GeoEnum::RefExt - GeoId);
}
else
delCoincidents.insert(VtId);
} else if (*it == "RootPoint") {
delCoincidents.insert(-1);
delCoincidents.insert(Sketcher::GeoEnum::RtPnt);
} else if (it->size() > 10 && it->substr(0,10) == "Constraint") {
int ConstrId = Sketcher::PropertyConstraintList::getIndexFromConstraintName(*it);
delConstraints.insert(ConstrId);