+ 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)
{
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);
}
@ -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);
@ -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);
}
@ -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 &&
@ -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,
@ -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);
@ -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,
@ -791,10 +791,10 @@ 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;
@ -802,9 +802,9 @@ int Sketch::addConstraint(const Constraint *constraint)
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,
@ -814,27 +814,28 @@ 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;
@ -842,9 +843,10 @@ int Sketch::addConstraint(const Constraint *constraint)
{
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;
}
@ -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;
}

View File

@ -46,7 +46,7 @@ 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
@ -54,8 +54,8 @@ bool isAlterGeoActive(Gui::Document *doc)
return true;
}
}
return false;
return false;
}
namespace SketcherGui {
@ -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();
@ -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"):
@ -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"));
@ -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.
{

View File

@ -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);
}
}