PartDesign: change view sizing on new sketch

This commit is contained in:
DeepSOIC
2019-09-07 19:52:12 +03:00
committed by wmayer
parent 30bd6345f5
commit f19e21a224
3 changed files with 7 additions and 19 deletions

View File

@@ -154,6 +154,12 @@ void ViewProviderOrigin::resetTemporaryVisibility() {
tempVisMap.clear ();
}
double ViewProviderOrigin::defaultSize()
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
return 0.25 * hGrp->GetFloat("NewDocumentCameraScale",100.0);
}
bool ViewProviderOrigin::isTemporaryVisibility() {
return !tempVisMap.empty();
}

View File

@@ -75,7 +75,7 @@ public:
}
/// Returns default size. Use this if it is not possible to determine appropriate size by other means
static double defaultSize() {return 10.;}
static double defaultSize();
protected:
virtual void onChanged(const App::Property* prop);
virtual bool onDelete(const std::vector<std::string> &);

View File

@@ -720,24 +720,6 @@ void CmdPartDesignNewSketch::activated(int iMsg)
Base::Console().Error("Failed to create a Body object");
return;
}
// The method 'SoCamera::viewBoundingBox' is still declared as protected in Coin3d versions
// older than 4.0.
#if COIN_MAJOR_VERSION >= 4
// if no part feature was there then auto-adjust the camera
Gui::Document* guidoc = Gui::Application::Instance->getDocument(doc);
Gui::View3DInventor* view = guidoc ? qobject_cast<Gui::View3DInventor*>(guidoc->getActiveView()) : nullptr;
if (view) {
SoCamera* camera = view->getViewer()->getCamera();
SbViewportRegion vpregion = view->getViewer()->getViewportRegion();
float aspectratio = vpregion.getViewportAspectRatio();
float size = Gui::ViewProviderOrigin::defaultSize();
SbBox3f bbox;
bbox.setBounds(-size,-size,-size,size,size,size);
camera->viewBoundingBox(bbox, aspectratio, 1.0f);
}
#endif
}
// At this point, we have pcActiveBody