[TechDraw] Add Owner property to Symbols
This commit is contained in:
@@ -51,6 +51,9 @@ DrawViewSymbol::DrawViewSymbol()
|
||||
ADD_PROPERTY_TYPE(Symbol, (""), vgroup, App::Prop_None, "The SVG code defining this symbol");
|
||||
ADD_PROPERTY_TYPE(EditableTexts, (""), vgroup, App::Prop_None,
|
||||
"Substitution values for the editable strings in this symbol");
|
||||
ADD_PROPERTY_TYPE(Owner, (nullptr), vgroup, (App::PropertyType)(App::Prop_None),
|
||||
"Feature to which this symbol is attached");
|
||||
|
||||
ScaleType.setValue("Custom");
|
||||
Scale.setStatus(App::Property::ReadOnly, false);
|
||||
Symbol.setStatus(App::Property::Hidden, true);
|
||||
@@ -58,6 +61,28 @@ DrawViewSymbol::DrawViewSymbol()
|
||||
|
||||
DrawViewSymbol::~DrawViewSymbol() {}
|
||||
|
||||
void DrawViewSymbol::touchTreeOwner()
|
||||
{
|
||||
auto owner = dynamic_cast<DrawView *>(Owner.getValue());
|
||||
if (owner) {
|
||||
owner->touch();
|
||||
}
|
||||
else { // If no owner is specified, touch all parent pages
|
||||
for (auto page : findAllParentPages()) {
|
||||
page->touch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewSymbol::onBeforeChange(const App::Property *prop)
|
||||
{
|
||||
if (prop == &Owner && !isRestoring()) {
|
||||
touchTreeOwner();
|
||||
}
|
||||
|
||||
TechDraw::DrawView::onBeforeChange(prop);
|
||||
}
|
||||
|
||||
void DrawViewSymbol::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &Symbol) {
|
||||
@@ -72,10 +97,26 @@ void DrawViewSymbol::onChanged(const App::Property* prop)
|
||||
//1 cycle
|
||||
updateFieldsInSymbol();
|
||||
}
|
||||
else if (prop == &Owner) {
|
||||
if (!isRestoring()) {
|
||||
touchTreeOwner();
|
||||
}
|
||||
}
|
||||
|
||||
TechDraw::DrawView::onChanged(prop);
|
||||
}
|
||||
|
||||
short DrawViewSymbol::mustExecute() const
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
if (Owner.isTouched()) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return DrawView::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* DrawViewSymbol::execute()
|
||||
{
|
||||
//nothing to do. DVS is just a container for properties.
|
||||
@@ -83,6 +124,11 @@ App::DocumentObjectExecReturn* DrawViewSymbol::execute()
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
DrawView *DrawViewSymbol::claimParent() const
|
||||
{
|
||||
return dynamic_cast<DrawView *>(Owner.getValue());
|
||||
}
|
||||
|
||||
QRectF DrawViewSymbol::getRect() const
|
||||
{
|
||||
double w = 64.0;//must default to something
|
||||
|
||||
Reference in New Issue
Block a user