Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit 5a4f9a8

Browse files
committed
Core datums: Rework to improve new sketch.
1 parent 1289997 commit 5a4f9a8

File tree

9 files changed

+186
-72
lines changed

9 files changed

+186
-72
lines changed

src/Gui/ViewProviderCoordinateSystem.cpp

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void ViewProviderCoordinateSystem::setDisplayMode(const char* ModeName)
9797
ViewProviderDocumentObject::setDisplayMode(ModeName);
9898
}
9999

100-
void ViewProviderCoordinateSystem::setTemporaryVisibility(bool axis, bool plane) {
100+
void ViewProviderCoordinateSystem::setTemporaryVisibility(bool axis, bool plane, bool points) {
101101
auto origin = static_cast<App::Origin*>( getObject() );
102102

103103
bool saveState = tempVisMap.empty();
@@ -137,7 +137,7 @@ void ViewProviderCoordinateSystem::setTemporaryVisibility(bool axis, bool plane)
137137
if (saveState) {
138138
tempVisMap[vp] = vp->isVisible();
139139
}
140-
vp->setVisible(plane);
140+
vp->setVisible(points);
141141
}
142142
}
143143

@@ -170,6 +170,46 @@ bool ViewProviderCoordinateSystem::isTemporaryVisibility() {
170170
return !tempVisMap.empty();
171171
}
172172

173+
void ViewProviderCoordinateSystem::setPlaneLabelVisibility(bool val)
174+
{
175+
auto lcs = static_cast<App::LocalCoordinateSystem*>(getObject());
176+
auto& planes = lcs->planes();
177+
for (auto* plane : planes) {
178+
auto* vp = dynamic_cast<Gui::ViewProviderPlane*>(
179+
Gui::Application::Instance->getViewProvider(plane));
180+
if (vp) {
181+
vp->setLabelVisibility(val);
182+
}
183+
}
184+
185+
}
186+
187+
void ViewProviderCoordinateSystem::setTemporaryScale(double factor)
188+
{
189+
auto lcs = static_cast<App::LocalCoordinateSystem*>(getObject());
190+
auto& objs = lcs->OriginFeatures.getValues();
191+
for (auto* obj : objs) {
192+
auto* vp = dynamic_cast<Gui::ViewProviderDatum*>(
193+
Gui::Application::Instance->getViewProvider(obj));
194+
if (vp) {
195+
vp->setTemporaryScale(factor);
196+
}
197+
}
198+
}
199+
200+
void ViewProviderCoordinateSystem::resetTemporarySize()
201+
{
202+
auto lcs = static_cast<App::LocalCoordinateSystem*>(getObject());
203+
auto& objs = lcs->OriginFeatures.getValues();
204+
for (auto* obj : objs) {
205+
auto* vp = dynamic_cast<Gui::ViewProviderDatum*>(
206+
Gui::Application::Instance->getViewProvider(obj));
207+
if (vp) {
208+
vp->resetTemporarySize();
209+
}
210+
}
211+
}
212+
173213
void ViewProviderCoordinateSystem::updateData(const App::Property* prop) {
174214
auto* jcs = dynamic_cast<App::LocalCoordinateSystem*>(getObject());
175215
if(jcs) {

src/Gui/ViewProviderCoordinateSystem.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,18 @@ class GuiExport ViewProviderCoordinateSystem : public ViewProviderGeoFeatureGrou
6060
*/
6161
///@{
6262
/// Set temporary visibility of some of origin's objects e.g. while rotating or mirroring
63-
void setTemporaryVisibility (bool axis, bool planes);
63+
void setTemporaryVisibility (bool axis, bool planes, bool points = false);
6464
/// Returns true if the origin in temporary visibility mode
6565
bool isTemporaryVisibility ();
6666
/// Reset the visibility
6767
void resetTemporaryVisibility ();
6868
///@}
6969

70+
void setTemporaryScale(double factor);
71+
void resetTemporarySize();
72+
73+
void setPlaneLabelVisibility(bool val);
74+
7075
bool canDragObjects() const override {
7176
return false;
7277
}

src/Gui/ViewProviderDatum.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "PreCompiled.h"
2424

2525
#ifndef _PreComp_
26-
# include <Inventor/nodes/SoText2.h>
2726
# include <Inventor/nodes/SoAnnotation.h>
2827
# include <Inventor/nodes/SoDrawStyle.h>
2928
# include <Inventor/nodes/SoFont.h>
@@ -60,17 +59,12 @@ ViewProviderDatum::ViewProviderDatum() {
6059
pRoot = new SoSeparator();
6160
pRoot->ref();
6261

63-
// Create the Label node
64-
pLabel = new SoText2();
65-
pLabel->ref();
66-
6762
lineThickness = 2.0;
6863
}
6964

7065

7166
ViewProviderDatum::~ViewProviderDatum() {
7267
pRoot->unref();
73-
pLabel->unref();
7468
}
7569

7670

@@ -132,20 +126,27 @@ void ViewProviderDatum::attach(App::DocumentObject* pcObject)
132126

133127
sep->addChild(visible);
134128

135-
136-
// Scale feature to the given size
137-
float sz = App::GetApplication()
138-
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
139-
->GetFloat("LocalCoordinateSystemSize", 1.0); // NOLINT
140-
141129
soScale->setPart("shape", sep);
142-
soScale->scaleFactor = sz;
130+
resetTemporarySize();
143131

144132
highlight->addChild(soScale);
145133

146134
addDisplayMaskMode(highlight, "Base");
147135
}
148136

137+
void ViewProviderDatum::setTemporaryScale(double factor)
138+
{
139+
soScale->scaleFactor = soScale->scaleFactor.getValue() * factor;
140+
}
141+
142+
void ViewProviderDatum::resetTemporarySize()
143+
{
144+
float sz = App::GetApplication()
145+
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
146+
->GetFloat("LocalCoordinateSystemSize", 1.0); // NOLINT
147+
148+
soScale->scaleFactor = sz;
149+
}
149150

150151
void ViewProviderDatum::onChanged(const App::Property* prop) {
151152
ViewProviderGeometryObject::onChanged(prop);

src/Gui/ViewProviderDatum.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include "ViewProviderGeometryObject.h"
2727

28-
class SoText2;
2928
class SoScale;
3029

3130
namespace Gui
@@ -46,9 +45,6 @@ namespace Gui
4645
/// Get point derived classes will add their specific stuff
4746
SoSeparator* getDatumRoot() const { return pRoot; }
4847

49-
/// Get pointer to the text label associated with the feature
50-
SoText2* getLabel() const { return pLabel; }
51-
5248
void attach(App::DocumentObject*) override;
5349
std::vector<std::string> getDisplayModes() const override;
5450
void setDisplayMode(const char* ModeName) override;
@@ -63,13 +59,15 @@ namespace Gui
6359
{ }
6460
///@}
6561

62+
void setTemporaryScale(double factor);
63+
void resetTemporarySize();
64+
6665
protected:
6766
void onChanged(const App::Property* prop) override;
6867
bool onDelete(const std::vector<std::string>&) override;
6968
protected:
7069
SoSeparator* pRoot;
7170
SoShapeScale* soScale;
72-
SoText2* pLabel;
7371
double lineThickness;
7472
};
7573

src/Gui/ViewProviderLine.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#ifndef _PreComp_
2727
# include <Inventor/nodes/SoText2.h>
28-
# include <Inventor/nodes/SoAsciiText.h>
2928
# include <Inventor/nodes/SoCoordinate3.h>
3029
# include <Inventor/nodes/SoIndexedLineSet.h>
3130
# include <Inventor/nodes/SoPickStyle.h>
@@ -48,9 +47,14 @@ PROPERTY_SOURCE(Gui::ViewProviderLine, Gui::ViewProviderDatum)
4847
ViewProviderLine::ViewProviderLine()
4948
{
5049
sPixmap = "Std_Axis";
50+
51+
pLabel = new SoText2();
52+
pLabel->ref();
5153
}
5254

53-
ViewProviderLine::~ViewProviderLine() = default;
55+
ViewProviderLine::~ViewProviderLine() {
56+
pLabel->unref();
57+
}
5458

5559
void ViewProviderLine::attach(App::DocumentObject *obj) {
5660
ViewProviderDatum::attach(obj);
@@ -114,5 +118,5 @@ void ViewProviderLine::attach(App::DocumentObject *obj) {
114118
ps->style.setValue(SoPickStyle::SHAPE_ON_TOP);
115119
sep->addChild(ps);
116120

117-
sep->addChild ( getLabel () );
121+
sep->addChild (pLabel);
118122
}

src/Gui/ViewProviderLine.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#include "ViewProviderDatum.h"
2929

30+
class SoText2;
31+
3032
namespace Gui
3133
{
3234

@@ -38,6 +40,9 @@ class GuiExport ViewProviderLine : public ViewProviderDatum {
3840
~ViewProviderLine() override;
3941

4042
void attach ( App::DocumentObject * ) override;
43+
44+
protected:
45+
SoText2* pLabel;
4146
};
4247

4348
} //namespace Gui

0 commit comments

Comments
 (0)