Skip to content

Commit

Permalink
[TechDraw] Tree view update refactoring (FreeCAD#11815)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavltom authored Dec 23, 2023
1 parent 7a2be9e commit 8d51d78
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
46 changes: 13 additions & 33 deletions src/Mod/TechDraw/Gui/CommandCreateDims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ void execRadius(Gui::Command* cmd)
//build the dimension
// DrawViewDimension* dim =
dimensionMaker(partFeat, "Radius", references2d, references3d);

//Horrible hack to force Tree update
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
}

//===========================================================================
Expand Down Expand Up @@ -365,10 +361,6 @@ void execDiameter(Gui::Command* cmd)
//build the dimension
// DrawViewDimension* dim =
dimensionMaker(partFeat, "Diameter", references2d, references3d);

//Horrible hack to force Tree update
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
}

//===========================================================================
Expand Down Expand Up @@ -464,10 +456,6 @@ void execDistance(Gui::Command* cmd)

//position the Dimension text on the view
positionDimText(dim);

//Horrible hack to force Tree update (claimChildren)
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
}

//===========================================================================
Expand Down Expand Up @@ -560,13 +548,8 @@ void execDistanceX(Gui::Command* cmd)
//build the dimension
DrawViewDimension* dim = dimensionMaker(partFeat, "DistanceX", references2d, references3d);


//position the Dimension text on the view
positionDimText(dim);

//Horrible hack to force Tree update (claimChildren)
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
}

//===========================================================================
Expand Down Expand Up @@ -660,10 +643,6 @@ void execDistanceY(Gui::Command* cmd)

//position the Dimension text on the view
positionDimText(dim);

//Horrible hack to force Tree update (claimChildren)
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
}

//===========================================================================
Expand Down Expand Up @@ -756,10 +735,6 @@ void execAngle(Gui::Command* cmd)

//position the Dimension text on the view
positionDimText(dim);

//Horrible hack to force Tree update (claimChildren)
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
}

//===========================================================================
Expand Down Expand Up @@ -849,12 +824,9 @@ void execAngle3Pt(Gui::Command* cmd)

//build the dimension
DrawViewDimension* dim = dimensionMaker(partFeat, "Angle3Pt", references2d, references3d);

//position the Dimension text on the view
positionDimText(dim);

//Horrible hack to force Tree update (claimChildren)
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
}

//! link 3D geometry to Dimension(s) on a Page
Expand Down Expand Up @@ -1337,11 +1309,11 @@ void CmdTechDrawLandmarkDimension::activated(int iMsg)
FeatName.c_str());

commitCommand();
dim->recomputeFeature();

//Horrible hack to force Tree update
double x = dvp->X.getValue();
dvp->X.setValue(x);
// Touch the parent feature so the dimension in tree view appears as a child
dvp->touch(true);

dim->recomputeFeature();
}

bool CmdTechDrawLandmarkDimension::isActive()
Expand Down Expand Up @@ -1416,6 +1388,14 @@ DrawViewDimension* dimensionMaker(TechDraw::DrawViewPart* dvp, std::string dimTy
dimName.c_str());

Gui::Command::commitCommand();

// Touch the parent feature so the dimension in tree view appears as a child
dvp->touch(true);

// Select only the newly created dimension
Gui::Selection().clearSelection();
Gui::Selection().addSelection(dvp->getDocument()->getName(), dim->getNameInDocument());

dim->recomputeFeature();
return dim;
}
Expand Down
11 changes: 4 additions & 7 deletions src/Mod/TechDraw/Gui/CommandDecorate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ void CmdTechDrawHatch::activated(int iMsg)
// dialog to fill in hatch values
Gui::Control().showDialog(new TaskDlgHatch(partFeat, subNames));

//Horrible hack to force Tree update ??still required??
//WF: yes. ViewProvider will not claim children without this!
double x = partFeat->X.getValue();
partFeat->X.setValue(x);
// Touch the parent feature so the hatching in tree view appears as a child
partFeat->touch();
getDocument()->recompute();
}

Expand Down Expand Up @@ -216,9 +214,8 @@ void CmdTechDrawGeometricHatch::activated(int iMsg)

commitCommand();

//Horrible hack to force Tree update ??still required??
double x = objFeat->X.getValue();
objFeat->X.setValue(x);
// Touch the parent feature so the hatching in tree view appears as a child
objFeat->touch();
getDocument()->recompute();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Mod/TechDraw/Gui/CommandExtensionDims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2334,10 +2334,10 @@ namespace TechDrawGui {
throw Base::TypeError("CmdTechDrawExtensionCreateLinDimension - dim not found\n");
dim->References2D.setValues(objs, subs);
cmd->doCommand(cmd->Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str());

// Touch the parent feature so the dimension in tree view appears as a child
objFeat->touch();
dim->recomputeFeature();
//Horrible hack to force Tree update
double x = objFeat->X.getValue();
objFeat->X.setValue(x);
return dim;
}

Expand Down

0 comments on commit 8d51d78

Please sign in to comment.