[TD]CI clang warnings
This commit is contained in:
@@ -43,13 +43,9 @@
|
||||
#include "DrawPage.h"
|
||||
#include "DrawViewCollection.h"
|
||||
#include "DrawViewClip.h"
|
||||
#include "DrawProjGroup.h"
|
||||
#include "DrawProjGroupItem.h"
|
||||
#include "DrawLeaderLine.h"
|
||||
#include "Preferences.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "Geometry.h"
|
||||
#include "Cosmetic.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawViewPy.h> // generated from DrawViewPy.xml
|
||||
|
||||
@@ -65,9 +61,10 @@ const char* DrawView::ScaleTypeEnums[]= {"Page",
|
||||
"Automatic",
|
||||
"Custom",
|
||||
nullptr};
|
||||
const double SCALEINCREMENT(0.1);
|
||||
App::PropertyFloatConstraint::Constraints DrawView::scaleRange = {Precision::Confusion(),
|
||||
std::numeric_limits<double>::max(),
|
||||
(0.1)}; // increment by 0.1
|
||||
(SCALEINCREMENT)}; // increment by 0.1
|
||||
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawView, App::DocumentObject)
|
||||
@@ -128,40 +125,46 @@ void DrawView::onChanged(const App::Property* prop)
|
||||
//Coding note: calling execute, recompute or recomputeFeature inside an onChanged
|
||||
//method can create infinite loops if the called method changes a property. In general
|
||||
//don't do this! There are situations where it is OK, but careful analysis is a must.
|
||||
if (!isRestoring()) {
|
||||
if (prop == &ScaleType) {
|
||||
auto page = findParentPage();
|
||||
if (ScaleType.isValue("Page")) {
|
||||
Scale.setStatus(App::Property::ReadOnly, true);
|
||||
if (page) {
|
||||
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
|
||||
Scale.setValue(page->Scale.getValue());
|
||||
}
|
||||
}
|
||||
} else if ( ScaleType.isValue("Custom") ) {
|
||||
//don't change Scale
|
||||
Scale.setStatus(App::Property::ReadOnly, false);
|
||||
} else if ( ScaleType.isValue("Automatic") ) {
|
||||
Scale.setStatus(App::Property::ReadOnly, true);
|
||||
if (!checkFit(page)) {
|
||||
double newScale = autoScale(page->getPageWidth(), page->getPageHeight());
|
||||
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
|
||||
Scale.setValue(newScale);
|
||||
}
|
||||
if (isRestoring()) {
|
||||
App::DocumentObject::onChanged(prop);
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop == &ScaleType) {
|
||||
auto page = findParentPage();
|
||||
if (!page) {
|
||||
//we don't belong to a page yet, so don't bother
|
||||
return;
|
||||
}
|
||||
if (ScaleType.isValue("Page")) {
|
||||
Scale.setStatus(App::Property::ReadOnly, true);
|
||||
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
|
||||
Scale.setValue(page->Scale.getValue());
|
||||
}
|
||||
} else if ( ScaleType.isValue("Custom") ) {
|
||||
//don't change Scale
|
||||
Scale.setStatus(App::Property::ReadOnly, false);
|
||||
} else if ( ScaleType.isValue("Automatic") ) {
|
||||
Scale.setStatus(App::Property::ReadOnly, true);
|
||||
if (!checkFit(page)) {
|
||||
double newScale = autoScale(page->getPageWidth(), page->getPageHeight());
|
||||
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
|
||||
Scale.setValue(newScale);
|
||||
}
|
||||
}
|
||||
} else if (prop == &LockPosition) {
|
||||
handleXYLock();
|
||||
requestPaint(); //change lock icon
|
||||
LockPosition.purgeTouched();
|
||||
} else if ((prop == &Caption) ||
|
||||
(prop == &Label)) {
|
||||
requestPaint();
|
||||
} else if ((prop == &X) ||
|
||||
(prop == &Y)) {
|
||||
//X,Y changes are only interesting to DPGI and Gui side
|
||||
}
|
||||
} else if (prop == &LockPosition) {
|
||||
handleXYLock();
|
||||
requestPaint(); //change lock icon
|
||||
LockPosition.purgeTouched();
|
||||
} else if ((prop == &Caption) ||
|
||||
(prop == &Label)) {
|
||||
requestPaint();
|
||||
} else if ( prop == &X ||
|
||||
prop == &Y ) {
|
||||
//X,Y changes are only interesting to DPGI and Gui side
|
||||
}
|
||||
|
||||
App::DocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
@@ -215,7 +218,7 @@ short DrawView::mustExecute() const
|
||||
////you must override this in derived class
|
||||
QRectF DrawView::getRect() const
|
||||
{
|
||||
QRectF result(0,0,1,1);
|
||||
QRectF result(0, 0,1, 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -224,7 +227,6 @@ void DrawView::onDocumentRestored()
|
||||
handleXYLock();
|
||||
setScaleAttribute();
|
||||
validateScale();
|
||||
DrawView::execute();
|
||||
}
|
||||
|
||||
//in versions before 0.20 Scale and ScaleType were mishandled.
|
||||
@@ -244,7 +246,6 @@ void DrawView::validateScale()
|
||||
double myScale = Scale.getValue();
|
||||
if (!DrawUtil::fpCompare(pageScale, myScale)) {
|
||||
ScaleType.setValue("Custom");
|
||||
ScaleType.purgeTouched();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,10 +358,10 @@ double DrawView::autoScale() const
|
||||
auto page = findParentPage();
|
||||
double w = page->getPageWidth();
|
||||
double h = page->getPageHeight();
|
||||
return autoScale(w,h);
|
||||
return autoScale(w, h);
|
||||
}
|
||||
|
||||
//compare 1:1 rect of view to pagesize(pw,h)
|
||||
//compare 1:1 rect of view to pagesize(pw, h)
|
||||
double DrawView::autoScale(double pw, double ph) const
|
||||
{
|
||||
// Base::Console().Message("DV::autoScale(Page: %.3f, %.3f) - %s\n", pw, ph, getNameInDocument());
|
||||
@@ -374,7 +375,7 @@ double DrawView::autoScale(double pw, double ph) const
|
||||
double vbh = viewBox.height()/getScale();
|
||||
double xScale = pw/vbw; // > 1 page bigger than figure
|
||||
double yScale = ph/vbh; // < 1 page is smaller than figure
|
||||
double newScale = std::min(xScale,yScale) * fudgeFactor;
|
||||
double newScale = std::min(xScale, yScale) * fudgeFactor;
|
||||
double sensibleScale = DrawUtil::sensibleScale(newScale);
|
||||
return sensibleScale;
|
||||
}
|
||||
@@ -413,7 +414,7 @@ bool DrawView::checkFit(TechDraw::DrawPage* p) const
|
||||
|
||||
void DrawView::setPosition(double x, double y, bool force)
|
||||
{
|
||||
// Base::Console().Message("DV::setPosition(%.3f,%.3f) - \n",x,y,getNameInDocument());
|
||||
// Base::Console().Message("DV::setPosition(%.3f, %.3f) - \n", x,y, getNameInDocument());
|
||||
if ( (!isLocked()) ||
|
||||
(force) ) {
|
||||
double currX = X.getValue();
|
||||
@@ -438,7 +439,7 @@ double DrawView::getScale() const
|
||||
}
|
||||
if (!(result > 0.0)) {
|
||||
result = 1.0;
|
||||
Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue());
|
||||
Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n", getNameInDocument(), Scale.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -461,7 +462,7 @@ void DrawView::handleChangedPropertyType(Base::XMLReader &reader, const char * T
|
||||
{
|
||||
if (prop == &Scale) {
|
||||
App::PropertyFloat tmp;
|
||||
if (strcmp(tmp.getTypeId().getName(),TypeName)==0) { //property in file is Float
|
||||
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { //property in file is Float
|
||||
tmp.setContainer(this);
|
||||
tmp.Restore(reader);
|
||||
double tmpValue = tmp.getValue();
|
||||
@@ -499,7 +500,7 @@ void DrawView::handleChangedPropertyType(Base::XMLReader &reader, const char * T
|
||||
}
|
||||
|
||||
// property X had App::PropertyFloat and was changed to App::PropertyLength
|
||||
// and later to PropertyDistance because some X,Y are relative to existing points on page
|
||||
// and later to PropertyDistance because some X, Y are relative to existing points on page
|
||||
else if (prop == &X && strcmp(TypeName, "App::PropertyFloat") == 0) {
|
||||
App::PropertyFloat XProperty;
|
||||
XProperty.setContainer(this);
|
||||
@@ -550,7 +551,7 @@ void DrawView::setScaleAttribute()
|
||||
{
|
||||
if (ScaleType.isValue("Page") ||
|
||||
ScaleType.isValue("Automatic")) {
|
||||
Scale.setStatus(App::Property::ReadOnly,true);
|
||||
Scale.setStatus(App::Property::ReadOnly, true);
|
||||
} else {
|
||||
Scale.setStatus(App::Property::ReadOnly, false);
|
||||
}
|
||||
@@ -568,7 +569,7 @@ double DrawView::prefScale()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
double result = hGrp->GetFloat("DefaultViewScale", 1.0);
|
||||
double result = hGrp->GetFloat("DefaultViewScale", 1.0);
|
||||
if (ScaleType.isValue("Page")) {
|
||||
auto page = findParentPage();
|
||||
if (page) {
|
||||
@@ -595,7 +596,7 @@ PyObject *DrawView::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawViewPy(this),true);
|
||||
PythonObject = Py::Object(new DrawViewPy(this), true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user