+ improve coding style and fix typos
+ fix positioning of symmetry constraint icon git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5002 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
a2082838bb
commit
b252fe7e1f
|
@ -608,13 +608,8 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||||
}
|
}
|
||||||
} else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) {
|
} else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) {
|
||||||
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle*>(geo);
|
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle*>(geo);
|
||||||
|
|
||||||
Base::Vector3d center = circle->getCenter();
|
Base::Vector3d center = circle->getCenter();
|
||||||
|
|
||||||
double startangle, endangle, angle, circ;
|
|
||||||
|
|
||||||
double theta0 = atan2(point.y - center.y,point.x - center.x);
|
double theta0 = atan2(point.y - center.y,point.x - center.x);
|
||||||
|
|
||||||
if (GeoId1 >= 0 && GeoId2 >= 0) {
|
if (GeoId1 >= 0 && GeoId2 >= 0) {
|
||||||
double theta1 = atan2(point1.y - center.y, point1.x - center.x);
|
double theta1 = atan2(point1.y - center.y, point1.x - center.x);
|
||||||
double theta2 = atan2(point2.y - center.y, point2.x - center.x);
|
double theta2 = atan2(point2.y - center.y, point2.x - center.x);
|
||||||
|
@ -668,7 +663,6 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||||
newConstr->Second = GeoId1;
|
newConstr->Second = GeoId1;
|
||||||
addConstraint(newConstr);
|
addConstraint(newConstr);
|
||||||
|
|
||||||
|
|
||||||
newConstr->First = newGeoId;
|
newConstr->First = newGeoId;
|
||||||
newConstr->FirstPos = start;
|
newConstr->FirstPos = start;
|
||||||
newConstr->Second = GeoId2;
|
newConstr->Second = GeoId2;
|
||||||
|
@ -678,7 +672,6 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||||
//movePoint(newGeoId, start, point2);
|
//movePoint(newGeoId, start, point2);
|
||||||
//movePoint(newGeoId, end, point1);
|
//movePoint(newGeoId, end, point1);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -689,7 +682,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||||
|
|
||||||
Base::Vector3d center = aoc->getCenter();
|
Base::Vector3d center = aoc->getCenter();
|
||||||
|
|
||||||
double startangle, endangle, angle, circ;
|
double startangle, endangle;
|
||||||
aoc->getRange(startangle, endangle);
|
aoc->getRange(startangle, endangle);
|
||||||
|
|
||||||
double theta0 = atan2(point.y - center.y,point.x - center.x);
|
double theta0 = atan2(point.y - center.y,point.x - center.x);
|
||||||
|
@ -698,9 +691,8 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||||
double theta1 = atan2(point1.y - center.y, point1.x - center.x);
|
double theta1 = atan2(point1.y - center.y, point1.x - center.x);
|
||||||
double theta2 = atan2(point2.y - center.y, point2.x - center.x);
|
double theta2 = atan2(point2.y - center.y, point2.x - center.x);
|
||||||
|
|
||||||
double u1,v1;
|
double u1 = (theta1 >= 0) ? theta1 : theta1 + 2*M_PI;
|
||||||
u1= theta1;
|
double v1 = (theta2 >= 0) ? theta2 : theta2 + 2*M_PI;
|
||||||
v1 = theta2;
|
|
||||||
|
|
||||||
if (theta0 < theta1 && theta0 < theta2) {
|
if (theta0 < theta1 && theta0 < theta2) {
|
||||||
if (theta1 > theta2)
|
if (theta1 > theta2)
|
||||||
|
@ -719,17 +711,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||||
u = fmod(u, 2.f*M_PI);
|
u = fmod(u, 2.f*M_PI);
|
||||||
v = fmod(v, 2.f*M_PI);
|
v = fmod(v, 2.f*M_PI);
|
||||||
|
|
||||||
|
bool swap = (u > v);
|
||||||
if(u1 < 0)
|
|
||||||
u1 += 2 * M_PI;
|
|
||||||
|
|
||||||
if(v1 < 0)
|
|
||||||
v1 += 2 * M_PI;
|
|
||||||
|
|
||||||
bool swap = false;
|
|
||||||
if(u > v) {
|
|
||||||
swap = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theta1 > theta2) {
|
if (theta1 > theta2) {
|
||||||
std::swap(GeoId1,GeoId2);
|
std::swap(GeoId1,GeoId2);
|
||||||
|
@ -760,7 +742,6 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||||
|
|
||||||
// Setting the range manually to improve stability before adding constraints
|
// Setting the range manually to improve stability before adding constraints
|
||||||
|
|
||||||
|
|
||||||
aoc->getRange(u,v);
|
aoc->getRange(u,v);
|
||||||
u = fmod(u, 2.f*M_PI);
|
u = fmod(u, 2.f*M_PI);
|
||||||
v = fmod(v, 2.f*M_PI);
|
v = fmod(v, 2.f*M_PI);
|
||||||
|
|
|
@ -1027,7 +1027,7 @@ void CmdSketcherConstrainParallel::activated(int iMsg)
|
||||||
// only one sketch with its subelements are allowed to be selected
|
// only one sketch with its subelements are allowed to be selected
|
||||||
if (selection.size() != 1) {
|
if (selection.size() != 1) {
|
||||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||||
QObject::tr("Select an edge from the sketch."));
|
QObject::tr("Select two or more lines from the sketch."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1134,7 +1134,6 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GeoId1,GeoId2;
|
int GeoId1,GeoId2;
|
||||||
if (SubNames[0].size() > 4 && SubNames[0].substr(0,4) == "Edge")
|
if (SubNames[0].size() > 4 && SubNames[0].substr(0,4) == "Edge")
|
||||||
GeoId1 = std::atoi(SubNames[0].substr(4,4000).c_str());
|
GeoId1 = std::atoi(SubNames[0].substr(4,4000).c_str());
|
||||||
|
@ -1545,7 +1544,6 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
|
||||||
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
|
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
|
||||||
const std::vector<Part::Geometry *> &geomlist = Obj->Geometry.getValues();
|
const std::vector<Part::Geometry *> &geomlist = Obj->Geometry.getValues();
|
||||||
|
|
||||||
|
|
||||||
// go through the selected subelements
|
// go through the selected subelements
|
||||||
|
|
||||||
if (SubNames.size() < 2) {
|
if (SubNames.size() < 2) {
|
||||||
|
@ -1589,6 +1587,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
|
||||||
QObject::tr("Select geometry of similar type"));
|
QObject::tr("Select geometry of similar type"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// undo command open
|
// undo command open
|
||||||
openCommand("add equality constraint");
|
openCommand("add equality constraint");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
|
@ -271,8 +271,6 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
|
||||||
float height = scale / (float) srch;
|
float height = scale / (float) srch;
|
||||||
float width = aspectRatio * (float) height;
|
float width = aspectRatio * (float) height;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this->bbx = width;
|
this->bbx = width;
|
||||||
this->bby = height;
|
this->bby = height;
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@
|
||||||
namespace SketcherGui {
|
namespace SketcherGui {
|
||||||
|
|
||||||
class SketcherGuiExport SoDatumLabel : public SoShape {
|
class SketcherGuiExport SoDatumLabel : public SoShape {
|
||||||
typedef SoNode inherited;
|
typedef SoShape inherited;
|
||||||
|
|
||||||
|
|
||||||
SO_NODE_HEADER(SoDatumLabel);
|
SO_NODE_HEADER(SoDatumLabel);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
namespace SketcherGui {
|
namespace SketcherGui {
|
||||||
|
|
||||||
class SketcherGuiExport SoZoomTranslation : public SoTranslation {
|
class SketcherGuiExport SoZoomTranslation : public SoTranslation {
|
||||||
typedef SoNode inherited;
|
typedef SoTranslation inherited;
|
||||||
|
|
||||||
SO_NODE_HEADER(SoZoomTranslation);
|
SO_NODE_HEADER(SoZoomTranslation);
|
||||||
|
|
||||||
|
|
|
@ -2397,19 +2397,10 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
|
||||||
break;
|
break;
|
||||||
case PointOnObject:
|
case PointOnObject:
|
||||||
case Tangent:
|
case Tangent:
|
||||||
case Symmetric:
|
|
||||||
{
|
{
|
||||||
if ((*it)->Type == Symmetric) {
|
|
||||||
SoSeparator *sepArrows = new SoSeparator();
|
|
||||||
sepArrows->addChild(new SoCoordinate3());
|
|
||||||
SoLineSet *lineSet = new SoLineSet;
|
|
||||||
sepArrows->addChild(lineSet);
|
|
||||||
sep->addChild(sepArrows);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new nodes to Constraint Seperator
|
// Add new nodes to Constraint Seperator
|
||||||
sep->addChild(new SoZoomTranslation());
|
sep->addChild(new SoZoomTranslation()); // 1.
|
||||||
sep->addChild(new SoImage()); // constraint icon
|
sep->addChild(new SoImage()); // 2. constraint icon
|
||||||
|
|
||||||
if ((*it)->Type == Tangent) {
|
if ((*it)->Type == Tangent) {
|
||||||
Part::Geometry *geo1 = getSketchObject()->Geometry.getValues()[(*it)->First];
|
Part::Geometry *geo1 = getSketchObject()->Geometry.getValues()[(*it)->First];
|
||||||
|
@ -2417,13 +2408,28 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
|
||||||
if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() &&
|
if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() &&
|
||||||
geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
|
geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
|
||||||
sep->addChild(new SoZoomTranslation());
|
sep->addChild(new SoZoomTranslation());
|
||||||
sep->addChild(new SoImage()); // second constraint icon
|
sep->addChild(new SoImage()); // 3. second constraint icon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
edit->vConstrType.push_back((*it)->Type);
|
edit->vConstrType.push_back((*it)->Type);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Symmetric:
|
||||||
|
{
|
||||||
|
SoSeparator *sepArrows = new SoSeparator();
|
||||||
|
sepArrows->addChild(new SoCoordinate3());
|
||||||
|
SoLineSet *lineSet = new SoLineSet;
|
||||||
|
sepArrows->addChild(lineSet);
|
||||||
|
sep->addChild(sepArrows); // 1.
|
||||||
|
|
||||||
|
// Add new nodes to Constraint Seperator
|
||||||
|
sep->addChild(new SoTranslation()); // 2.
|
||||||
|
sep->addChild(new SoImage()); // 3. constraint icon
|
||||||
|
|
||||||
|
edit->vConstrType.push_back((*it)->Type);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
edit->vConstrType.push_back(None);
|
edit->vConstrType.push_back(None);
|
||||||
}
|
}
|
||||||
|
@ -2977,7 +2983,7 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
|
||||||
edit->PreselectConstraint = -1;
|
edit->PreselectConstraint = -1;
|
||||||
this->drawConstraintIcons();
|
this->drawConstraintIcons();
|
||||||
this->updateColor();
|
this->updateColor();
|
||||||
// if in edit not delet the object
|
// if in edit not delete the object
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if not in edit delete the whole object
|
// if not in edit delete the whole object
|
||||||
|
|
Loading…
Reference in New Issue
Block a user