Skip to content

Commit

Permalink
TD: DrawProjGroup: add units for spacing
Browse files Browse the repository at this point in the history
-also improve some tooltips
  • Loading branch information
donovaly authored and WandererFan committed Dec 10, 2019
1 parent 42196ea commit 78e6861
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
37 changes: 26 additions & 11 deletions src/Mod/TechDraw/App/DrawProjGroup.cpp
Expand Up @@ -54,11 +54,9 @@
using namespace TechDraw;

const char* DrawProjGroup::ProjectionTypeEnums[] = {"Default",
"First Angle",
"Third Angle",
NULL};


"First Angle",
"Third Angle",
NULL};

PROPERTY_SOURCE(TechDraw::DrawProjGroup, TechDraw::DrawViewCollection)

Expand All @@ -70,25 +68,22 @@ DrawProjGroup::DrawProjGroup(void)
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
bool autoDist = hGrp->GetBool("AutoDist",true);



ADD_PROPERTY_TYPE(Source ,(0), group, App::Prop_None,"Shape to view");
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(Anchor, (0), group, App::Prop_None, "The root view to align projections with");
Anchor.setScope(App::LinkScope::Global);


ProjectionType.setEnums(ProjectionTypeEnums);
ADD_PROPERTY_TYPE(ProjectionType, ((long)getDefProjConv()), group,
App::Prop_None, "First or Third Angle projection");
App::Prop_None, "First or Third angle projection");

ADD_PROPERTY_TYPE(AutoDistribute ,(autoDist),agroup,
App::Prop_None,"Distribute Views Automatically or Manually");
App::Prop_None,"Distribute views automatically or manually");
ADD_PROPERTY_TYPE(spacingX, (15), agroup, App::Prop_None, "Horizontal spacing between views");
ADD_PROPERTY_TYPE(spacingY, (15), agroup, App::Prop_None, "Vertical spacing between views");
Rotation.setStatus(App::Property::Hidden,true); //DPG does not rotate
Caption.setStatus(App::Property::Hidden,true);

}

DrawProjGroup::~DrawProjGroup()
Expand Down Expand Up @@ -1276,3 +1271,23 @@ PyObject *DrawProjGroup::getPyObject(void)
}
return Py::new_reference_to(PythonObject);
}

void DrawProjGroup::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 spacingX/Y had the App::PropertyFloat and were changed to App::PropertyLength
if ((prop == &spacingX) && (strcmp(TypeName, "App::PropertyFloat") == 0)) {
App::PropertyFloat spacingXProperty;
// restore the PropertyFloat to be able to set its value
spacingXProperty.Restore(reader);
spacingX.setValue(spacingXProperty.getValue());
}
else if ((prop == &spacingY) && (strcmp(TypeName, "App::PropertyFloat") == 0)) {
App::PropertyFloat spacingYProperty;
spacingYProperty.Restore(reader);
spacingY.setValue(spacingYProperty.getValue());
}
}
6 changes: 4 additions & 2 deletions src/Mod/TechDraw/App/DrawProjGroup.h
Expand Up @@ -60,9 +60,9 @@ class TechDrawExport DrawProjGroup : public TechDraw::DrawViewCollection

App::PropertyBool AutoDistribute;
/// Default horizontal spacing between adjacent views on Drawing, in mm
App::PropertyFloat spacingX;
App::PropertyLength spacingX;
/// Default vertical spacing between adjacent views on Drawing, in mm
App::PropertyFloat spacingY;
App::PropertyLength spacingY;

App::PropertyLink Anchor; /// Anchor Element to align views to

Expand Down Expand Up @@ -174,6 +174,8 @@ class TechDrawExport DrawProjGroup : public TechDraw::DrawViewCollection
Base::Vector3d dir2vec(gp_Dir d);
gp_Dir vec2dir(Base::Vector3d v);

virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);

};

} //namespace TechDraw
Expand Down

0 comments on commit 78e6861

Please sign in to comment.