Skip to content

Commit

Permalink
+ fix whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed May 30, 2015
1 parent 3b1873f commit eef340f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 71 deletions.
110 changes: 56 additions & 54 deletions src/Mod/Sketcher/App/Sketch.cpp
Expand Up @@ -632,40 +632,41 @@ GCS::Curve* Sketch::getGCSCurveByGeoId(int geoId)

int Sketch::addConstraint(const Constraint *constraint)
{
if(int(Geoms.size()) <= 0)
if (Geoms.empty())
throw Base::Exception("Sketch::addConstraint. Can't add constraint to a sketch with no geometry!");
int rtn = -1;

ConstrDef c;
c.constr=const_cast<Constraint *>(constraint);
c.driving=constraint->isDriving;

switch (constraint->Type) {
case DistanceX:
if (constraint->FirstPos == none){ // horizontal length of a line
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

rtn = addDistanceXConstraint(constraint->First,c.value);
}
else if (constraint->Second == Constraint::GeoUndef) {// point on fixed x-coordinate
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
Parameters.push_back(c.value);

rtn = addCoordinateXConstraint(constraint->First,constraint->FirstPos,c.value);
}
}
else if (constraint->SecondPos != none) {// point to point horizontal distance
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

rtn = addDistanceXConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,c.value);
}
Expand All @@ -674,15 +675,16 @@ int Sketch::addConstraint(const Constraint *constraint)
if (constraint->FirstPos == none){ // vertical length of a line
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

rtn = addDistanceYConstraint(constraint->First,c.value);
}
else if (constraint->Second == Constraint::GeoUndef){ // point on fixed y-coordinate
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

Expand All @@ -691,10 +693,10 @@ int Sketch::addConstraint(const Constraint *constraint)
else if (constraint->SecondPos != none){ // point to point vertical distance
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

rtn = addDistanceYConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,c.value);
}
Expand Down Expand Up @@ -732,18 +734,16 @@ int Sketch::addConstraint(const Constraint *constraint)
//any other point-wise perpendicularity
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

rtn = addAngleAtPointConstraint(
constraint->First, constraint->FirstPos,
constraint->Second, constraint->SecondPos,
constraint->Third, constraint->ThirdPos,
c.value, constraint->Type);
}


break;
case Tangent:
if (constraint->FirstPos == none &&
Expand All @@ -755,10 +755,10 @@ int Sketch::addConstraint(const Constraint *constraint)
//any other point-wise tangency (endpoint-to-curve, endpoint-to-endpoint, tangent-via-point)
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

rtn = addAngleAtPointConstraint(
constraint->First, constraint->FirstPos,
constraint->Second, constraint->SecondPos,
Expand All @@ -770,9 +770,9 @@ int Sketch::addConstraint(const Constraint *constraint)
if (constraint->SecondPos != none){ // point to point distance
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
Parameters.push_back(c.value);
rtn = addDistanceConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,
c.value);
Expand All @@ -781,7 +781,7 @@ int Sketch::addConstraint(const Constraint *constraint)
if (constraint->FirstPos != none) { // point to line distance
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
rtn = addDistanceConstraint(constraint->First,constraint->FirstPos,
Expand All @@ -791,20 +791,20 @@ int Sketch::addConstraint(const Constraint *constraint)
else {// line length
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
Parameters.push_back(c.value);

rtn = addDistanceConstraint(constraint->First,c.value);
}
break;
case Angle:
if (constraint->Third != Constraint::GeoUndef){
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
Parameters.push_back(c.value);

rtn = addAngleAtPointConstraint (
constraint->First, constraint->FirstPos,
Expand All @@ -814,37 +814,39 @@ int Sketch::addConstraint(const Constraint *constraint)
} else if (constraint->SecondPos != none){ // angle between two lines (with explicit start points)
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);

rtn = addAngleConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,c.value);
}
else if (constraint->Second != Constraint::GeoUndef){ // angle between two lines
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
Parameters.push_back(c.value);
rtn = addAngleConstraint(constraint->First,constraint->Second,c.value);
}
else if (constraint->First != Constraint::GeoUndef) {// orientation angle of a line
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
Parameters.push_back(c.value);

rtn = addAngleConstraint(constraint->First,c.value);
}
break;
case Radius:
{
c.value = new double(constraint->Value);
if(c.driving)
FixParameters.push_back(c.value);
FixParameters.push_back(c.value);
else
Parameters.push_back(c.value);
Parameters.push_back(c.value);

rtn = addRadiusConstraint(constraint->First, c.value);
break;
}
Expand Down Expand Up @@ -877,30 +879,30 @@ int Sketch::addConstraint(const Constraint *constraint)
}
break;
case SnellsLaw:
{
c.value = new double(constraint->Value);
c.secondvalue = new double(constraint->Value);
{
c.value = new double(constraint->Value);
c.secondvalue = new double(constraint->Value);

if(c.driving) {
FixParameters.push_back(c.value);
FixParameters.push_back(c.secondvalue);
}
else {
Parameters.push_back(c.value);
Parameters.push_back(c.secondvalue);
}
if(c.driving) {
FixParameters.push_back(c.value);
FixParameters.push_back(c.secondvalue);
}
else {
Parameters.push_back(c.value);
Parameters.push_back(c.secondvalue);
}

//assert(constraint->ThirdPos==none); //will work anyway...
rtn = addSnellsLawConstraint(constraint->First, constraint->FirstPos,
constraint->Second, constraint->SecondPos,
constraint->Third,
c.value, c.secondvalue);
}
//assert(constraint->ThirdPos==none); //will work anyway...
rtn = addSnellsLawConstraint(constraint->First, constraint->FirstPos,
constraint->Second, constraint->SecondPos,
constraint->Third,
c.value, c.secondvalue);
}
break;
case None:
break;
}

Constrs.push_back(c);
return rtn;
}
Expand Down
30 changes: 14 additions & 16 deletions src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp
Expand Up @@ -46,16 +46,16 @@ using namespace SketcherGui;
using namespace Sketcher;

bool isAlterGeoActive(Gui::Document *doc)
{
{
if (doc) {
// checks if a Sketch Viewprovider is in Edit
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom
(SketcherGui::ViewProviderSketch::getClassTypeId())) {
return true;
}
}
return false;

return false;
}

namespace SketcherGui {
Expand Down Expand Up @@ -85,18 +85,18 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
if(Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 0){

Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();

if(geometryCreationMode==Construction) {
geometryCreationMode=Normal;

rcCmdMgr.getCommandByName("Sketcher_CreateLine")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateLine"));
rcCmdMgr.getCommandByName("Sketcher_CreateRectangle")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateRectangle"));
rcCmdMgr.getCommandByName("Sketcher_CreatePolyline")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline"));
Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline"));
rcCmdMgr.getCommandByName("Sketcher_CreateSlot")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateSlot"));
Gui::BitmapFactory().pixmap("Sketcher_CreateSlot"));
// Comp commands require a distinctive treatment
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(rcCmdMgr.getCommandByName("Sketcher_CompCreateArc")->getAction());
QList<QAction*> a = pcAction->actions();
Expand All @@ -112,7 +112,7 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
index = pcAction->property("defaultAction").toInt();
a[0]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse"));
a[1]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse_3points"));
a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_Elliptical_Arc"));
a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_Elliptical_Arc"));
rcCmdMgr.getCommandByName("Sketcher_CompCreateConic")->getAction()->setIcon(
index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse"):
index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse_3points"):
Expand All @@ -135,17 +135,17 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon"));
a[3]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon"));
a[4]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon"));
a[5]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon"));
a[5]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon"));
rcCmdMgr.getCommandByName("Sketcher_CompCreateRegularPolygon")->getAction()->setIcon(
index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateTriangle"):
index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateSquare"):
index==2?Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon"):
index==3?Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon"):
index==4?Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon"):
Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon"));
index==4?Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon"):
Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon"));
}
else {
geometryCreationMode=Construction;
geometryCreationMode=Construction;

rcCmdMgr.getCommandByName("Sketcher_CreateLine")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateLine_Constr"));
Expand Down Expand Up @@ -194,17 +194,15 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon_Constr"));
a[3]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon_Constr"));
a[4]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon_Constr"));
a[5]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon_Constr"));
a[5]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon_Constr"));
rcCmdMgr.getCommandByName("Sketcher_CompCreateRegularPolygon")->getAction()->setIcon(
index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateTriangle_Constr"):
index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateSquare_Constr"):
index==2?Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon_Constr"):
index==3?Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon_Constr"):
index==4?Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon_Constr"):
index==4?Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon_Constr"):
Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon_Constr"));

}

}
}
else // there was a selection, so operate in toggle mode.
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/Gui/CommandCreateGeo.cpp
Expand Up @@ -105,7 +105,7 @@ void ActivateHandler(Gui::Document *doc,DrawSketchHandler *handler)
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom
(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*> (doc->getInEdit());
vp->purgeHandler();
vp->purgeHandler();
vp->activateHandler(handler);
}
}
Expand Down

0 comments on commit eef340f

Please sign in to comment.