[TD] last part of removal of superfluous nullptr checks
This commit is contained in:
@@ -111,17 +111,14 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::s
|
||||
CosmeticVertex* result = nullptr;
|
||||
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
|
||||
if (dvp == nullptr) {
|
||||
if (!dvp)
|
||||
return result;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
TechDraw::VertexPtr v = dvp->getProjVertexByIndex(idx);
|
||||
if (!v) {
|
||||
if (!v)
|
||||
return result;
|
||||
}
|
||||
if (!v->cosmeticTag.empty()) {
|
||||
if (!v->cosmeticTag.empty())
|
||||
result = getCosmeticVertex(v->cosmeticTag);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -424,9 +421,8 @@ TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(std::string na
|
||||
GeomFormat* result = nullptr;
|
||||
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
|
||||
if (dvp == nullptr) {
|
||||
if (!dvp)
|
||||
return result;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
const std::vector<TechDraw::GeomFormat*> formats = GeomFormats.getValues();
|
||||
for (auto& gf: formats) {
|
||||
|
||||
@@ -263,7 +263,7 @@ TechDraw::DrawPage * DrawProjGroup::getPage(void) const
|
||||
double DrawProjGroup::calculateAutomaticScale() const
|
||||
{
|
||||
TechDraw::DrawPage *page = getPage();
|
||||
if (page == nullptr)
|
||||
if (!page)
|
||||
throw Base::RuntimeError("No page is assigned to this feature");
|
||||
|
||||
DrawProjGroupItem *viewPtrs[10];
|
||||
@@ -405,7 +405,7 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const
|
||||
{
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
|
||||
if (view == nullptr) {
|
||||
if (!view) {
|
||||
//should never have a item in DPG that is not a DPGI.
|
||||
Base::Console().Log("PROBLEM - DPG::hasProjection finds non-DPGI in Group %s / %s\n",
|
||||
getNameInDocument(),viewProjType);
|
||||
@@ -942,11 +942,10 @@ void DrawProjGroup::recomputeChildren(void)
|
||||
// Base::Console().Message("DPG::recomputeChildren()\n");
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (view == nullptr) {
|
||||
if (!view)
|
||||
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
|
||||
} else {
|
||||
else
|
||||
view->recomputeFeature();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,11 +953,10 @@ void DrawProjGroup::autoPositionChildren(void)
|
||||
{
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (view == nullptr) {
|
||||
if (!view)
|
||||
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
|
||||
} else {
|
||||
else
|
||||
view->autoPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -970,7 +968,7 @@ void DrawProjGroup::updateChildrenScale(void)
|
||||
// Base::Console().Message("DPG::updateChildrenScale\n");
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (view == nullptr) {
|
||||
if (!view) {
|
||||
//if an element in Views is not a DPGI, something really bad has happened somewhere
|
||||
Base::Console().Log("PROBLEM - DPG::updateChildrenScale - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
@@ -988,7 +986,7 @@ void DrawProjGroup::updateChildrenSource(void)
|
||||
{
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (view == nullptr) {
|
||||
if (!view) {
|
||||
//if an element in Views is not a DPGI, something really bad has happened somewhere
|
||||
Base::Console().Log("PROBLEM - DPG::updateChildrenSource - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
@@ -1012,7 +1010,7 @@ void DrawProjGroup::updateChildrenLock(void)
|
||||
{
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (view == nullptr) {
|
||||
if (!view) {
|
||||
//if an element in Views is not a DPGI, something really bad has happened somewhere
|
||||
Base::Console().Log("PROBLEM - DPG::updateChildrenLock - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
@@ -1027,7 +1025,7 @@ void DrawProjGroup::updateViews(void) {
|
||||
// this is intended to update the views in general, e.g. when the spacing changed
|
||||
for (const auto it : Views.getValues()) {
|
||||
auto view(dynamic_cast<DrawProjGroupItem *>(it));
|
||||
if (view == nullptr) {
|
||||
if (!view) {
|
||||
//if an element in Views is not a DPGI, something really bad has happened somewhere
|
||||
Base::Console().Log("PROBLEM - DPG::updateViews - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
@@ -1042,7 +1040,7 @@ void DrawProjGroup::updateChildrenEnforce(void)
|
||||
{
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (view == nullptr) {
|
||||
if (!view) {
|
||||
//if an element in Views is not a DPGI, something really bad has happened somewhere
|
||||
Base::Console().Log("PROBLEM - DPG::updateChildrenEnforce - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
|
||||
@@ -497,9 +497,8 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
|
||||
}
|
||||
|
||||
const BaseGeomPtrVector& edges = go->getEdgeGeometry();
|
||||
if (edges.empty()) {
|
||||
if (edges.empty())
|
||||
Base::Console().Log("DVP::buildGO - NO extracted edges!\n");
|
||||
}
|
||||
bbox = go->calcBoundingBox();
|
||||
return go;
|
||||
}
|
||||
@@ -507,9 +506,8 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
|
||||
//! make faces from the existing edge geometry
|
||||
void DrawViewPart::extractFaces()
|
||||
{
|
||||
if (geometryObject == nullptr) {
|
||||
if (!geometryObject)
|
||||
return;
|
||||
}
|
||||
geometryObject->clearFaceGeom();
|
||||
const std::vector<TechDraw::BaseGeomPtr>& goEdges =
|
||||
geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
|
||||
@@ -876,9 +874,8 @@ BaseGeomPtr DrawViewPart::projectEdge(const TopoDS_Edge& e) const
|
||||
bool DrawViewPart::hasGeometry(void) const
|
||||
{
|
||||
bool result = false;
|
||||
if (geometryObject == nullptr) {
|
||||
if (!geometryObject)
|
||||
return result;
|
||||
}
|
||||
const std::vector<TechDraw::VertexPtr> &verts = getVertexGeometry();
|
||||
const std::vector<TechDraw::BaseGeomPtr> &edges = getEdgeGeometry();
|
||||
if (verts.empty() &&
|
||||
@@ -1390,7 +1387,7 @@ void DrawViewPart::clearGeomFormats(void)
|
||||
|
||||
void DrawViewPart::dumpVerts(std::string text)
|
||||
{
|
||||
if (geometryObject == nullptr) {
|
||||
if (!geometryObject) {
|
||||
Base::Console().Message("no verts to dump yet\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -310,11 +310,10 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
if (ce) {
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
if (!pColor)
|
||||
ce->m_format.m_color = defCol;
|
||||
} else {
|
||||
else
|
||||
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
|
||||
}
|
||||
} else {
|
||||
std::string msg = "DVPPI:makeCosmeticLine - line creation failed";
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
@@ -358,11 +357,10 @@ PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args)
|
||||
if (ce) {
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
if (!pColor)
|
||||
ce->m_format.m_color = defCol;
|
||||
} else {
|
||||
else
|
||||
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
|
||||
}
|
||||
} else {
|
||||
std::string msg = "DVPPI:makeCosmeticLine - line creation failed";
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
@@ -398,11 +396,10 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
ce->permaRadius = radius;
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
if (!pColor)
|
||||
ce->m_format.m_color = defCol;
|
||||
} else {
|
||||
else
|
||||
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
|
||||
}
|
||||
} else {
|
||||
std::string msg = "DVPPI:makeCosmeticCircle - circle creation failed";
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
@@ -441,11 +438,10 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
ce->permaRadius = radius;
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
if (!pColor)
|
||||
ce->m_format.m_color = defCol;
|
||||
} else {
|
||||
else
|
||||
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
|
||||
}
|
||||
} else {
|
||||
std::string msg = "DVPPI:makeCosmeticCircleArc - arc creation failed";
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
@@ -690,17 +686,15 @@ PyObject* DrawViewPartPy::formatGeometricEdge(PyObject *args)
|
||||
PyObject* DrawViewPartPy::getEdgeByIndex(PyObject *args)
|
||||
{
|
||||
int edgeIndex = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &edgeIndex)) {
|
||||
if (!PyArg_ParseTuple(args, "i", &edgeIndex))
|
||||
throw Py::TypeError("expected (edgeIndex)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
|
||||
//this is scaled and +Yup
|
||||
//need unscaled and +Ydown
|
||||
TechDraw::BaseGeomPtr geom = dvp->getGeomByIndex(edgeIndex);
|
||||
if (geom == nullptr) {
|
||||
if (!geom)
|
||||
throw Py::ValueError("wrong edgeIndex");
|
||||
}
|
||||
|
||||
TopoDS_Shape temp = TechDraw::mirrorShapeVec(geom->occEdge,
|
||||
Base::Vector3d(0.0, 0.0, 0.0),
|
||||
|
||||
@@ -130,7 +130,7 @@ void CmdTechDrawLeaderLine::activated(int iMsg)
|
||||
TechDraw::DrawView* baseFeat = nullptr;
|
||||
if (!selection.empty()) {
|
||||
baseFeat = dynamic_cast<TechDraw::DrawView *>(selection[0].getObject());
|
||||
if( baseFeat == nullptr ) {
|
||||
if (!baseFeat) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"),
|
||||
QObject::tr("Can not attach leader. No base View selected."));
|
||||
return;
|
||||
@@ -347,10 +347,8 @@ void execMidpoints(Gui::Command* cmd)
|
||||
TechDraw::DrawViewPart * dvp = nullptr;
|
||||
std::vector<std::string> selectedEdges = getSelectedSubElements(cmd, dvp, "Edge");
|
||||
|
||||
if ( (dvp == nullptr) ||
|
||||
(selectedEdges.empty()) ) {
|
||||
if (!dvp || selectedEdges.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add Midpoint Vertices"));
|
||||
|
||||
@@ -375,10 +373,8 @@ void execQuadrants(Gui::Command* cmd)
|
||||
TechDraw::DrawViewPart* dvp = nullptr;
|
||||
std::vector<std::string> selectedEdges = getSelectedSubElements(cmd, dvp, "Edge");
|
||||
|
||||
if ( (dvp == nullptr) ||
|
||||
(selectedEdges.empty()) ) {
|
||||
if (!dvp || selectedEdges.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add Quadrant Vertices"));
|
||||
|
||||
@@ -438,7 +434,7 @@ void CmdTechDrawCosmeticVertex::activated(int iMsg)
|
||||
|
||||
TechDraw::DrawViewPart* baseFeat = nullptr;
|
||||
baseFeat = dynamic_cast<TechDraw::DrawViewPart*>((*shapes.begin()));
|
||||
if (baseFeat == nullptr) {
|
||||
if (!baseFeat) {
|
||||
Base::Console().Message("CMD::CosmeticVertex - 1st shape is not DVP. WTF?\n");
|
||||
return;
|
||||
}
|
||||
@@ -1052,7 +1048,7 @@ void execLine2Points(Gui::Command* cmd)
|
||||
}
|
||||
}
|
||||
|
||||
if (baseFeat == nullptr) {
|
||||
if (!baseFeat) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"),
|
||||
QObject::tr("You must select a base View for the line."));
|
||||
return;
|
||||
@@ -1215,14 +1211,12 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
|
||||
}
|
||||
} else if (geomType == "Vertex") {
|
||||
TechDraw::VertexPtr tdv = objFeat->getProjVertexByIndex(idx);
|
||||
if (tdv == nullptr) {
|
||||
if (!tdv)
|
||||
Base::Console().Message("CMD::eraser - geom: %d not found!\n", idx);
|
||||
}
|
||||
|
||||
std::string delTag = tdv->cosmeticTag;
|
||||
if (delTag.empty()) {
|
||||
if (delTag.empty())
|
||||
Base::Console().Warning("Vertex%d is not cosmetic! Can not erase.\n", idx);
|
||||
}
|
||||
cv2Delete.push_back(delTag);
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
@@ -1295,7 +1289,7 @@ void CmdTechDrawDecorateLine::activated(int iMsg)
|
||||
}
|
||||
|
||||
baseFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
if( baseFeat == nullptr ) {
|
||||
if (!baseFeat) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"),
|
||||
QObject::tr("No View in Selection."));
|
||||
return;
|
||||
@@ -1504,7 +1498,7 @@ std::vector<std::string> getSelectedSubElements(Gui::Command* cmd,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dvp == nullptr) {
|
||||
if (!dvp) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"),
|
||||
QObject::tr("No Part View in Selection"));
|
||||
return selectedSubs;
|
||||
|
||||
@@ -259,10 +259,8 @@ void QGILeaderLine::onLineEditFinished(QPointF tipDisplace, std::vector<QPointF>
|
||||
// points.size());
|
||||
m_blockDraw = true;
|
||||
auto featLeader = getFeature();
|
||||
if (featLeader == nullptr) {
|
||||
//tarfu
|
||||
if (!featLeader)
|
||||
return;
|
||||
}
|
||||
double baseScale = featLeader->getBaseScale();
|
||||
|
||||
if ( !(TechDraw::DrawUtil::fpCompare(tipDisplace.x(),0.0) &&
|
||||
@@ -299,9 +297,8 @@ void QGILeaderLine::startPathEdit(void)
|
||||
{
|
||||
saveState();
|
||||
auto featLeader( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
|
||||
if (featLeader == nullptr) {
|
||||
if (!featLeader)
|
||||
return;
|
||||
}
|
||||
|
||||
double scale = featLeader->getScale();
|
||||
m_editPath->setScale(scale);
|
||||
@@ -346,46 +343,38 @@ void QGILeaderLine::updateView(bool update)
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
if (!vp)
|
||||
return;
|
||||
}
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGILeaderLine::draw()
|
||||
{
|
||||
// Base::Console().Message("QGILL::draw()- %s\n", getViewObject()->getNameInDocument());
|
||||
if (m_blockDraw) {
|
||||
if (m_blockDraw)
|
||||
return;
|
||||
}
|
||||
if (!isVisible()) {
|
||||
if (!isVisible())
|
||||
return;
|
||||
}
|
||||
TechDraw::DrawLeaderLine* featLeader = getFeature();
|
||||
if((!featLeader) ) {
|
||||
if (!featLeader)
|
||||
return;
|
||||
}
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
if (!vp)
|
||||
return;
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
TechDraw::DrawView* parent = featLeader->getBaseView();
|
||||
if (parent) {
|
||||
if (parent)
|
||||
scale = parent->getScale();
|
||||
}
|
||||
|
||||
if (m_editPath->inEdit()) {
|
||||
if (m_editPath->inEdit())
|
||||
return;
|
||||
}
|
||||
|
||||
//********
|
||||
if (featLeader->isLocked()) {
|
||||
if (featLeader->isLocked())
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
} else {
|
||||
else
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
}
|
||||
m_lineStyle = (Qt::PenStyle) vp->LineStyle.getValue();
|
||||
|
||||
double baseScale = featLeader->getBaseScale();
|
||||
@@ -427,7 +416,7 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)
|
||||
// Base::Console().Message("QGILeaderLine::makeLeaderPath()\n");
|
||||
QPainterPath result;
|
||||
DrawLeaderLine* featLeader = getFeature();
|
||||
if (featLeader == nullptr) {
|
||||
if (!featLeader) {
|
||||
Base::Console().Message("QGILL::makeLeaderPath - featLeader is nullptr\n");
|
||||
return result;
|
||||
}
|
||||
@@ -489,7 +478,7 @@ std::vector<QPointF> QGILeaderLine::getWayPointsFromFeature(void)
|
||||
std::vector<QPointF> qPoints;
|
||||
|
||||
DrawLeaderLine* featLeader = getFeature();
|
||||
if (featLeader == nullptr) {
|
||||
if (!featLeader) {
|
||||
Base::Console().Message("QGILL::getWayPointsFromFeature - featLeader is nullptr\n");
|
||||
return qPoints;
|
||||
}
|
||||
@@ -576,9 +565,8 @@ void QGILeaderLine::abandonEdit(void)
|
||||
double QGILeaderLine::getLineWidth(void)
|
||||
{
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
if (!vp)
|
||||
return Rez::guiX(LineGroup::getDefaultWidth("Graphic"));
|
||||
}
|
||||
return Rez::guiX(vp->LineWidth.getValue());
|
||||
}
|
||||
|
||||
@@ -600,16 +588,14 @@ QColor QGILeaderLine::getNormalColor()
|
||||
m_colNormal = PreferencesGui::leaderQColor();
|
||||
|
||||
auto lead( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
|
||||
if (!lead) {
|
||||
if (!lead)
|
||||
// Base::Console().Message("QGILL::getNormalColor - no feature\n");
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
if (!vp)
|
||||
// Base::Console().Message("QGILL::getNormalColor - no viewProvider\n");
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
m_colNormal = vp->Color.getValue().asValue<QColor>();
|
||||
return m_colNormal;
|
||||
|
||||
@@ -177,13 +177,13 @@ void QGIDatumLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGIDatumLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
QGIViewDimension* qgivDimension = dynamic_cast<QGIViewDimension*>(parentItem());
|
||||
if (qgivDimension == nullptr) {
|
||||
if (!qgivDimension) {
|
||||
qWarning() << "QGIDatumLabel::mouseDoubleClickEvent: No parent item";
|
||||
return;
|
||||
}
|
||||
|
||||
auto ViewProvider = dynamic_cast<ViewProviderDimension*>(qgivDimension->getViewProvider(qgivDimension->getViewObject()));
|
||||
if (ViewProvider == nullptr) {
|
||||
if (!ViewProvider) {
|
||||
qWarning() << "QGIDatumLabel::mouseDoubleClickEvent: No valid view provider";
|
||||
return;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ void QGIDatumLabel::setToleranceString()
|
||||
if (!qgivd)
|
||||
return;
|
||||
const auto dim( dynamic_cast<TechDraw::DrawViewDimension *>(qgivd->getViewObject()) );
|
||||
if( dim == nullptr ) {
|
||||
if (!dim) {
|
||||
return;
|
||||
// don't show if both are zero or if EqualTolerance is true
|
||||
} else if (!dim->hasOverUnderTolerance() || dim->EqualTolerance.getValue() || dim->TheoreticalExact.getValue()) {
|
||||
@@ -645,18 +645,15 @@ void QGIViewDimension::updateView(bool update)
|
||||
void QGIViewDimension::updateDim()
|
||||
{
|
||||
const auto dim( dynamic_cast<TechDraw::DrawViewDimension *>(getViewObject()) );
|
||||
if( dim == nullptr ) {
|
||||
if (!dim)
|
||||
return;
|
||||
}
|
||||
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
if (!vp)
|
||||
return;
|
||||
}
|
||||
|
||||
QString labelText= QString::fromUtf8(dim->getFormattedDimensionValue(1).c_str()); // pre value [unit] post
|
||||
if (dim->isMultiValueSchema()) {
|
||||
if (dim->isMultiValueSchema())
|
||||
labelText = QString::fromUtf8(dim->getFormattedDimensionValue(0).c_str()); //don't format multis
|
||||
}
|
||||
|
||||
QFont font = datumLabel->getFont();
|
||||
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
|
||||
@@ -682,9 +679,8 @@ void QGIViewDimension::datumLabelDragFinished()
|
||||
{
|
||||
auto dim( dynamic_cast<TechDraw::DrawViewDimension *>(getViewObject()) );
|
||||
|
||||
if( dim == nullptr ) {
|
||||
if (!dim)
|
||||
return;
|
||||
}
|
||||
|
||||
double x = Rez::appX(datumLabel->X()),
|
||||
y = Rez::appX(datumLabel->Y());
|
||||
@@ -718,26 +714,25 @@ void QGIViewDimension::draw()
|
||||
}
|
||||
|
||||
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(getViewObject());
|
||||
if((!dim) || //nothing to draw, don't try
|
||||
(!dim->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) ||
|
||||
(!dim->has2DReferences()) ) {
|
||||
if (!dim ||//nothing to draw, don't try
|
||||
!dim->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId()) ||
|
||||
!dim->has2DReferences()) {
|
||||
datumLabel->hide();
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
|
||||
const TechDraw::DrawViewPart *refObj = dim->getViewPart();
|
||||
if (refObj == nullptr) {
|
||||
if (!refObj)
|
||||
return;
|
||||
}
|
||||
if(!refObj->hasGeometry()) { //nothing to draw yet (restoring)
|
||||
if (!refObj->hasGeometry()) { //nothing to draw yet (restoring)
|
||||
datumLabel->hide();
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
|
||||
if (vp == nullptr) {
|
||||
if (!vp) {
|
||||
datumLabel->show();
|
||||
show();
|
||||
return;
|
||||
@@ -1253,7 +1248,7 @@ void QGIViewDimension::drawArrows(int count, const Base::Vector2d positions[], d
|
||||
void QGIViewDimension::arrowPositionsToFeature(const Base::Vector2d positions[]) const
|
||||
{
|
||||
auto dim( dynamic_cast<TechDraw::DrawViewDimension*>(getViewObject()) );
|
||||
if( dim == nullptr )
|
||||
if (!dim)
|
||||
return;
|
||||
|
||||
dim->saveArrowPositions(positions);
|
||||
@@ -2371,9 +2366,8 @@ QColor QGIViewDimension::prefNormalColor()
|
||||
TechDraw::DrawView* dv = getViewObject();
|
||||
if (dv) {
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension*>(dv);
|
||||
if( dim == nullptr ) {
|
||||
if (!dim)
|
||||
return m_colNormal;
|
||||
}
|
||||
} else {
|
||||
return m_colNormal;
|
||||
}
|
||||
@@ -2382,9 +2376,8 @@ QColor QGIViewDimension::prefNormalColor()
|
||||
Gui::ViewProvider* vp = getViewProvider(dim);
|
||||
if (vp) {
|
||||
vpDim = dynamic_cast<ViewProviderDimension*>(vp);
|
||||
if (vpDim == nullptr) {
|
||||
if (!vpDim)
|
||||
return m_colNormal;
|
||||
}
|
||||
} else {
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
@@ -215,9 +215,8 @@ void TaskSectionView::setUiEdit()
|
||||
void TaskSectionView::saveSectionState()
|
||||
{
|
||||
// Base::Console().Message("TSV::saveSectionState()\n");
|
||||
if (m_section == nullptr) {
|
||||
if (!m_section)
|
||||
return;
|
||||
}
|
||||
|
||||
m_saveSymbol = m_section->SectionSymbol.getValue();
|
||||
m_saveScale = m_section->getScale();
|
||||
@@ -233,9 +232,8 @@ void TaskSectionView::saveSectionState()
|
||||
void TaskSectionView::restoreSectionState()
|
||||
{
|
||||
// Base::Console().Message("TSV::restoreSectionState()\n");
|
||||
if (m_section == nullptr) {
|
||||
if (!m_section)
|
||||
return;
|
||||
}
|
||||
|
||||
m_section->SectionSymbol.setValue(m_saveSymbol);
|
||||
m_section->Scale.setValue(m_saveScale);
|
||||
@@ -376,9 +374,8 @@ void TaskSectionView::applyQuick(std::string dir)
|
||||
{
|
||||
// Base::Console().Message("TSV::applyQuick(%s)\n", dir.c_str());
|
||||
m_dirName = dir;
|
||||
if (m_section == nullptr) {
|
||||
if (!m_section)
|
||||
createSectionView();
|
||||
}
|
||||
|
||||
if (!isSectionValid()) {
|
||||
failNoObject(m_sectionName);
|
||||
@@ -389,9 +386,8 @@ void TaskSectionView::applyQuick(std::string dir)
|
||||
enableAll(true);
|
||||
|
||||
m_section->recomputeFeature();
|
||||
if (isBaseValid()) {
|
||||
if (isBaseValid())
|
||||
m_base->requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSectionView::applyAligned(void)
|
||||
@@ -417,7 +413,7 @@ void TaskSectionView::createSectionView(void)
|
||||
std::string baseName = m_base->getNameInDocument();
|
||||
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create SectionView"));
|
||||
if (m_section == nullptr) {
|
||||
if (!m_section) {
|
||||
m_sectionName = m_base->getDocument()->getUniqueObjectName("SectionView");
|
||||
std::string sectionType = "TechDraw::DrawViewSection";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user