Merge branch 'master' into feature/tool-bit-poc
This commit is contained in:
@@ -75,17 +75,17 @@ DrawView::DrawView(void):
|
||||
mouseMove(false)
|
||||
{
|
||||
static const char *group = "Base";
|
||||
ADD_PROPERTY_TYPE(X ,(0.0),group,App::Prop_None,"X position in internal units");
|
||||
ADD_PROPERTY_TYPE(Y ,(0.0),group,App::Prop_None,"Y position in internal units");
|
||||
ADD_PROPERTY_TYPE(LockPosition ,(false),group,App::Prop_None,"Lock View position to parent Page or Group");
|
||||
ADD_PROPERTY_TYPE(Rotation ,(0.0),group,App::Prop_None,"Rotation in degrees counterclockwise");
|
||||
ADD_PROPERTY_TYPE(X, (0.0), group, App::Prop_None, "X position");
|
||||
ADD_PROPERTY_TYPE(Y, (0.0), group, App::Prop_None, "Y position");
|
||||
ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_None, "Lock View position to parent Page or Group");
|
||||
ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_None, "Rotation in degrees counterclockwise");
|
||||
|
||||
ScaleType.setEnums(ScaleTypeEnums);
|
||||
ADD_PROPERTY_TYPE(ScaleType,((long)0),group, App::Prop_None, "Scale Type");
|
||||
ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view");
|
||||
ADD_PROPERTY_TYPE(ScaleType, ((long)0), group, App::Prop_None, "Scale Type");
|
||||
ADD_PROPERTY_TYPE(Scale, (1.0), group, App::Prop_None, "Scale factor of the view");
|
||||
Scale.setConstraints(&scaleRange);
|
||||
|
||||
ADD_PROPERTY_TYPE(Caption ,(""),group,App::Prop_None,"Short text about the view");
|
||||
ADD_PROPERTY_TYPE(Caption, (""), group, App::Prop_None, "Short text about the view");
|
||||
}
|
||||
|
||||
DrawView::~DrawView()
|
||||
@@ -340,9 +340,8 @@ void DrawView::handleChangedPropertyType(
|
||||
Scale.setValue(1.0);
|
||||
}
|
||||
} else {
|
||||
// has Scale prop that isn't Float!
|
||||
Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n");
|
||||
// no idea
|
||||
// has Scale property that isn't float
|
||||
Base::Console().Log("DrawPage::Restore - old document Scale is not a float!\n");
|
||||
}
|
||||
} else if (prop->isDerivedFrom(App::PropertyLinkList::getClassTypeId())
|
||||
&& strcmp(prop->getName(),"Source")==0)
|
||||
@@ -365,6 +364,21 @@ void DrawView::handleChangedPropertyType(
|
||||
}
|
||||
}
|
||||
}
|
||||
// property X had App::PropertyFloat and was changed to App::PropertyLength
|
||||
else if (prop == &X && strcmp(TypeName, "App::PropertyFloat") == 0) {
|
||||
App::PropertyFloat XProperty;
|
||||
XProperty.setContainer(this);
|
||||
// restore the PropertyFloat to be able to set its value
|
||||
XProperty.Restore(reader);
|
||||
X.setValue(XProperty.getValue());
|
||||
}
|
||||
// property Y had App::PropertyFloat and was changed to App::PropertyLength
|
||||
else if (prop == &Y && strcmp(TypeName, "App::PropertyFloat") == 0) {
|
||||
App::PropertyFloat YProperty;
|
||||
YProperty.setContainer(this);
|
||||
YProperty.Restore(reader);
|
||||
Y.setValue(YProperty.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
bool DrawView::keepUpdated(void)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/FeaturePython.h>
|
||||
|
||||
namespace TechDraw
|
||||
@@ -51,9 +52,9 @@ public:
|
||||
DrawView(void);
|
||||
virtual ~DrawView();
|
||||
|
||||
App::PropertyFloat X;
|
||||
App::PropertyFloat Y;
|
||||
App::PropertyBool LockPosition;
|
||||
App::PropertyLength X;
|
||||
App::PropertyLength Y;
|
||||
App::PropertyBool LockPosition;
|
||||
App::PropertyFloatConstraint Scale;
|
||||
|
||||
App::PropertyEnumeration ScaleType;
|
||||
|
||||
@@ -100,6 +100,9 @@ void DrawViewAnnotation::onChanged(const App::Property* prop)
|
||||
void DrawViewAnnotation::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop)
|
||||
// transforms properties that had been changed
|
||||
{
|
||||
// also check for changed properties of the base class
|
||||
DrawView::handleChangedPropertyType(reader, TypeName, prop);
|
||||
|
||||
// property LineSpace had the App::PropertyInteger and was changed to App::PropertyPercent
|
||||
if (prop == &LineSpace && strcmp(TypeName, "App::PropertyInteger") == 0) {
|
||||
App::PropertyInteger LineSpaceProperty;
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
|
||||
private:
|
||||
static const char* TextStyleEnums[];
|
||||
|
||||
@@ -128,6 +128,27 @@ void DrawViewBalloon::onDocumentRestored()
|
||||
|
||||
}
|
||||
|
||||
void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop)
|
||||
// transforms properties that had been changed
|
||||
{
|
||||
// also check for changed properties of the base class
|
||||
DrawView::handleChangedPropertyType(reader, TypeName, prop);
|
||||
|
||||
// property OriginX had the App::PropertyFloat and was changed to App::PropertyLength
|
||||
if (prop == &OriginX && strcmp(TypeName, "App::PropertyFloat") == 0) {
|
||||
App::PropertyInteger OriginXProperty;
|
||||
// restore the PropertyInteger to be able to set its value
|
||||
OriginXProperty.Restore(reader);
|
||||
OriginX.setValue(OriginXProperty.getValue());
|
||||
}
|
||||
// property OriginY had the App::PropertyFloat and was changed to App::PropertyLength
|
||||
else if (prop == &OriginY && strcmp(TypeName, "App::PropertyFloat") == 0) {
|
||||
App::PropertyFloat OriginYProperty;
|
||||
OriginYProperty.Restore(reader);
|
||||
OriginY.setValue(OriginYProperty.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
short DrawViewBalloon::mustExecute() const
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <App/DocumentObject.h>
|
||||
# include <App/FeaturePython.h>
|
||||
# include <App/PropertyLinks.h>
|
||||
# include <App/PropertyUnits.h>
|
||||
|
||||
#include "DrawView.h"
|
||||
|
||||
@@ -53,8 +54,8 @@ public:
|
||||
App::PropertyEnumeration EndType;
|
||||
App::PropertyEnumeration Symbol;
|
||||
App::PropertyFloat SymbolScale;
|
||||
App::PropertyFloat OriginX;
|
||||
App::PropertyFloat OriginY;
|
||||
App::PropertyLength OriginX;
|
||||
App::PropertyLength OriginY;
|
||||
App::PropertyBool OriginIsSet;
|
||||
App::PropertyFloat TextWrapLen;
|
||||
|
||||
@@ -79,6 +80,7 @@ public:
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
virtual void onDocumentRestored();
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Units
|
||||
import Part
|
||||
import Measure
|
||||
import TechDraw
|
||||
@@ -38,24 +39,24 @@ def DVBalloonTest():
|
||||
view1 = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewPart','View')
|
||||
FreeCAD.ActiveDocument.View.Source = [FreeCAD.ActiveDocument.Box]
|
||||
rc = page.addView(view1)
|
||||
view1.X = 30
|
||||
view1.Y = 150
|
||||
view1.X = Units.Quantity(30.0,Units.Length)
|
||||
view1.Y = Units.Quantity(150.0,Units.Length)
|
||||
view2 = FreeCAD.activeDocument().addObject('TechDraw::DrawViewPart','View001')
|
||||
FreeCAD.activeDocument().View001.Source = [FreeCAD.activeDocument().Sphere]
|
||||
rc = page.addView(view2)
|
||||
view2.X = 220
|
||||
view2.Y = 150
|
||||
view2.X = Units.Quantity(220.0,Units.Length)
|
||||
view2.Y = Units.Quantity(150.0,Units.Length)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
print("Place balloon")
|
||||
balloon1 = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewBalloon','Balloon1')
|
||||
balloon1.sourceView=view1
|
||||
balloon1.OriginIsSet=1
|
||||
balloon1.OriginX=view1.X + 20
|
||||
balloon1.OriginY=view1.Y + 20
|
||||
balloon1.OriginX=view1.X + Units.Quantity(20.0,Units.Length)
|
||||
balloon1.OriginY=view1.Y + Units.Quantity(20.0,Units.Length)
|
||||
balloon1.Text="1"
|
||||
balloon1.Y=balloon1.OriginX + 20
|
||||
balloon1.X=balloon1.OriginY + 20
|
||||
balloon1.Y=balloon1.OriginX + Units.Quantity(20.0,Units.Length)
|
||||
balloon1.X=balloon1.OriginY + Units.Quantity(20.0,Units.Length)
|
||||
|
||||
print("adding balloon1 to page")
|
||||
rc = page.addView(balloon1)
|
||||
@@ -63,11 +64,11 @@ def DVBalloonTest():
|
||||
balloon2 = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewBalloon','Balloon2')
|
||||
balloon2.sourceView=view2
|
||||
balloon2.OriginIsSet=1
|
||||
balloon2.OriginX=view2.X + 20
|
||||
balloon2.OriginY=view2.Y + 20
|
||||
balloon2.OriginX=view2.X + Units.Quantity(20.0,Units.Length)
|
||||
balloon2.OriginY=view2.Y + Units.Quantity(20.0,Units.Length)
|
||||
balloon2.Text="2"
|
||||
balloon2.Y=balloon2.OriginX + 20
|
||||
balloon2.X=balloon2.OriginY + 20
|
||||
balloon2.Y=balloon2.OriginX + Units.Quantity(20.0,Units.Length)
|
||||
balloon2.X=balloon2.OriginY + Units.Quantity(20.0,Units.Length)
|
||||
|
||||
print("adding balloon2 to page")
|
||||
rc = page.addView(balloon2)
|
||||
|
||||
Reference in New Issue
Block a user