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:
@@ -74,8 +74,6 @@ ViewProviderBody::ViewProviderBody()
|
||||
|
||||
ViewProviderBody::~ViewProviderBody()
|
||||
{
|
||||
connectChangedObjectApp.disconnect();
|
||||
connectChangedObjectGui.disconnect();
|
||||
}
|
||||
|
||||
void ViewProviderBody::attach(App::DocumentObject *pcFeat)
|
||||
@@ -85,20 +83,6 @@ void ViewProviderBody::attach(App::DocumentObject *pcFeat)
|
||||
|
||||
//set default display mode
|
||||
onChanged(&DisplayModeBody);
|
||||
|
||||
App::Document *adoc = pcObject->getDocument ();
|
||||
Gui::Document *gdoc = Gui::Application::Instance->getDocument ( adoc ) ;
|
||||
|
||||
assert ( adoc );
|
||||
assert ( gdoc );
|
||||
|
||||
//NOLINTBEGIN
|
||||
connectChangedObjectApp = adoc->signalChangedObject.connect (
|
||||
std::bind ( &ViewProviderBody::slotChangedObjectApp, this, sp::_1, sp::_2) );
|
||||
|
||||
connectChangedObjectGui = gdoc->signalChangedObject.connect (
|
||||
std::bind ( &ViewProviderBody::slotChangedObjectGui, this, sp::_1, sp::_2) );
|
||||
//NOLINTEND
|
||||
}
|
||||
|
||||
// TODO on activating the body switch to the "Through" mode (2015-09-05, Fat-Zer)
|
||||
@@ -228,8 +212,6 @@ void ViewProviderBody::updateData(const App::Property* prop)
|
||||
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
|
||||
|
||||
if (prop == &body->Group || prop == &body->BaseFeature) {
|
||||
// update sizes of origins and datums
|
||||
updateOriginDatumSize ();
|
||||
//ensure all model features are in visual body mode
|
||||
setVisualBodyMode(true);
|
||||
}
|
||||
@@ -252,122 +234,6 @@ void ViewProviderBody::updateData(const App::Property* prop)
|
||||
PartGui::ViewProviderPart::updateData(prop);
|
||||
}
|
||||
|
||||
void ViewProviderBody::slotChangedObjectApp ( const App::DocumentObject& obj, const App::Property& prop ) {
|
||||
|
||||
if(App::GetApplication().isRestoring())
|
||||
return;
|
||||
|
||||
if (!obj.isDerivedFrom ( Part::Feature::getClassTypeId () ) ||
|
||||
obj.isDerivedFrom ( Part::BodyBase::getClassTypeId () ) ) { // we are interested only in Part::Features, not in bodies
|
||||
return;
|
||||
}
|
||||
|
||||
const Part::Feature *feat = static_cast <const Part::Feature *>(&obj);
|
||||
|
||||
if ( &feat->Shape != &prop && &feat->Placement != &prop) { // react only on changes in shapes and placement
|
||||
return;
|
||||
}
|
||||
|
||||
PartDesign::Body *body = static_cast<PartDesign::Body*> ( getObject() );
|
||||
if ( body && body->hasObject (&obj ) ) {
|
||||
updateOriginDatumSize ();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderBody::slotChangedObjectGui (
|
||||
const Gui::ViewProviderDocumentObject& vp, const App::Property& prop )
|
||||
{
|
||||
if (&vp.Visibility != &prop) { // react only on visibility changes
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !vp.isDerivedFrom ( Gui::ViewProviderOrigin::getClassTypeId () ) &&
|
||||
!vp.isDerivedFrom ( Gui::ViewProviderDatum::getClassTypeId () ) ) {
|
||||
// Ignore origins to avoid infinite recursion (not likely in a well-formed document,
|
||||
// but may happen in documents designed in old versions of assembly branch )
|
||||
return;
|
||||
}
|
||||
|
||||
PartDesign::Body *body = static_cast<PartDesign::Body*> ( getObject() );
|
||||
App::DocumentObject *obj = vp.getObject ();
|
||||
|
||||
if ( body && obj && body->hasObject ( obj ) ) {
|
||||
updateOriginDatumSize ();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderBody::updateOriginDatumSize () {
|
||||
PartDesign::Body *body = static_cast<PartDesign::Body *> ( getObject() );
|
||||
|
||||
// Use different bounding boxes for datums and for origins:
|
||||
Gui::Document* gdoc = Gui::Application::Instance->getDocument(getObject()->getDocument());
|
||||
if(!gdoc)
|
||||
return;
|
||||
|
||||
Gui::MDIView* view = gdoc->getViewOfViewProvider(this);
|
||||
if(!view)
|
||||
return;
|
||||
|
||||
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
|
||||
SoGetBoundingBoxAction bboxAction(viewer->getSoRenderManager()->getViewportRegion());
|
||||
|
||||
const auto & model = body->getFullModel ();
|
||||
|
||||
// BBox for Datums is calculated from all visible objects but treating datums as their basepoints only
|
||||
SbBox3f bboxDatums = ViewProviderDatum::getRelevantBoundBox ( bboxAction, model );
|
||||
// BBox for origin should take into account datums size also
|
||||
SbBox3f bboxOrigins = bboxDatums;
|
||||
|
||||
for(App::DocumentObject* obj : model) {
|
||||
if ( obj->isDerivedFrom ( Part::Datum::getClassTypeId () ) ) {
|
||||
ViewProvider *vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if (!vp) { continue; }
|
||||
|
||||
ViewProviderDatum *vpDatum = static_cast <ViewProviderDatum *> (vp) ;
|
||||
|
||||
vpDatum->setExtents ( bboxDatums );
|
||||
|
||||
bboxAction.apply ( vp->getRoot () );
|
||||
bboxOrigins.extendBy ( bboxAction.getBoundingBox () );
|
||||
}
|
||||
}
|
||||
|
||||
// get the bounding box values
|
||||
SbVec3f max = bboxOrigins.getMax();
|
||||
SbVec3f min = bboxOrigins.getMin();
|
||||
|
||||
// obtain an Origin and it's ViewProvider
|
||||
App::Origin* origin = nullptr;
|
||||
Gui::ViewProviderOrigin* vpOrigin = nullptr;
|
||||
try {
|
||||
origin = body->getOrigin ();
|
||||
assert (origin);
|
||||
|
||||
Gui::ViewProvider *vp = Gui::Application::Instance->getViewProvider(origin);
|
||||
if (!vp) {
|
||||
throw Base::ValueError ("No view provider linked to the Origin");
|
||||
}
|
||||
assert ( vp->isDerivedFrom ( Gui::ViewProviderOrigin::getClassTypeId () ) );
|
||||
vpOrigin = static_cast <Gui::ViewProviderOrigin *> ( vp );
|
||||
} catch (const Base::Exception &ex) {
|
||||
if(!getExtendedViewProvider()->getDocument()->getDocument()->testStatus(App::Document::Restoring))
|
||||
Base::Console().Error ("%s\n", ex.what() );
|
||||
return;
|
||||
}
|
||||
|
||||
// calculate the desired origin size
|
||||
Base::Vector3d size;
|
||||
|
||||
for (uint_fast8_t i=0; i<3; i++) {
|
||||
size[i] = std::max ( fabs ( max[i] ), fabs ( min[i] ) );
|
||||
if (size[i] < Precision::Confusion() ) {
|
||||
size[i] = Gui::ViewProviderOrigin::defaultSize();
|
||||
}
|
||||
}
|
||||
|
||||
vpOrigin->Size.setValue ( size*1.2 );
|
||||
}
|
||||
|
||||
void ViewProviderBody::onChanged(const App::Property* prop) {
|
||||
|
||||
if(prop == &DisplayModeBody) {
|
||||
|
||||
Reference in New Issue
Block a user