fix Coverity issues

This commit is contained in:
wmayer 2016-08-20 19:45:36 +02:00
parent d80c05e186
commit d39bd4906b
12 changed files with 111 additions and 122 deletions

View File

@ -77,7 +77,7 @@ private:
throw Py::RuntimeError("No file extension");
throw Py::RuntimeError("Unknown file extension");
return Py::None();
//return Py::None();
}
Py::Object insert(const Py::Tuple& args)

View File

@ -62,7 +62,7 @@ using namespace Part;
TYPESYSTEM_SOURCE(Sketcher::Sketch, Base::Persistence)
Sketch::Sketch()
: GCSsys(), ConstraintsCounter(0), isInitMove(false),
: SolveTime(0), GCSsys(), ConstraintsCounter(0), isInitMove(false), isFine(true),
defaultSolver(GCS::DogLeg),defaultSolverRedundant(GCS::DogLeg),debugMode(GCS::Minimal)
{
}
@ -183,27 +183,27 @@ const char* nameByType(Sketch::GeoType type)
int Sketch::addGeometry(const Part::Geometry *geo, bool fixed)
{
if (geo->getTypeId() == GeomPoint::getClassTypeId()) { // add a point
const GeomPoint *point = dynamic_cast<const GeomPoint*>(geo);
const GeomPoint *point = static_cast<const GeomPoint*>(geo);
// create the definition struct for that geom
return addPoint(*point, fixed);
} else if (geo->getTypeId() == GeomLineSegment::getClassTypeId()) { // add a line
const GeomLineSegment *lineSeg = dynamic_cast<const GeomLineSegment*>(geo);
const GeomLineSegment *lineSeg = static_cast<const GeomLineSegment*>(geo);
// create the definition struct for that geom
return addLineSegment(*lineSeg, fixed);
} else if (geo->getTypeId() == GeomCircle::getClassTypeId()) { // add a circle
const GeomCircle *circle = dynamic_cast<const GeomCircle*>(geo);
const GeomCircle *circle = static_cast<const GeomCircle*>(geo);
// create the definition struct for that geom
return addCircle(*circle, fixed);
} else if (geo->getTypeId() == GeomEllipse::getClassTypeId()) { // add a ellipse
const GeomEllipse *ellipse = dynamic_cast<const GeomEllipse*>(geo);
const GeomEllipse *ellipse = static_cast<const GeomEllipse*>(geo);
// create the definition struct for that geom
return addEllipse(*ellipse, fixed);
} else if (geo->getTypeId() == GeomArcOfCircle::getClassTypeId()) { // add an arc
const GeomArcOfCircle *aoc = dynamic_cast<const GeomArcOfCircle*>(geo);
const GeomArcOfCircle *aoc = static_cast<const GeomArcOfCircle*>(geo);
// create the definition struct for that geom
return addArc(*aoc, fixed);
} else if (geo->getTypeId() == GeomArcOfEllipse::getClassTypeId()) { // add an arc
const GeomArcOfEllipse *aoe = dynamic_cast<const GeomArcOfEllipse*>(geo);
const GeomArcOfEllipse *aoe = static_cast<const GeomArcOfEllipse*>(geo);
// create the definition struct for that geom
return addArcOfEllipse(*aoe, fixed);
} else {
@ -594,19 +594,19 @@ Py::Tuple Sketch::getPyGeometry(void) const
Base::Vector3d temp(*(Points[it->startPointId].x),*(Points[it->startPointId].y),0);
tuple[i] = Py::asObject(new VectorPy(temp));
} else if (it->type == Line) {
GeomLineSegment *lineSeg = dynamic_cast<GeomLineSegment*>(it->geo->clone());
GeomLineSegment *lineSeg = static_cast<GeomLineSegment*>(it->geo->clone());
tuple[i] = Py::asObject(new LinePy(lineSeg));
} else if (it->type == Arc) {
GeomArcOfCircle *aoc = dynamic_cast<GeomArcOfCircle*>(it->geo->clone());
GeomArcOfCircle *aoc = static_cast<GeomArcOfCircle*>(it->geo->clone());
tuple[i] = Py::asObject(new ArcOfCirclePy(aoc));
} else if (it->type == Circle) {
GeomCircle *circle = dynamic_cast<GeomCircle*>(it->geo->clone());
GeomCircle *circle = static_cast<GeomCircle*>(it->geo->clone());
tuple[i] = Py::asObject(new CirclePy(circle));
} else if (it->type == Ellipse) {
GeomEllipse *ellipse = dynamic_cast<GeomEllipse*>(it->geo->clone());
GeomEllipse *ellipse = static_cast<GeomEllipse*>(it->geo->clone());
tuple[i] = Py::asObject(new EllipsePy(ellipse));
} else if (it->type == ArcOfEllipse) {
GeomArcOfEllipse *ellipse = dynamic_cast<GeomArcOfEllipse*>(it->geo->clone());
GeomArcOfEllipse *ellipse = static_cast<GeomArcOfEllipse*>(it->geo->clone());
tuple[i] = Py::asObject(new ArcOfEllipsePy(ellipse));
}
else {
@ -922,7 +922,7 @@ int Sketch::addConstraint(const Constraint *constraint)
c.value, c.secondvalue);
}
break;
case None:
case Sketcher::None: // ambiguous enum value
case NumConstraintTypes:
break;
}
@ -1993,13 +1993,13 @@ bool Sketch::updateGeometry()
for (std::vector<GeoDef>::const_iterator it=Geoms.begin(); it != Geoms.end(); ++it, i++) {
try {
if (it->type == Point) {
GeomPoint *point = dynamic_cast<GeomPoint*>(it->geo);
GeomPoint *point = static_cast<GeomPoint*>(it->geo);
point->setPoint(Vector3d(*Points[it->startPointId].x,
*Points[it->startPointId].y,
0.0)
);
} else if (it->type == Line) {
GeomLineSegment *lineSeg = dynamic_cast<GeomLineSegment*>(it->geo);
GeomLineSegment *lineSeg = static_cast<GeomLineSegment*>(it->geo);
lineSeg->setPoints(Vector3d(*Lines[it->index].p1.x,
*Lines[it->index].p1.y,
0.0),
@ -2014,7 +2014,7 @@ bool Sketch::updateGeometry()
// *myArc.start.y = *myArc.center.y + *myArc.rad * sin(*myArc.startAngle);
// *myArc.end.x = *myArc.center.x + *myArc.rad * cos(*myArc.endAngle);
// *myArc.end.y = *myArc.center.y + *myArc.rad * sin(*myArc.endAngle);
GeomArcOfCircle *aoc = dynamic_cast<GeomArcOfCircle*>(it->geo);
GeomArcOfCircle *aoc = static_cast<GeomArcOfCircle*>(it->geo);
aoc->setCenter(Vector3d(*Points[it->midPointId].x,
*Points[it->midPointId].y,
0.0)
@ -2024,7 +2024,7 @@ bool Sketch::updateGeometry()
} else if (it->type == ArcOfEllipse) {
GCS::ArcOfEllipse &myArc = ArcsOfEllipse[it->index];
GeomArcOfEllipse *aoe = dynamic_cast<GeomArcOfEllipse*>(it->geo);
GeomArcOfEllipse *aoe = static_cast<GeomArcOfEllipse*>(it->geo);
Base::Vector3d center = Vector3d(*Points[it->midPointId].x, *Points[it->midPointId].y, 0.0);
Base::Vector3d f1 = Vector3d(*myArc.focus1.x, *myArc.focus1.y, 0.0);
@ -2044,7 +2044,7 @@ bool Sketch::updateGeometry()
aoe->setMajorAxisDir(fd);
aoe->setRange(*myArc.startAngle, *myArc.endAngle, /*emulateCCW=*/true);
} else if (it->type == Circle) {
GeomCircle *circ = dynamic_cast<GeomCircle*>(it->geo);
GeomCircle *circ = static_cast<GeomCircle*>(it->geo);
circ->setCenter(Vector3d(*Points[it->midPointId].x,
*Points[it->midPointId].y,
0.0)
@ -2052,7 +2052,7 @@ bool Sketch::updateGeometry()
circ->setRadius(*Circles[it->index].rad);
} else if (it->type == Ellipse) {
GeomEllipse *ellipse = dynamic_cast<GeomEllipse*>(it->geo);
GeomEllipse *ellipse = static_cast<GeomEllipse*>(it->geo);
Base::Vector3d center = Vector3d(*Points[it->midPointId].x, *Points[it->midPointId].y, 0.0);
Base::Vector3d f1 = Vector3d(*Ellipses[it->index].focus1.x, *Ellipses[it->index].focus1.y, 0.0);

View File

@ -348,7 +348,10 @@ protected:
};
/// container element to store and work with the constraints of this sketch
struct ConstrDef {
ConstrDef() : driving(true) {}
ConstrDef() : constr(0)
, driving(true)
, value(0)
, secondvalue(0) {}
Constraint * constr; // pointer to the constraint
bool driving;
double * value;

View File

@ -194,6 +194,7 @@ System::System()
, subSystems(0)
, subSystemsAux(0)
, reference(0)
, dofs(0)
, hasUnknowns(false)
, hasDiagnosis(false)
, isInit(false)

View File

@ -605,8 +605,10 @@ void CmdSketcherViewSketch::activated(int iMsg)
{
Gui::Document *doc = getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
doCommand(Gui,"Gui.ActiveDocument.ActiveView.setCameraOrientation(App.ActiveDocument.%s.Placement.Rotation.Q)"
,vp->getObject()->getNameInDocument());
if (vp) {
doCommand(Gui,"Gui.ActiveDocument.ActiveView.setCameraOrientation(App.ActiveDocument.%s.Placement.Rotation.Q)"
,vp->getObject()->getNameInDocument());
}
}
bool CmdSketcherViewSketch::isActive(void)

View File

@ -68,7 +68,7 @@ bool isCreateConstraintActive(Gui::Document *doc)
if (doc) {
// checks if a Sketch Viewprovider is in Edit and is in no special mode
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
if (dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())
if (static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())
->getSketchMode() == ViewProviderSketch::STATUS_NONE) {
if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0)
return true;
@ -124,14 +124,7 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr)
}
// e.g. an angle or a distance X or Y applied on a line or two vertexes
if (Constr->Type == Sketcher::Angle ||
((Constr->Type == Sketcher::DistanceX || Constr->Type == Sketcher::DistanceY) &&
(Constr->FirstPos == Sketcher::none || Constr->Second != Sketcher::Constraint::GeoUndef)))
// hide negative sign
init_val.setValue(datum);
else // show negative sign
init_val.setValue(datum);
init_val.setValue(datum);
ui_ins_datum.labelEdit->setValue(init_val);
ui_ins_datum.labelEdit->selectNumber();
@ -214,7 +207,7 @@ void finishDistanceConstraint(Gui::Command* cmd, Sketcher::SketchObject* sketch,
Gui::Document *doc = cmd->getActiveGuiDocument();
float sf = 1.f;
if (doc && doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch *vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch *vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
sf = vp->getScaleFactor();
constr->LabelDistance = 2. * sf;
@ -509,11 +502,11 @@ int SketchSelection::setUp(void)
return -1;
}
SketchObj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
SketchObj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
SketchSubNames = selection[0].getSubNames();
} else if(selection.size() == 2) {
if(selection[0].getObject()->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())){
SketchObj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
SketchObj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
// check if the none sketch object is the support of the sketch
if(selection[1].getObject() != SketchObj->Support.getValue()){
ErrorMsg = QObject::tr("Only sketch and its support is allowed to select");
@ -525,7 +518,7 @@ int SketchSelection::setUp(void)
SupportSubNames = selection[1].getSubNames();
} else if (selection[1].getObject()->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) {
SketchObj = dynamic_cast<Sketcher::SketchObject*>(selection[1].getObject());
SketchObj = static_cast<Sketcher::SketchObject*>(selection[1].getObject());
// check if the none sketch object is the support of the sketch
if(selection[0].getObject() != SketchObj->Support.getValue()){
ErrorMsg = QObject::tr("Only sketch and its support is allowed to select");
@ -580,7 +573,7 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
std::vector<int> ids;
@ -677,7 +670,7 @@ void CmdSketcherConstrainVertical::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
std::vector<int> ids;
@ -773,7 +766,7 @@ void CmdSketcherConstrainLock::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@ -875,7 +868,7 @@ void CmdSketcherConstrainCoincident::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() < 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@ -967,7 +960,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() < 1 || SubNames.size() > 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@ -1037,7 +1030,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
const Part::Geometry *geom = Obj->getGeometry(GeoId2);
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg;
lineSeg = dynamic_cast<const Part::GeomLineSegment*>(geom);
lineSeg = static_cast<const Part::GeomLineSegment*>(geom);
Base::Vector3d pnt1 = lineSeg->getStartPoint();
Base::Vector3d pnt2 = lineSeg->getEndPoint();
Base::Vector3d d = pnt2-pnt1;
@ -1071,7 +1064,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
const Part::Geometry *geom = Obj->getGeometry(GeoId1);
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg;
lineSeg = dynamic_cast<const Part::GeomLineSegment*>(geom);
lineSeg = static_cast<const Part::GeomLineSegment*>(geom);
double ActLength = (lineSeg->getEndPoint()-lineSeg->getStartPoint()).Length();
openCommand("add length constraint");
@ -1148,7 +1141,7 @@ void CmdSketcherConstrainPointOnObject::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
//count curves and points
std::vector<SelIdPair> points;
@ -1234,7 +1227,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() < 1 || SubNames.size() > 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@ -1392,7 +1385,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() < 1 || SubNames.size() > 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@ -1549,7 +1542,7 @@ void CmdSketcherConstrainParallel::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
// go through the selected subelements
@ -1970,7 +1963,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() != 2 && SubNames.size() != 3){
strError = QObject::tr("Wrong number of selected objects!","tangent constraint");
@ -2224,7 +2217,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@ -2241,12 +2234,12 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
int GeoId = std::atoi(it->substr(4,4000).c_str()) - 1;
const Part::Geometry *geom = Obj->getGeometry(GeoId);
if (geom && geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>(geom);
const Part::GeomArcOfCircle *arc = static_cast<const Part::GeomArcOfCircle *>(geom);
double radius = arc->getRadius();
geoIdRadiusMap.push_back(std::make_pair(GeoId, radius));
}
else if (geom && geom->getTypeId() == Part::GeomCircle::getClassTypeId()) {
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geom);
const Part::GeomCircle *circle = static_cast<const Part::GeomCircle *>(geom);
double radius = circle->getRadius();
geoIdRadiusMap.push_back(std::make_pair(GeoId, radius));
}
@ -2255,12 +2248,12 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
int GeoId = -std::atoi(it->substr(12,4000).c_str()) - 2;
const Part::Geometry *geom = Obj->getGeometry(GeoId);
if (geom && geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>(geom);
const Part::GeomArcOfCircle *arc = static_cast<const Part::GeomArcOfCircle *>(geom);
double radius = arc->getRadius();
externalGeoIdRadiusMap.push_back(std::make_pair(GeoId, radius));
}
else if (geom && geom->getTypeId() == Part::GeomCircle::getClassTypeId()) {
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geom);
const Part::GeomCircle *circle = static_cast<const Part::GeomCircle *>(geom);
double radius = circle->getRadius();
externalGeoIdRadiusMap.push_back(std::make_pair(GeoId, radius));
}
@ -2303,7 +2296,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
Gui::Document *doc = getActiveGuiDocument();
float sf = 1.f;
if (doc && doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch *vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch *vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
sf = vp->getScaleFactor();
for (std::size_t i=0; i<externalGeoIdRadiusMap.size();i++) {
@ -2381,7 +2374,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
Gui::Document *doc = getActiveGuiDocument();
float sf = 1.f;
if (doc && doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch *vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch *vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
sf = vp->getScaleFactor();
for (std::size_t i=0; i<geoIdRadiusMap.size();i++) {
@ -2548,7 +2541,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() < 1 || SubNames.size() > 3) {
//goto ExitWithMessage;
@ -2646,8 +2639,8 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
const Part::Geometry *geom2 = Obj->getGeometry(GeoId2);
if (geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId() &&
geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg1 = dynamic_cast<const Part::GeomLineSegment*>(geom1);
const Part::GeomLineSegment *lineSeg2 = dynamic_cast<const Part::GeomLineSegment*>(geom2);
const Part::GeomLineSegment *lineSeg1 = static_cast<const Part::GeomLineSegment*>(geom1);
const Part::GeomLineSegment *lineSeg2 = static_cast<const Part::GeomLineSegment*>(geom2);
// find the two closest line ends
Sketcher::PointPos PosId1,PosId2;
@ -2718,7 +2711,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
const Part::Geometry *geom = Obj->getGeometry(GeoId1);
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg;
lineSeg = dynamic_cast<const Part::GeomLineSegment*>(geom);
lineSeg = static_cast<const Part::GeomLineSegment*>(geom);
Base::Vector3d dir = lineSeg->getEndPoint()-lineSeg->getStartPoint();
double ActAngle = atan2(dir.y,dir.x);
@ -2741,7 +2734,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
}
else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *arc;
arc = dynamic_cast<const Part::GeomArcOfCircle*>(geom);
arc = static_cast<const Part::GeomArcOfCircle*>(geom);
double startangle, endangle;
arc->getRange(startangle, endangle, /*EmulateCCWXY=*/true);
double angle = endangle - startangle;
@ -2820,7 +2813,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
// go through the selected subelements
@ -2929,7 +2922,6 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg)
{
// get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
@ -2941,6 +2933,7 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
if (SubNames.size() != 3 && SubNames.size() != 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@ -2955,7 +2948,7 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg)
getIdsFromName(SubNames[1], Obj, GeoId2, PosId2);
if (SubNames.size() == 2) {
checkBothExternal(GeoId1, GeoId2);
//checkBothExternal(GeoId1, GeoId2);
if (isVertex(GeoId1,PosId1) && isEdge(GeoId2,PosId2)) {
std::swap(GeoId1,GeoId2);
std::swap(PosId1,PosId2);
@ -3109,7 +3102,7 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg)
try{
// get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
@ -3257,7 +3250,7 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
// go through the selected subelements
if (SubNames.size() < 2) {

View File

@ -108,7 +108,7 @@ void ActivateHandler(Gui::Document *doc,DrawSketchHandler *handler)
if (doc) {
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom
(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*> (doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*> (doc->getInEdit());
vp->purgeHandler();
vp->activateHandler(handler);
}
@ -1141,7 +1141,7 @@ protected:
// Use updated startPoint/endPoint as autoconstraints can modify the position
const Part::Geometry *geom = sketchgui->getSketchObject()->getGeometry(GeoId);
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg = dynamic_cast<const Part::GeomLineSegment *>(geom);
const Part::GeomLineSegment *lineSeg = static_cast<const Part::GeomLineSegment *>(geom);
dirVec.Set(lineSeg->getEndPoint().x - lineSeg->getStartPoint().x,
lineSeg->getEndPoint().y - lineSeg->getStartPoint().y,
0.f);
@ -1153,7 +1153,7 @@ protected:
EditCurve[0] = Base::Vector2D(lineSeg->getEndPoint().x, lineSeg->getEndPoint().y);
}
else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *arcSeg = dynamic_cast<const Part::GeomArcOfCircle *>(geom);
const Part::GeomArcOfCircle *arcSeg = static_cast<const Part::GeomArcOfCircle *>(geom);
if (PosId == Sketcher::start) {
EditCurve[0] = Base::Vector2D(arcSeg->getStartPoint(/*emulateCCW=*/true).x,arcSeg->getStartPoint(/*emulateCCW=*/true).y);
dirVec = Base::Vector3d(0.f,0.f,-1.0) % (arcSeg->getStartPoint(/*emulateCCW=*/true)-arcSeg->getCenter());
@ -4152,8 +4152,8 @@ public:
construction=geom1->Construction && geom2->Construction;
if (geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId() &&
geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg1 = dynamic_cast<const Part::GeomLineSegment *>(geom1);
const Part::GeomLineSegment *lineSeg2 = dynamic_cast<const Part::GeomLineSegment *>(geom2);
const Part::GeomLineSegment *lineSeg1 = static_cast<const Part::GeomLineSegment *>(geom1);
const Part::GeomLineSegment *lineSeg2 = static_cast<const Part::GeomLineSegment *>(geom2);
Base::Vector3d dir1 = lineSeg1->getEndPoint() - lineSeg1->getStartPoint();
Base::Vector3d dir2 = lineSeg2->getEndPoint() - lineSeg2->getStartPoint();
if (PosIdList[0] == Sketcher::end)
@ -4225,9 +4225,9 @@ public:
Base::Vector2D secondPos = onSketchPos;
// guess fillet radius
const Part::GeomLineSegment *lineSeg1 = dynamic_cast<const Part::GeomLineSegment *>
const Part::GeomLineSegment *lineSeg1 = static_cast<const Part::GeomLineSegment *>
(sketchgui->getSketchObject()->getGeometry(firstCurve));
const Part::GeomLineSegment *lineSeg2 = dynamic_cast<const Part::GeomLineSegment *>
const Part::GeomLineSegment *lineSeg2 = static_cast<const Part::GeomLineSegment *>
(sketchgui->getSketchObject()->getGeometry(secondCurve));
Base::Vector3d refPnt1(firstPos.fX, firstPos.fY, 0.f);
Base::Vector3d refPnt2(secondPos.fX, secondPos.fY, 0.f);

View File

@ -61,7 +61,7 @@ bool isSketcherAcceleratorActive(Gui::Document *doc, bool actsOnSelection )
if (doc) {
// checks if a Sketch Viewprovider is in Edit and is in no special mode
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
if (dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())
if (static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())
->getSketchMode() == ViewProviderSketch::STATUS_NONE) {
if (!actsOnSelection)
return true;
@ -80,7 +80,7 @@ void ActivateAcceleratorHandler(Gui::Document *doc,DrawSketchHandler *handler)
if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom
(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*> (doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*> (doc->getInEdit());
vp->purgeHandler();
vp->activateHandler(handler);
}
@ -124,7 +124,7 @@ void CmdSketcherCloseShape::activated(int iMsg)
return;
}
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
int GeoIdFirst=-1;
int GeoIdLast=-1;
@ -233,7 +233,7 @@ void CmdSketcherConnect::activated(int iMsg)
QObject::tr("Select at least two edges from the sketch."));
return;
}
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
// undo command open
openCommand("add coincident constraint");
@ -304,7 +304,6 @@ void CmdSketcherSelectConstraints::activated(int iMsg)
{
// get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
@ -315,6 +314,7 @@ void CmdSketcherSelectConstraints::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
std::string doc_name = Obj->getDocument()->getName();
@ -366,7 +366,7 @@ void CmdSketcherSelectOrigin::activated(int iMsg)
{
Gui::Document * doc= getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
Sketcher::SketchObject* Obj= vp->getSketchObject();
@ -413,7 +413,7 @@ void CmdSketcherSelectVerticalAxis::activated(int iMsg)
{
Gui::Document * doc= getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
Sketcher::SketchObject* Obj= vp->getSketchObject();
@ -456,7 +456,7 @@ void CmdSketcherSelectHorizontalAxis::activated(int iMsg)
{
Gui::Document * doc= getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
Sketcher::SketchObject* Obj= vp->getSketchObject();
@ -498,7 +498,7 @@ void CmdSketcherSelectRedundantConstraints::activated(int iMsg)
{
Gui::Document * doc= getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
Sketcher::SketchObject* Obj= vp->getSketchObject();
@ -506,7 +506,7 @@ void CmdSketcherSelectRedundantConstraints::activated(int iMsg)
std::string obj_name = Obj->getNameInDocument();
// get the needed lists and objects
const std::vector< int > &solverredundant = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchObject()->getLastRedundant();
const std::vector< int > &solverredundant = vp->getSketchObject()->getLastRedundant();
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
getSelection().clearSelection();
@ -550,16 +550,15 @@ void CmdSketcherSelectConflictingConstraints::activated(int iMsg)
{
Gui::Document * doc= getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
Sketcher::SketchObject* Obj= vp->getSketchObject();
std::string doc_name = Obj->getDocument()->getName();
std::string obj_name = Obj->getNameInDocument();
std::stringstream ss;
// get the needed lists and objects
const std::vector< int > &solverconflicting = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchObject()->getLastConflicting();
const std::vector< int > &solverconflicting = vp->getSketchObject()->getLastConflicting();
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
getSelection().clearSelection();
@ -605,7 +604,7 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg)
Gui::Document * doc= getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
SketcherGui::ViewProviderSketch* vp = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
Sketcher::SketchObject* Obj= vp->getSketchObject();
@ -724,7 +723,6 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
{
// get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
@ -735,6 +733,7 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
std::string doc_name = Obj->getDocument()->getName();
std::string obj_name = Obj->getNameInDocument();
@ -1003,7 +1002,6 @@ void CmdSketcherSymmetry::activated(int iMsg)
{
// get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
@ -1014,10 +1012,7 @@ void CmdSketcherSymmetry::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
std::string doc_name = Obj->getDocument()->getName();
std::string obj_name = Obj->getNameInDocument();
std::stringstream ss;
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
getSelection().clearSelection();
@ -1348,7 +1343,6 @@ void SketcherCopy::activate(bool clone)
{
// get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
@ -1359,10 +1353,7 @@ void SketcherCopy::activate(bool clone)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
std::string doc_name = Obj->getDocument()->getName();
std::string obj_name = Obj->getNameInDocument();
std::stringstream ss;
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
getSelection().clearSelection();
@ -1809,7 +1800,6 @@ void CmdSketcherRectangularArray::activated(int iMsg)
{
// get the selection
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
@ -1820,10 +1810,7 @@ void CmdSketcherRectangularArray::activated(int iMsg)
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
std::string doc_name = Obj->getDocument()->getName();
std::string obj_name = Obj->getNameInDocument();
std::stringstream ss;
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
getSelection().clearSelection();

View File

@ -252,7 +252,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
for (std::vector<Part::Geometry *>::const_iterator it=geomlist.begin(); it != geomlist.end(); ++it, i++) {
if ((*it)->getTypeId() == Part::GeomCircle::getClassTypeId()) {
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>((*it));
const Part::GeomCircle *circle = static_cast<const Part::GeomCircle *>((*it));
Base::Vector3d center = circle->getCenter();
@ -274,7 +274,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
} else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) {
const Part::GeomEllipse *ellipse = dynamic_cast<const Part::GeomEllipse *>((*it));
const Part::GeomEllipse *ellipse = static_cast<const Part::GeomEllipse *>((*it));
Base::Vector3d center = ellipse->getCenter();
@ -301,7 +301,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
}
} else if ((*it)->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>((*it));
const Part::GeomArcOfCircle *arc = static_cast<const Part::GeomArcOfCircle *>((*it));
Base::Vector3d center = arc->getCenter();
double radius = arc->getRadius();
@ -329,7 +329,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
}
}
} else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) {
const Part::GeomArcOfEllipse *aoe = dynamic_cast<const Part::GeomArcOfEllipse *>((*it));
const Part::GeomArcOfEllipse *aoe = static_cast<const Part::GeomArcOfEllipse *>((*it));
Base::Vector3d center = aoe->getCenter();
@ -433,7 +433,7 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>
bool mid_external;
bool end_external;
dynamic_cast<Sketcher::SketchObject*>((sketchgui->getObject()))->isCoincidentWithExternalGeometry(geoId1, start_external, mid_external, end_external);
static_cast<Sketcher::SketchObject*>((sketchgui->getObject()))->isCoincidentWithExternalGeometry(geoId1, start_external, mid_external, end_external);
if( !(start_external && end_external) ) {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Horizontal',%i)) "
@ -449,7 +449,7 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>
bool mid_external;
bool end_external;
dynamic_cast<Sketcher::SketchObject*>((sketchgui->getObject()))->isCoincidentWithExternalGeometry(geoId1, start_external, mid_external, end_external);
static_cast<Sketcher::SketchObject*>((sketchgui->getObject()))->isCoincidentWithExternalGeometry(geoId1, start_external, mid_external, end_external);
if( !(start_external && end_external) ) {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Vertical',%i)) "
@ -460,7 +460,7 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>
} break;
case Sketcher::Tangent: {
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(sketchgui->getObject());
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(sketchgui->getObject());
const Part::Geometry *geom1 = Obj->getGeometry(geoId1);
const Part::Geometry *geom2 = Obj->getGeometry(it->GeoId);

View File

@ -40,7 +40,8 @@ TYPESYSTEM_SOURCE(SketcherGui::PropertyConstraintListItem, Gui::PropertyEditor::
PropertyConstraintListItem::PropertyConstraintListItem()
{
blockEvent = false;
onlyUnnamed = false;
}
QVariant PropertyConstraintListItem::toString(const QVariant& prop) const

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -40,6 +40,7 @@ using namespace SketcherGui;
SketchOrientationDialog::SketchOrientationDialog(void)
: QDialog(Gui::getMainWindow()), ui(new Ui_SketchOrientationDialog)
{
DirType = 0;
ui->setupUi(this);
onPreview();

View File

@ -320,6 +320,9 @@ protected:
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
ConstraintItem * item = dynamic_cast<ConstraintItem*>(view->item(index.row()));
if (!item)
return;
App::ObjectIdentifier path = item->sketch->Constraints.createPath(item->ConstraintNbr);
App::PropertyExpressionEngine::ExpressionInfo expr_info = item->sketch->getExpression(path);
@ -362,9 +365,8 @@ void ConstraintView::contextMenuEvent (QContextMenuEvent* event)
bool isToggleDriving = false;
// Non-driving-constraints/measurements
if (item) {
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
if (it) {
// if its the right constraint
if ((it->constraintType() == Sketcher::Distance ||
it->constraintType() == Sketcher::DistanceX ||
@ -416,11 +418,10 @@ void ConstraintView::updateDrivingStatus()
{
QListWidgetItem* item = currentItem();
if (item){
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
if (it) {
onUpdateDrivingStatus(item, !it->isDriving());
}
}
}
void ConstraintView::modifyCurrentItem()
@ -623,7 +624,7 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemSelectionChanged(void)
void TaskSketcherConstrains::on_listWidgetConstraints_itemActivated(QListWidgetItem *item)
{
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
if (!item) return;
if (!it) return;
// if its the right constraint
if (it->constraintType() == Sketcher::Distance ||
@ -650,12 +651,12 @@ void TaskSketcherConstrains::on_listWidgetConstraints_updateDrivingStatus(QListW
void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetItem *item)
{
if (!item || inEditMode)
const ConstraintItem *it = dynamic_cast<const ConstraintItem*>(item);
if (!it || inEditMode)
return;
inEditMode = true;
const ConstraintItem *it = dynamic_cast<const ConstraintItem*>(item);
const Sketcher::SketchObject * sketch = sketchView->getSketchObject();
const std::vector< Sketcher::Constraint * > &vals = sketch->Constraints.getValues();
const Sketcher::Constraint* v = vals[it->ConstraintNbr];