Core: Add App::LocalCoordinateSystem.
Most of App::Origin is moved into this sub class of App::Origin. Add App::Point. Change graphics of the planes/axis. Remove scale-by-content behavior and make it fixed size on screen.
This commit is contained in:
@@ -39,22 +39,19 @@
|
||||
#include "Document.h"
|
||||
#include "ViewProviderLine.h"
|
||||
#include "ViewProviderPlane.h"
|
||||
#include "ViewProviderPoint.h"
|
||||
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Gui::ViewProviderOrigin, Gui::ViewProviderDocumentObject)
|
||||
PROPERTY_SOURCE(Gui::ViewProviderOrigin, Gui::ViewProviderGeoFeatureGroup)
|
||||
|
||||
/**
|
||||
* Creates the view provider for an object group.
|
||||
*/
|
||||
ViewProviderOrigin::ViewProviderOrigin()
|
||||
{
|
||||
ADD_PROPERTY_TYPE ( Size, (Base::Vector3d(10,10,10)), 0, App::Prop_None,
|
||||
QT_TRANSLATE_NOOP("App::Property", "The displayed size of the origin"));
|
||||
Size.setStatus(App::Property::ReadOnly, true);
|
||||
|
||||
sPixmap = "Std_CoordinateSystem";
|
||||
Visibility.setValue(false);
|
||||
|
||||
@@ -71,8 +68,9 @@ ViewProviderOrigin::~ViewProviderOrigin() {
|
||||
pcGroupChildren = nullptr;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderOrigin::claimChildren() const {
|
||||
return static_cast<App::Origin*>( getObject() )->OriginFeatures.getValues ();
|
||||
std::vector<App::DocumentObject*> ViewProviderOrigin::claimChildren() const
|
||||
{
|
||||
return static_cast<App::Origin*>( getObject() )->OriginFeatures.getValues();
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderOrigin::claimChildren3D() const {
|
||||
@@ -128,7 +126,22 @@ void ViewProviderOrigin::setTemporaryVisibility(bool axis, bool plane) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (const Base::Exception &ex) {
|
||||
|
||||
// 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(plane);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (const Base::Exception &ex) {
|
||||
Base::Console().Error ("%s\n", ex.what() );
|
||||
}
|
||||
|
||||
@@ -148,70 +161,34 @@ void ViewProviderOrigin::resetTemporaryVisibility() {
|
||||
double ViewProviderOrigin::defaultSize()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
return 0.25 * hGrp->GetFloat("NewDocumentCameraScale",100.0);
|
||||
return hGrp->GetFloat("DatumsSize", 25);
|
||||
}
|
||||
|
||||
bool ViewProviderOrigin::isTemporaryVisibility() {
|
||||
return !tempVisMap.empty();
|
||||
}
|
||||
|
||||
void ViewProviderOrigin::onChanged(const App::Property* prop) {
|
||||
if (prop == &Size) {
|
||||
try {
|
||||
Gui::Application *app = Gui::Application::Instance;
|
||||
Base::Vector3d sz = Size.getValue ();
|
||||
auto origin = static_cast<App::Origin*> ( getObject() );
|
||||
|
||||
// Calculate axes and planes sizes
|
||||
double szXY = std::max ( sz.x, sz.y );
|
||||
double szXZ = std::max ( sz.x, sz.z );
|
||||
double szYZ = std::max ( sz.y, sz.z );
|
||||
|
||||
double szX = std::min ( szXY, szXZ );
|
||||
double szY = std::min ( szXY, szYZ );
|
||||
double szZ = std::min ( szXZ, szYZ );
|
||||
|
||||
// Find view providers
|
||||
Gui::ViewProviderPlane* vpPlaneXY, *vpPlaneXZ, *vpPlaneYZ;
|
||||
Gui::ViewProviderLine* vpLineX, *vpLineY, *vpLineZ;
|
||||
// Planes
|
||||
vpPlaneXY = static_cast<Gui::ViewProviderPlane *> ( app->getViewProvider ( origin->getXY () ) );
|
||||
vpPlaneXZ = static_cast<Gui::ViewProviderPlane *> ( app->getViewProvider ( origin->getXZ () ) );
|
||||
vpPlaneYZ = static_cast<Gui::ViewProviderPlane *> ( app->getViewProvider ( origin->getYZ () ) );
|
||||
// Axes
|
||||
vpLineX = static_cast<Gui::ViewProviderLine *> ( app->getViewProvider ( origin->getX () ) );
|
||||
vpLineY = static_cast<Gui::ViewProviderLine *> ( app->getViewProvider ( origin->getY () ) );
|
||||
vpLineZ = static_cast<Gui::ViewProviderLine *> ( app->getViewProvider ( origin->getZ () ) );
|
||||
|
||||
// set their sizes
|
||||
if (vpPlaneXY) { vpPlaneXY->Size.setValue ( szXY ); }
|
||||
if (vpPlaneXZ) { vpPlaneXZ->Size.setValue ( szXZ ); }
|
||||
if (vpPlaneYZ) { vpPlaneYZ->Size.setValue ( szYZ ); }
|
||||
if (vpLineX) { vpLineX->Size.setValue ( szX * axesScaling ); }
|
||||
if (vpLineY) { vpLineY->Size.setValue ( szY * axesScaling ); }
|
||||
if (vpLineZ) { vpLineZ->Size.setValue ( szZ * axesScaling ); }
|
||||
|
||||
} catch (const Base::Exception &ex) {
|
||||
// While restoring a document don't report errors if one of the lines or planes
|
||||
// cannot be found.
|
||||
App::Document* doc = getObject()->getDocument();
|
||||
if (!doc->testStatus(App::Document::Restoring))
|
||||
Base::Console().Error ("%s\n", ex.what() );
|
||||
void ViewProviderOrigin::updateData(const App::Property* prop) {
|
||||
auto* jcs = dynamic_cast<App::LocalCoordinateSystem*>(getObject());
|
||||
if(jcs) {
|
||||
if (prop == &jcs->Placement) {
|
||||
// Update position
|
||||
}
|
||||
}
|
||||
|
||||
ViewProviderDocumentObject::onChanged ( prop );
|
||||
ViewProviderDocumentObject::updateData(prop);
|
||||
}
|
||||
|
||||
bool ViewProviderOrigin::onDelete(const std::vector<std::string> &) {
|
||||
auto origin = static_cast<App::Origin*>( getObject() );
|
||||
auto lcs = static_cast<App::LocalCoordinateSystem*>(getObject());
|
||||
|
||||
if ( !origin->getInList().empty() ) {
|
||||
auto origin = dynamic_cast<App::Origin*>(lcs);
|
||||
if (origin && !origin->getInList().empty()) {
|
||||
// Do not allow deletion of origin objects that are not lost.
|
||||
return false;
|
||||
}
|
||||
|
||||
auto objs = origin->OriginFeatures.getValues();
|
||||
origin->OriginFeatures.setValues({});
|
||||
auto objs = lcs->OriginFeatures.getValues();
|
||||
lcs->OriginFeatures.setValues({});
|
||||
|
||||
for (auto obj: objs ) {
|
||||
Gui::Command::doCommand( Gui::Command::Doc, "App.getDocument(\"%s\").removeObject(\"%s\")",
|
||||
|
||||
Reference in New Issue
Block a user