@@ -97,51 +97,41 @@ void ViewProviderCoordinateSystem::setDisplayMode(const char* ModeName)
|
||||
ViewProviderDocumentObject::setDisplayMode(ModeName);
|
||||
}
|
||||
|
||||
void ViewProviderCoordinateSystem::setTemporaryVisibility(bool axis, bool plane, bool points) {
|
||||
auto origin = static_cast<App::Origin*>( getObject() );
|
||||
void ViewProviderCoordinateSystem::setTemporaryVisibility(DatumElements elements)
|
||||
{
|
||||
auto origin = getObject<App::Origin>();
|
||||
|
||||
bool saveState = tempVisMap.empty();
|
||||
|
||||
try {
|
||||
// Remember & Set axis visibility
|
||||
for(App::DocumentObject* obj : origin->axes()) {
|
||||
if (obj) {
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if(vp) {
|
||||
if (saveState) {
|
||||
tempVisMap[vp] = vp->isVisible();
|
||||
}
|
||||
vp->setVisible(axis);
|
||||
if (auto vp = Gui::Application::Instance->getViewProvider(obj)) {
|
||||
if (saveState) {
|
||||
tempVisMap[vp] = vp->isVisible();
|
||||
}
|
||||
vp->setVisible(elements.testFlag(DatumElement::Axes));
|
||||
}
|
||||
}
|
||||
|
||||
// Remember & Set plane visibility
|
||||
for(App::DocumentObject* obj : origin->planes()) {
|
||||
if (obj) {
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if(vp) {
|
||||
if (saveState) {
|
||||
tempVisMap[vp] = vp->isVisible();
|
||||
}
|
||||
vp->setVisible(plane);
|
||||
if (auto vp = Gui::Application::Instance->getViewProvider(obj)) {
|
||||
if (saveState) {
|
||||
tempVisMap[vp] = vp->isVisible();
|
||||
}
|
||||
vp->setVisible(elements.testFlag(DatumElement::Planes));
|
||||
}
|
||||
}
|
||||
|
||||
// Remember & Set origin point visibility
|
||||
App::DocumentObject* obj = origin->getOrigin();
|
||||
if (obj) {
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if (vp) {
|
||||
if (saveState) {
|
||||
tempVisMap[vp] = vp->isVisible();
|
||||
}
|
||||
vp->setVisible(points);
|
||||
if (auto vp = Gui::Application::Instance->getViewProvider(obj)) {
|
||||
if (saveState) {
|
||||
tempVisMap[vp] = vp->isVisible();
|
||||
}
|
||||
vp->setVisible(elements.testFlag(DatumElement::Origin));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (const Base::Exception &ex) {
|
||||
Base::Console().Error ("%s\n", ex.what() );
|
||||
@@ -183,30 +173,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,8 @@
|
||||
#ifndef GUI_VIEWPROVIDER_ViewProviderOrigin_H
|
||||
#define GUI_VIEWPROVIDER_ViewProviderOrigin_H
|
||||
|
||||
#include <functional>
|
||||
#include <Base/Bitmask.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
|
||||
#include "ViewProviderGeoFeatureGroup.h"
|
||||
@@ -32,6 +34,18 @@
|
||||
namespace Gui {
|
||||
|
||||
class Document;
|
||||
class ViewProviderDatum;
|
||||
|
||||
enum class DatumElement
|
||||
{
|
||||
// clang-format off
|
||||
Origin = 1 << 0,
|
||||
Axes = 1 << 1,
|
||||
Planes = 1 << 2
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
using DatumElements = Base::Flags<DatumElement>;
|
||||
|
||||
class GuiExport ViewProviderCoordinateSystem : public ViewProviderGeoFeatureGroup
|
||||
{
|
||||
@@ -60,7 +74,7 @@ public:
|
||||
*/
|
||||
///@{
|
||||
/// Set temporary visibility of some of origin's objects e.g. while rotating or mirroring
|
||||
void setTemporaryVisibility (bool axis, bool planes, bool points = false);
|
||||
void setTemporaryVisibility (DatumElements elements);
|
||||
/// Returns true if the origin in temporary visibility mode
|
||||
bool isTemporaryVisibility ();
|
||||
/// Reset the visibility
|
||||
@@ -84,10 +98,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;
|
||||
|
||||
@@ -96,5 +115,7 @@ private:
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
ENABLE_BITMASK_OPERATORS(Gui::DatumElement)
|
||||
|
||||
#endif // GUI_VIEWPROVIDER_ViewProviderOrigin_H
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ void ViewProviderPlane::setLabelVisibility(bool val)
|
||||
labelSwitch->whichChild = val ? SO_SWITCH_ALL : SO_SWITCH_NONE;
|
||||
}
|
||||
|
||||
unsigned long ViewProviderPlane::getColor(std::string& role)
|
||||
unsigned long ViewProviderPlane::getColor(const std::string& role) const
|
||||
{
|
||||
auto planesRoles = App::LocalCoordinateSystem::PlaneRoles;
|
||||
if (role == planesRoles[0]) {
|
||||
@@ -167,7 +167,7 @@ unsigned long ViewProviderPlane::getColor(std::string& role)
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string ViewProviderPlane::getLabelText(std::string& role)
|
||||
std::string ViewProviderPlane::getLabelText(const std::string& role) const
|
||||
{
|
||||
std::string text;
|
||||
auto planesRoles = App::LocalCoordinateSystem::PlaneRoles;
|
||||
@@ -183,7 +183,7 @@ std::string ViewProviderPlane::getLabelText(std::string& role)
|
||||
return text;
|
||||
}
|
||||
|
||||
std::string ViewProviderPlane::getRole()
|
||||
std::string ViewProviderPlane::getRole() const
|
||||
{
|
||||
// Note: Role property of App::Plane is not set yet when attaching.
|
||||
const char* name = pcObject->getNameInDocument();
|
||||
@@ -199,4 +199,4 @@ std::string ViewProviderPlane::getRole()
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
|
||||
void attach (App::DocumentObject*) override;
|
||||
|
||||
unsigned long getColor(std::string& role);
|
||||
std::string getRole();
|
||||
std::string getLabelText(std::string& role);
|
||||
unsigned long getColor(const std::string& role) const;
|
||||
std::string getRole() const;
|
||||
std::string getLabelText(const std::string& role) const;
|
||||
void setLabelVisibility(bool val);
|
||||
|
||||
private:
|
||||
|
||||
@@ -110,14 +110,8 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
|
||||
ui->listWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
axisBit = 0,
|
||||
planeBit = 1
|
||||
};
|
||||
|
||||
// NOTE: generally there shouldn't be more then one origin
|
||||
std::map<App::Origin*, std::bitset<2>> originVisStatus;
|
||||
std::map<App::Origin*, Gui::DatumElements> originVisStatus;
|
||||
|
||||
auto statusIt = status.cbegin();
|
||||
auto objIt = objects.begin();
|
||||
@@ -144,10 +138,10 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
|
||||
App::Origin* origin = dynamic_cast<App::Origin*>(datum->getLCS());
|
||||
if (origin) {
|
||||
if ((*objIt)->isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
originVisStatus[origin].set(planeBit, true);
|
||||
originVisStatus[origin].setFlag(Gui::DatumElement::Planes, true);
|
||||
}
|
||||
else if ((*objIt)->isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
originVisStatus[origin].set(axisBit, true);
|
||||
originVisStatus[origin].setFlag(Gui::DatumElement::Axes, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,8 +154,7 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
|
||||
Gui::ViewProviderCoordinateSystem* vpo = static_cast<Gui::ViewProviderCoordinateSystem*>(
|
||||
Gui::Application::Instance->getViewProvider(origin));
|
||||
if (vpo) {
|
||||
vpo->setTemporaryVisibility(originVisStatus[origin][axisBit],
|
||||
originVisStatus[origin][planeBit]);
|
||||
vpo->setTemporaryVisibility(originVisStatus[origin]);
|
||||
vpo->setTemporaryScale(4.0); // NOLINT
|
||||
vpo->setPlaneLabelVisibility(true);
|
||||
origins.push_back(vpo);
|
||||
|
||||
@@ -174,7 +174,7 @@ void TaskHelixParameters::showCoordinateAxes()
|
||||
ViewProviderCoordinateSystem* vpOrigin;
|
||||
vpOrigin = static_cast<ViewProviderCoordinateSystem*>(
|
||||
Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->setTemporaryVisibility(true, false);
|
||||
vpOrigin->setTemporaryVisibility(Gui::DatumElement::Axes);
|
||||
}
|
||||
catch (const Base::Exception& ex) {
|
||||
ex.ReportException();
|
||||
|
||||
@@ -111,7 +111,7 @@ void TaskLinearPatternParameters::setupParameterUI(QWidget* widget)
|
||||
App::Origin* origin = body->getOrigin();
|
||||
auto vpOrigin = static_cast<ViewProviderCoordinateSystem*>(
|
||||
Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->setTemporaryVisibility(true, false);
|
||||
vpOrigin->setTemporaryVisibility(Gui::DatumElement::Axes);
|
||||
}
|
||||
catch (const Base::Exception& ex) {
|
||||
Base::Console().Error("%s\n", ex.what());
|
||||
|
||||
@@ -92,7 +92,7 @@ void TaskMirroredParameters::setupParameterUI(QWidget* widget)
|
||||
App::Origin* origin = body->getOrigin();
|
||||
auto vpOrigin = static_cast<ViewProviderCoordinateSystem*>(
|
||||
Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->setTemporaryVisibility(false, true);
|
||||
vpOrigin->setTemporaryVisibility(Gui::DatumElement::Planes);
|
||||
}
|
||||
catch (const Base::Exception& ex) {
|
||||
Base::Console().Error("%s\n", ex.what());
|
||||
|
||||
@@ -113,7 +113,7 @@ void TaskPolarPatternParameters::setupParameterUI(QWidget* widget)
|
||||
App::Origin* origin = body->getOrigin();
|
||||
auto vpOrigin = static_cast<ViewProviderCoordinateSystem*>(
|
||||
Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->setTemporaryVisibility(true, false);
|
||||
vpOrigin->setTemporaryVisibility(Gui::DatumElement::Axes);
|
||||
}
|
||||
catch (const Base::Exception& ex) {
|
||||
Base::Console().Error("%s\n", ex.what());
|
||||
|
||||
@@ -262,7 +262,7 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent)
|
||||
App::Origin *origin = body->getOrigin();
|
||||
Gui::ViewProviderCoordinateSystem* vpOrigin {};
|
||||
vpOrigin = static_cast<Gui::ViewProviderCoordinateSystem*>(Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->setTemporaryVisibility(true, true);
|
||||
vpOrigin->setTemporaryVisibility(Gui::DatumElement::Planes | Gui::DatumElement::Axes);
|
||||
} catch (const Base::Exception &ex) {
|
||||
Base::Console().Error ("%s\n", ex.what () );
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
|
||||
// show the parts coordinate system axis for selection
|
||||
try {
|
||||
if (auto vpOrigin = getOriginView()) {
|
||||
vpOrigin->setTemporaryVisibility(true, false);
|
||||
vpOrigin->setTemporaryVisibility(Gui::DatumElement::Axes);
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception &ex) {
|
||||
|
||||
Reference in New Issue
Block a user