+ fix whitespaces

This commit is contained in:
wmayer 2015-05-30 20:30:12 +02:00
parent 3b1873f1dc
commit eef340f19c
3 changed files with 71 additions and 71 deletions

View File

@ -632,40 +632,41 @@ GCS::Curve* Sketch::getGCSCurveByGeoId(int geoId)
int Sketch::addConstraint(const Constraint *constraint) 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!"); throw Base::Exception("Sketch::addConstraint. Can't add constraint to a sketch with no geometry!");
int rtn = -1; int rtn = -1;
ConstrDef c; ConstrDef c;
c.constr=const_cast<Constraint *>(constraint); c.constr=const_cast<Constraint *>(constraint);
c.driving=constraint->isDriving; c.driving=constraint->isDriving;
switch (constraint->Type) { switch (constraint->Type) {
case DistanceX: case DistanceX:
if (constraint->FirstPos == none){ // horizontal length of a line if (constraint->FirstPos == none){ // horizontal length of a line
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addDistanceXConstraint(constraint->First,c.value); rtn = addDistanceXConstraint(constraint->First,c.value);
} }
else if (constraint->Second == Constraint::GeoUndef) {// point on fixed x-coordinate else if (constraint->Second == Constraint::GeoUndef) {// point on fixed x-coordinate
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addCoordinateXConstraint(constraint->First,constraint->FirstPos,c.value); rtn = addCoordinateXConstraint(constraint->First,constraint->FirstPos,c.value);
} }
else if (constraint->SecondPos != none) {// point to point horizontal distance else if (constraint->SecondPos != none) {// point to point horizontal distance
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addDistanceXConstraint(constraint->First,constraint->FirstPos, rtn = addDistanceXConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,c.value); constraint->Second,constraint->SecondPos,c.value);
} }
@ -674,15 +675,16 @@ int Sketch::addConstraint(const Constraint *constraint)
if (constraint->FirstPos == none){ // vertical length of a line if (constraint->FirstPos == none){ // vertical length of a line
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addDistanceYConstraint(constraint->First,c.value); rtn = addDistanceYConstraint(constraint->First,c.value);
} }
else if (constraint->Second == Constraint::GeoUndef){ // point on fixed y-coordinate else if (constraint->Second == Constraint::GeoUndef){ // point on fixed y-coordinate
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
@ -691,10 +693,10 @@ int Sketch::addConstraint(const Constraint *constraint)
else if (constraint->SecondPos != none){ // point to point vertical distance else if (constraint->SecondPos != none){ // point to point vertical distance
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addDistanceYConstraint(constraint->First,constraint->FirstPos, rtn = addDistanceYConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,c.value); constraint->Second,constraint->SecondPos,c.value);
} }
@ -732,18 +734,16 @@ int Sketch::addConstraint(const Constraint *constraint)
//any other point-wise perpendicularity //any other point-wise perpendicularity
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addAngleAtPointConstraint( rtn = addAngleAtPointConstraint(
constraint->First, constraint->FirstPos, constraint->First, constraint->FirstPos,
constraint->Second, constraint->SecondPos, constraint->Second, constraint->SecondPos,
constraint->Third, constraint->ThirdPos, constraint->Third, constraint->ThirdPos,
c.value, constraint->Type); c.value, constraint->Type);
} }
break; break;
case Tangent: case Tangent:
if (constraint->FirstPos == none && if (constraint->FirstPos == none &&
@ -755,10 +755,10 @@ int Sketch::addConstraint(const Constraint *constraint)
//any other point-wise tangency (endpoint-to-curve, endpoint-to-endpoint, tangent-via-point) //any other point-wise tangency (endpoint-to-curve, endpoint-to-endpoint, tangent-via-point)
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addAngleAtPointConstraint( rtn = addAngleAtPointConstraint(
constraint->First, constraint->FirstPos, constraint->First, constraint->FirstPos,
constraint->Second, constraint->SecondPos, constraint->Second, constraint->SecondPos,
@ -770,9 +770,9 @@ int Sketch::addConstraint(const Constraint *constraint)
if (constraint->SecondPos != none){ // point to point distance if (constraint->SecondPos != none){ // point to point distance
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addDistanceConstraint(constraint->First,constraint->FirstPos, rtn = addDistanceConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos, constraint->Second,constraint->SecondPos,
c.value); c.value);
@ -781,7 +781,7 @@ int Sketch::addConstraint(const Constraint *constraint)
if (constraint->FirstPos != none) { // point to line distance if (constraint->FirstPos != none) { // point to line distance
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addDistanceConstraint(constraint->First,constraint->FirstPos, rtn = addDistanceConstraint(constraint->First,constraint->FirstPos,
@ -791,10 +791,10 @@ int Sketch::addConstraint(const Constraint *constraint)
else {// line length else {// line length
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addDistanceConstraint(constraint->First,c.value); rtn = addDistanceConstraint(constraint->First,c.value);
} }
break; break;
@ -802,9 +802,9 @@ int Sketch::addConstraint(const Constraint *constraint)
if (constraint->Third != Constraint::GeoUndef){ if (constraint->Third != Constraint::GeoUndef){
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addAngleAtPointConstraint ( rtn = addAngleAtPointConstraint (
constraint->First, constraint->FirstPos, constraint->First, constraint->FirstPos,
@ -814,27 +814,28 @@ int Sketch::addConstraint(const Constraint *constraint)
} else if (constraint->SecondPos != none){ // angle between two lines (with explicit start points) } else if (constraint->SecondPos != none){ // angle between two lines (with explicit start points)
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addAngleConstraint(constraint->First,constraint->FirstPos, rtn = addAngleConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,c.value); constraint->Second,constraint->SecondPos,c.value);
} }
else if (constraint->Second != Constraint::GeoUndef){ // angle between two lines else if (constraint->Second != Constraint::GeoUndef){ // angle between two lines
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addAngleConstraint(constraint->First,constraint->Second,c.value); rtn = addAngleConstraint(constraint->First,constraint->Second,c.value);
} }
else if (constraint->First != Constraint::GeoUndef) {// orientation angle of a line else if (constraint->First != Constraint::GeoUndef) {// orientation angle of a line
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addAngleConstraint(constraint->First,c.value); rtn = addAngleConstraint(constraint->First,c.value);
} }
break; break;
@ -842,9 +843,10 @@ int Sketch::addConstraint(const Constraint *constraint)
{ {
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
if(c.driving) if(c.driving)
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
else else
Parameters.push_back(c.value); Parameters.push_back(c.value);
rtn = addRadiusConstraint(constraint->First, c.value); rtn = addRadiusConstraint(constraint->First, c.value);
break; break;
} }
@ -877,30 +879,30 @@ int Sketch::addConstraint(const Constraint *constraint)
} }
break; break;
case SnellsLaw: case SnellsLaw:
{ {
c.value = new double(constraint->Value); c.value = new double(constraint->Value);
c.secondvalue = new double(constraint->Value); c.secondvalue = new double(constraint->Value);
if(c.driving) { if(c.driving) {
FixParameters.push_back(c.value); FixParameters.push_back(c.value);
FixParameters.push_back(c.secondvalue); FixParameters.push_back(c.secondvalue);
} }
else { else {
Parameters.push_back(c.value); Parameters.push_back(c.value);
Parameters.push_back(c.secondvalue); Parameters.push_back(c.secondvalue);
} }
//assert(constraint->ThirdPos==none); //will work anyway... //assert(constraint->ThirdPos==none); //will work anyway...
rtn = addSnellsLawConstraint(constraint->First, constraint->FirstPos, rtn = addSnellsLawConstraint(constraint->First, constraint->FirstPos,
constraint->Second, constraint->SecondPos, constraint->Second, constraint->SecondPos,
constraint->Third, constraint->Third,
c.value, c.secondvalue); c.value, c.secondvalue);
} }
break; break;
case None: case None:
break; break;
} }
Constrs.push_back(c); Constrs.push_back(c);
return rtn; return rtn;
} }

View File

@ -46,7 +46,7 @@ using namespace SketcherGui;
using namespace Sketcher; using namespace Sketcher;
bool isAlterGeoActive(Gui::Document *doc) bool isAlterGeoActive(Gui::Document *doc)
{ {
if (doc) { if (doc) {
// checks if a Sketch Viewprovider is in Edit // checks if a Sketch Viewprovider is in Edit
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom
@ -54,8 +54,8 @@ bool isAlterGeoActive(Gui::Document *doc)
return true; return true;
} }
} }
return false;
return false;
} }
namespace SketcherGui { namespace SketcherGui {
@ -85,18 +85,18 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
if(Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 0){ if(Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 0){
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
if(geometryCreationMode==Construction) { if(geometryCreationMode==Construction) {
geometryCreationMode=Normal; geometryCreationMode=Normal;
rcCmdMgr.getCommandByName("Sketcher_CreateLine")->getAction()->setIcon( rcCmdMgr.getCommandByName("Sketcher_CreateLine")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateLine")); Gui::BitmapFactory().pixmap("Sketcher_CreateLine"));
rcCmdMgr.getCommandByName("Sketcher_CreateRectangle")->getAction()->setIcon( rcCmdMgr.getCommandByName("Sketcher_CreateRectangle")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateRectangle")); Gui::BitmapFactory().pixmap("Sketcher_CreateRectangle"));
rcCmdMgr.getCommandByName("Sketcher_CreatePolyline")->getAction()->setIcon( rcCmdMgr.getCommandByName("Sketcher_CreatePolyline")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline")); Gui::BitmapFactory().pixmap("Sketcher_CreatePolyline"));
rcCmdMgr.getCommandByName("Sketcher_CreateSlot")->getAction()->setIcon( rcCmdMgr.getCommandByName("Sketcher_CreateSlot")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateSlot")); Gui::BitmapFactory().pixmap("Sketcher_CreateSlot"));
// Comp commands require a distinctive treatment // Comp commands require a distinctive treatment
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(rcCmdMgr.getCommandByName("Sketcher_CompCreateArc")->getAction()); Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(rcCmdMgr.getCommandByName("Sketcher_CompCreateArc")->getAction());
QList<QAction*> a = pcAction->actions(); QList<QAction*> a = pcAction->actions();
@ -112,7 +112,7 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
index = pcAction->property("defaultAction").toInt(); index = pcAction->property("defaultAction").toInt();
a[0]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse")); a[0]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse"));
a[1]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse_3points")); 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( rcCmdMgr.getCommandByName("Sketcher_CompCreateConic")->getAction()->setIcon(
index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse"): index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse"):
index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse_3points"): index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateEllipse_3points"):
@ -135,17 +135,17 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon")); a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon"));
a[3]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon")); a[3]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon"));
a[4]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon")); 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( rcCmdMgr.getCommandByName("Sketcher_CompCreateRegularPolygon")->getAction()->setIcon(
index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateTriangle"): index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateTriangle"):
index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateSquare"): index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateSquare"):
index==2?Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon"): index==2?Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon"):
index==3?Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon"): index==3?Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon"):
index==4?Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon"): index==4?Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon"):
Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon")); Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon"));
} }
else { else {
geometryCreationMode=Construction; geometryCreationMode=Construction;
rcCmdMgr.getCommandByName("Sketcher_CreateLine")->getAction()->setIcon( rcCmdMgr.getCommandByName("Sketcher_CreateLine")->getAction()->setIcon(
Gui::BitmapFactory().pixmap("Sketcher_CreateLine_Constr")); Gui::BitmapFactory().pixmap("Sketcher_CreateLine_Constr"));
@ -194,17 +194,15 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon_Constr")); a[2]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon_Constr"));
a[3]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon_Constr")); a[3]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon_Constr"));
a[4]->setIcon(Gui::BitmapFactory().pixmap("Sketcher_CreateHeptagon_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( rcCmdMgr.getCommandByName("Sketcher_CompCreateRegularPolygon")->getAction()->setIcon(
index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateTriangle_Constr"): index==0?Gui::BitmapFactory().pixmap("Sketcher_CreateTriangle_Constr"):
index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateSquare_Constr"): index==1?Gui::BitmapFactory().pixmap("Sketcher_CreateSquare_Constr"):
index==2?Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon_Constr"): index==2?Gui::BitmapFactory().pixmap("Sketcher_CreatePentagon_Constr"):
index==3?Gui::BitmapFactory().pixmap("Sketcher_CreateHexagon_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")); Gui::BitmapFactory().pixmap("Sketcher_CreateOctagon_Constr"));
}
}
} }
else // there was a selection, so operate in toggle mode. else // there was a selection, so operate in toggle mode.
{ {

View File

@ -105,7 +105,7 @@ void ActivateHandler(Gui::Document *doc,DrawSketchHandler *handler)
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom
(SketcherGui::ViewProviderSketch::getClassTypeId())) { (SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*> (doc->getInEdit()); SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*> (doc->getInEdit());
vp->purgeHandler(); vp->purgeHandler();
vp->activateHandler(handler); vp->activateHandler(handler);
} }
} }