[MeasureGui] Use temporary measure object creation (#15122)
* MeasureGui: Store measure type in TaskMeasure * MeasureGui: Avoid adding measurement to document during command interaction * [Gui] Add check for document in VPDocumentObject::getActiveView * MeasureGui: Track the document when adding objects * MeasureGui: Cleanup python measurement creation * [Gui] Add isAnnotationViewProvider method * [Gui] Check if viewprovider is added as an annotation in getActiveView * [Gui] Add takeAnnotationViewprovider method to Gui::Document * [Gui] Make addViewProvider public * [MeasureGui] Add existing view provider to document when storing measurement * [MeasureGui] Fix invocation of initial label placement * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -556,20 +556,41 @@ ViewProvider * Document::getAnnotationViewProvider(const char* name) const
|
||||
return ( (it != d->_ViewProviderMapAnnotation.end()) ? it->second : 0 );
|
||||
}
|
||||
|
||||
void Document::removeAnnotationViewProvider(const char* name)
|
||||
bool Document::isAnnotationViewProvider(const ViewProvider* vp) const
|
||||
{
|
||||
std::map<std::string,ViewProvider*>::iterator it = d->_ViewProviderMapAnnotation.find(name);
|
||||
std::list<Gui::BaseView*>::iterator vIt;
|
||||
std::map<std::string,ViewProvider*>::const_iterator it;
|
||||
for (it = d->_ViewProviderMapAnnotation.begin(); it != d->_ViewProviderMapAnnotation.end(); ++it) {
|
||||
if (it->second == vp)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// cycling to all views of the document
|
||||
for (vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) {
|
||||
auto activeView = dynamic_cast<View3DInventor *>(*vIt);
|
||||
if (activeView)
|
||||
activeView->getViewer()->removeViewProvider(it->second);
|
||||
|
||||
ViewProvider* Document::takeAnnotationViewProvider(const char* name)
|
||||
{
|
||||
auto it = d->_ViewProviderMapAnnotation.find(name);
|
||||
if (it == d->_ViewProviderMapAnnotation.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
delete it->second;
|
||||
ViewProvider* vp = it->second;
|
||||
d->_ViewProviderMapAnnotation.erase(it);
|
||||
|
||||
// cycling to all views of the document
|
||||
for (auto vIt : d->baseViews) {
|
||||
if (auto activeView = dynamic_cast<View3DInventor *>(vIt)) {
|
||||
activeView->getViewer()->removeViewProvider(vp);
|
||||
}
|
||||
}
|
||||
|
||||
return vp;
|
||||
}
|
||||
|
||||
|
||||
void Document::removeAnnotationViewProvider(const char* name)
|
||||
{
|
||||
delete takeAnnotationViewProvider(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user