Gui: Reduce code duplication in ViewProviderCoordinateSystem
This commit is contained in:
@@ -183,30 +183,31 @@ void ViewProviderCoordinateSystem::setPlaneLabelVisibility(bool val)
|
||||
|
||||
}
|
||||
|
||||
void ViewProviderCoordinateSystem::setTemporaryScale(double factor)
|
||||
void ViewProviderCoordinateSystem::applyDatumObjects(const DatumObjectFunc& func)
|
||||
{
|
||||
auto lcs = getObject<App::LocalCoordinateSystem>();
|
||||
auto& objs = lcs->OriginFeatures.getValues();
|
||||
const auto& objs = lcs->OriginFeatures.getValues();
|
||||
for (auto* obj : objs) {
|
||||
auto* vp = dynamic_cast<Gui::ViewProviderDatum*>(
|
||||
Gui::Application::Instance->getViewProvider(obj));
|
||||
if (vp) {
|
||||
vp->setTemporaryScale(factor);
|
||||
func(vp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderCoordinateSystem::setTemporaryScale(double factor)
|
||||
{
|
||||
applyDatumObjects([factor](ViewProviderDatum* vp) {
|
||||
vp->setTemporaryScale(factor);
|
||||
});
|
||||
}
|
||||
|
||||
void ViewProviderCoordinateSystem::resetTemporarySize()
|
||||
{
|
||||
auto lcs = getObject<App::LocalCoordinateSystem>();
|
||||
auto& objs = lcs->OriginFeatures.getValues();
|
||||
for (auto* obj : objs) {
|
||||
auto* vp = dynamic_cast<Gui::ViewProviderDatum*>(
|
||||
Gui::Application::Instance->getViewProvider(obj));
|
||||
if (vp) {
|
||||
vp->resetTemporarySize();
|
||||
}
|
||||
}
|
||||
applyDatumObjects([](ViewProviderDatum* vp) {
|
||||
vp->resetTemporarySize();
|
||||
});
|
||||
}
|
||||
|
||||
void ViewProviderCoordinateSystem::updateData(const App::Property* prop) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#ifndef GUI_VIEWPROVIDER_ViewProviderOrigin_H
|
||||
#define GUI_VIEWPROVIDER_ViewProviderOrigin_H
|
||||
|
||||
#include <functional>
|
||||
#include <App/PropertyGeo.h>
|
||||
|
||||
#include "ViewProviderGeoFeatureGroup.h"
|
||||
@@ -32,6 +33,7 @@
|
||||
namespace Gui {
|
||||
|
||||
class Document;
|
||||
class ViewProviderDatum;
|
||||
|
||||
class GuiExport ViewProviderCoordinateSystem : public ViewProviderGeoFeatureGroup
|
||||
{
|
||||
@@ -84,10 +86,15 @@ public:
|
||||
|
||||
// default color for origini: light-blue (50, 150, 250, 255 stored as 0xRRGGBBAA)
|
||||
static const uint32_t defaultColor = 0x3296faff;
|
||||
|
||||
protected:
|
||||
void updateData(const App::Property*) override;
|
||||
bool onDelete(const std::vector<std::string> &) override;
|
||||
|
||||
private:
|
||||
using DatumObjectFunc = std::function<void(ViewProviderDatum*)>;
|
||||
void applyDatumObjects(const DatumObjectFunc& func);
|
||||
|
||||
private:
|
||||
SoGroup *pcGroupChildren;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user