+ 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:
logari81 2011-10-10 21:41:30 +00:00
parent a2082838bb
commit b252fe7e1f
6 changed files with 96 additions and 113 deletions

View File

@ -608,13 +608,8 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
}
} else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) {
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle*>(geo);
Base::Vector3d center = circle->getCenter();
double startangle, endangle, angle, circ;
double theta0 = atan2(point.y - center.y,point.x - center.x);
if (GeoId1 >= 0 && GeoId2 >= 0) {
double theta1 = atan2(point1.y - center.y, point1.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;
addConstraint(newConstr);
newConstr->First = newGeoId;
newConstr->FirstPos = start;
newConstr->Second = GeoId2;
@ -678,7 +672,6 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
//movePoint(newGeoId, start, point2);
//movePoint(newGeoId, end, point1);
return 0;
} else
return -1;
@ -689,7 +682,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
Base::Vector3d center = aoc->getCenter();
double startangle, endangle, angle, circ;
double startangle, endangle;
aoc->getRange(startangle, endangle);
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 theta2 = atan2(point2.y - center.y, point2.x - center.x);
double u1,v1;
u1= theta1;
v1 = theta2;
double u1 = (theta1 >= 0) ? theta1 : theta1 + 2*M_PI;
double v1 = (theta2 >= 0) ? theta2 : theta2 + 2*M_PI;
if (theta0 < theta1 && theta0 < theta2) {
if (theta1 > theta2)
@ -719,17 +711,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
u = fmod(u, 2.f*M_PI);
v = fmod(v, 2.f*M_PI);
if(u1 < 0)
u1 += 2 * M_PI;
if(v1 < 0)
v1 += 2 * M_PI;
bool swap = false;
if(u > v) {
swap = true;
}
bool swap = (u > v);
if (theta1 > theta2) {
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
aoc->getRange(u,v);
u = fmod(u, 2.f*M_PI);
v = fmod(v, 2.f*M_PI);

View File

@ -1027,7 +1027,7 @@ void CmdSketcherConstrainParallel::activated(int iMsg)
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
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;
}
@ -1134,7 +1134,6 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
return;
}
int GeoId1,GeoId2;
if (SubNames[0].size() > 4 && SubNames[0].substr(0,4) == "Edge")
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<Part::Geometry *> &geomlist = Obj->Geometry.getValues();
// go through the selected subelements
if (SubNames.size() < 2) {
@ -1589,6 +1587,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
QObject::tr("Select geometry of similar type"));
return;
}
// undo command open
openCommand("add equality constraint");
int i = 0;

View File

@ -271,8 +271,6 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
float height = scale / (float) srch;
float width = aspectRatio * (float) height;
this->bbx = width;
this->bby = height;

View File

@ -39,8 +39,7 @@
namespace SketcherGui {
class SketcherGuiExport SoDatumLabel : public SoShape {
typedef SoNode inherited;
typedef SoShape inherited;
SO_NODE_HEADER(SoDatumLabel);

View File

@ -30,7 +30,7 @@
namespace SketcherGui {
class SketcherGuiExport SoZoomTranslation : public SoTranslation {
typedef SoNode inherited;
typedef SoTranslation inherited;
SO_NODE_HEADER(SoZoomTranslation);

View File

@ -2397,19 +2397,10 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
break;
case PointOnObject:
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
sep->addChild(new SoZoomTranslation());
sep->addChild(new SoImage()); // constraint icon
sep->addChild(new SoZoomTranslation()); // 1.
sep->addChild(new SoImage()); // 2. constraint icon
if ((*it)->Type == Tangent) {
Part::Geometry *geo1 = getSketchObject()->Geometry.getValues()[(*it)->First];
@ -2417,13 +2408,28 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() &&
geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
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);
}
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:
edit->vConstrType.push_back(None);
}
@ -2977,7 +2983,7 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
edit->PreselectConstraint = -1;
this->drawConstraintIcons();
this->updateColor();
// if in edit not delet the object
// if in edit not delete the object
return false;
}
// if not in edit delete the whole object