+ fixes #0001678: Visibility property is ignored on drawing sheets
This commit is contained in:
parent
e7963472b0
commit
d8e0df9e97
|
@ -666,7 +666,6 @@ void Document::Restore(Base::XMLReader &reader)
|
||||||
// RestoreDocFile then restores the visibility status again
|
// RestoreDocFile then restores the visibility status again
|
||||||
std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::iterator it;
|
std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::iterator it;
|
||||||
for (it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) {
|
for (it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) {
|
||||||
it->second->hide();
|
|
||||||
it->second->startRestoring();
|
it->second->startRestoring();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ void ViewProviderDocumentObject::getTaskViewContent(std::vector<Gui::TaskView::T
|
||||||
|
|
||||||
void ViewProviderDocumentObject::startRestoring()
|
void ViewProviderDocumentObject::startRestoring()
|
||||||
{
|
{
|
||||||
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewProviderDocumentObject::finishRestoring()
|
void ViewProviderDocumentObject::finishRestoring()
|
||||||
|
|
|
@ -58,6 +58,10 @@ FeatureClip::FeatureClip(void)
|
||||||
ADD_PROPERTY_TYPE(Height ,(10),group,App::Prop_None ,"The height of the view area of this clip");
|
ADD_PROPERTY_TYPE(Height ,(10),group,App::Prop_None ,"The height of the view area of this clip");
|
||||||
ADD_PROPERTY_TYPE(Width ,(10),group,App::Prop_None ,"The width of the view area of this clip");
|
ADD_PROPERTY_TYPE(Width ,(10),group,App::Prop_None ,"The width of the view area of this clip");
|
||||||
ADD_PROPERTY_TYPE(ShowFrame ,(0),group,App::Prop_None,"Specifies if the clip frame appears on the page or not");
|
ADD_PROPERTY_TYPE(ShowFrame ,(0),group,App::Prop_None,"Specifies if the clip frame appears on the page or not");
|
||||||
|
// The 'Visible' property is handled by the view provider exclusively. It has the 'Output' flag set to
|
||||||
|
// avoid to call the execute() method. The view provider touches the page object, instead.
|
||||||
|
App::PropertyType propType = static_cast<App::PropertyType>(App::Prop_Hidden|App::Prop_Output);
|
||||||
|
ADD_PROPERTY_TYPE(Visible, (true),group,propType,"Control whether frame is visible in page object");
|
||||||
}
|
}
|
||||||
|
|
||||||
FeatureClip::~FeatureClip()
|
FeatureClip::~FeatureClip()
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
App::PropertyFloat Height;
|
App::PropertyFloat Height;
|
||||||
App::PropertyBool ShowFrame;
|
App::PropertyBool ShowFrame;
|
||||||
App::PropertyString ViewResult;
|
App::PropertyString ViewResult;
|
||||||
|
App::PropertyBool Visible;
|
||||||
|
|
||||||
/** @name methods overide Feature */
|
/** @name methods overide Feature */
|
||||||
//@{
|
//@{
|
||||||
|
|
|
@ -148,12 +148,16 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void)
|
||||||
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
|
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
|
||||||
if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
|
if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
|
||||||
Drawing::FeatureView *View = dynamic_cast<Drawing::FeatureView *>(*It);
|
Drawing::FeatureView *View = dynamic_cast<Drawing::FeatureView *>(*It);
|
||||||
ofile << View->ViewResult.getValue();
|
if (View->Visible.getValue()) {
|
||||||
ofile << tempendl << tempendl << tempendl;
|
ofile << View->ViewResult.getValue();
|
||||||
|
ofile << tempendl << tempendl << tempendl;
|
||||||
|
}
|
||||||
} else if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId()) ) {
|
} else if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId()) ) {
|
||||||
Drawing::FeatureClip *Clip = dynamic_cast<Drawing::FeatureClip *>(*It);
|
Drawing::FeatureClip *Clip = dynamic_cast<Drawing::FeatureClip *>(*It);
|
||||||
ofile << Clip->ViewResult.getValue();
|
if (Clip->Visible.getValue()) {
|
||||||
ofile << tempendl << tempendl << tempendl;
|
ofile << Clip->ViewResult.getValue();
|
||||||
|
ofile << tempendl << tempendl << tempendl;
|
||||||
|
}
|
||||||
} else if ( (*It)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()) ) {
|
} else if ( (*It)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()) ) {
|
||||||
// getting children inside subgroups too
|
// getting children inside subgroups too
|
||||||
App::DocumentObjectGroup *SubGroup = dynamic_cast<App::DocumentObjectGroup *>(*It);
|
App::DocumentObjectGroup *SubGroup = dynamic_cast<App::DocumentObjectGroup *>(*It);
|
||||||
|
@ -161,8 +165,10 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void)
|
||||||
for (std::vector<App::DocumentObject*>::const_iterator Grit= SubGrp.begin();Grit!=SubGrp.end();++Grit) {
|
for (std::vector<App::DocumentObject*>::const_iterator Grit= SubGrp.begin();Grit!=SubGrp.end();++Grit) {
|
||||||
if ( (*Grit)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
|
if ( (*Grit)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
|
||||||
Drawing::FeatureView *SView = dynamic_cast<Drawing::FeatureView *>(*Grit);
|
Drawing::FeatureView *SView = dynamic_cast<Drawing::FeatureView *>(*Grit);
|
||||||
ofile << SView->ViewResult.getValue();
|
if (SView->Visible.getValue()) {
|
||||||
ofile << tempendl << tempendl << tempendl;
|
ofile << SView->ViewResult.getValue();
|
||||||
|
ofile << tempendl << tempendl << tempendl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,10 @@ FeatureView::FeatureView(void)
|
||||||
ADD_PROPERTY_TYPE(Y ,(0),group,App::Prop_None,"Y position of the view on the drawing in modelling units (mm)");
|
ADD_PROPERTY_TYPE(Y ,(0),group,App::Prop_None,"Y position of the view on the drawing in modelling units (mm)");
|
||||||
ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view");
|
ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view");
|
||||||
ADD_PROPERTY_TYPE(Rotation ,(0),group,App::Prop_None,"Rotation of the view in degrees counterclockwise");
|
ADD_PROPERTY_TYPE(Rotation ,(0),group,App::Prop_None,"Rotation of the view in degrees counterclockwise");
|
||||||
|
// The 'Visible' property is handled by the view provider exclusively. It has the 'Output' flag set to
|
||||||
|
// avoid to call the execute() method. The view provider touches the page object, instead.
|
||||||
|
App::PropertyType propType = static_cast<App::PropertyType>(App::Prop_Hidden|App::Prop_Output);
|
||||||
|
ADD_PROPERTY_TYPE(Visible, (true),group,propType,"Control whether view is visible in page object");
|
||||||
|
|
||||||
App::PropertyType type = (App::PropertyType)(App::Prop_Hidden);
|
App::PropertyType type = (App::PropertyType)(App::Prop_Hidden);
|
||||||
ADD_PROPERTY_TYPE(ViewResult ,(0),group,type,"Resulting SVG fragment of that view");
|
ADD_PROPERTY_TYPE(ViewResult ,(0),group,type,"Resulting SVG fragment of that view");
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
|
|
||||||
App::PropertyFloat X,Y,Scale,Rotation;
|
App::PropertyFloat X,Y,Scale,Rotation;
|
||||||
App::PropertyString ViewResult;
|
App::PropertyString ViewResult;
|
||||||
|
App::PropertyBool Visible;
|
||||||
|
|
||||||
|
|
||||||
/** @name methods overide Feature */
|
/** @name methods overide Feature */
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
#include <Gui/SoFCSelection.h>
|
#include <Gui/SoFCSelection.h>
|
||||||
#include <Gui/Selection.h>
|
#include <Gui/Selection.h>
|
||||||
|
|
||||||
|
#include <Mod/Drawing/App/FeatureView.h>
|
||||||
|
#include <Mod/Drawing/App/FeatureClip.h>
|
||||||
#include "ViewProviderView.h"
|
#include "ViewProviderView.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +52,9 @@ PROPERTY_SOURCE(DrawingGui::ViewProviderDrawingView, Gui::ViewProviderDocumentOb
|
||||||
ViewProviderDrawingView::ViewProviderDrawingView()
|
ViewProviderDrawingView::ViewProviderDrawingView()
|
||||||
{
|
{
|
||||||
sPixmap = "Page";
|
sPixmap = "Page";
|
||||||
|
|
||||||
|
// Do not show in property editor
|
||||||
|
DisplayMode.StatusBits.set(3, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewProviderDrawingView::~ViewProviderDrawingView()
|
ViewProviderDrawingView::~ViewProviderDrawingView()
|
||||||
|
@ -70,12 +74,59 @@ void ViewProviderDrawingView::setDisplayMode(const char* ModeName)
|
||||||
|
|
||||||
std::vector<std::string> ViewProviderDrawingView::getDisplayModes(void) const
|
std::vector<std::string> ViewProviderDrawingView::getDisplayModes(void) const
|
||||||
{
|
{
|
||||||
// get the modes of the father
|
|
||||||
std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
|
std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
|
||||||
|
|
||||||
return StrList;
|
return StrList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingView::show(void)
|
||||||
|
{
|
||||||
|
ViewProviderDocumentObject::show();
|
||||||
|
|
||||||
|
App::DocumentObject* obj = getObject();
|
||||||
|
if (!obj || obj->isRestoring())
|
||||||
|
return;
|
||||||
|
if (obj->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) {
|
||||||
|
// The 'Visible' property is marked as 'Output'. To update the drawing on recompute
|
||||||
|
// the parent page object is touched.
|
||||||
|
static_cast<Drawing::FeatureView*>(obj)->Visible.setValue(true);
|
||||||
|
std::vector<App::DocumentObject*> inp = obj->getInList();
|
||||||
|
for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
|
||||||
|
(*it)->touch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingView::hide(void)
|
||||||
|
{
|
||||||
|
ViewProviderDocumentObject::hide();
|
||||||
|
|
||||||
|
App::DocumentObject* obj = getObject();
|
||||||
|
if (!obj || obj->isRestoring())
|
||||||
|
return;
|
||||||
|
if (obj->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) {
|
||||||
|
// The 'Visible' property is marked as 'Output'. To update the drawing on recompute
|
||||||
|
// the parent page object is touched.
|
||||||
|
static_cast<Drawing::FeatureView*>(obj)->Visible.setValue(false);
|
||||||
|
std::vector<App::DocumentObject*> inp = obj->getInList();
|
||||||
|
for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
|
||||||
|
(*it)->touch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViewProviderDrawingView::isShow(void) const
|
||||||
|
{
|
||||||
|
return Visibility.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingView::startRestoring()
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingView::finishRestoring()
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
void ViewProviderDrawingView::updateData(const App::Property*)
|
void ViewProviderDrawingView::updateData(const App::Property*)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -87,6 +138,9 @@ PROPERTY_SOURCE(DrawingGui::ViewProviderDrawingClip, Gui::ViewProviderDocumentOb
|
||||||
ViewProviderDrawingClip::ViewProviderDrawingClip()
|
ViewProviderDrawingClip::ViewProviderDrawingClip()
|
||||||
{
|
{
|
||||||
sPixmap = "Page";
|
sPixmap = "Page";
|
||||||
|
|
||||||
|
// Do not show in property editor
|
||||||
|
DisplayMode.StatusBits.set(3, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewProviderDrawingClip::~ViewProviderDrawingClip()
|
ViewProviderDrawingClip::~ViewProviderDrawingClip()
|
||||||
|
@ -111,6 +165,55 @@ std::vector<std::string> ViewProviderDrawingClip::getDisplayModes(void) const
|
||||||
return StrList;
|
return StrList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingClip::show(void)
|
||||||
|
{
|
||||||
|
ViewProviderDocumentObjectGroup::show();
|
||||||
|
|
||||||
|
App::DocumentObject* obj = getObject();
|
||||||
|
if (!obj || obj->isRestoring())
|
||||||
|
return;
|
||||||
|
if (obj->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId())) {
|
||||||
|
// The 'Visible' property is marked as 'Output'. To update the drawing on recompute
|
||||||
|
// the parent page object is touched.
|
||||||
|
static_cast<Drawing::FeatureClip*>(obj)->Visible.setValue(true);
|
||||||
|
std::vector<App::DocumentObject*> inp = obj->getInList();
|
||||||
|
for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
|
||||||
|
(*it)->touch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingClip::hide(void)
|
||||||
|
{
|
||||||
|
ViewProviderDocumentObjectGroup::hide();
|
||||||
|
|
||||||
|
App::DocumentObject* obj = getObject();
|
||||||
|
if (!obj || obj->isRestoring())
|
||||||
|
return;
|
||||||
|
if (obj->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId())) {
|
||||||
|
// The 'Visible' property is marked as 'Output'. To update the drawing on recompute
|
||||||
|
// the parent page object is touched.
|
||||||
|
static_cast<Drawing::FeatureClip*>(obj)->Visible.setValue(false);
|
||||||
|
std::vector<App::DocumentObject*> inp = obj->getInList();
|
||||||
|
for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
|
||||||
|
(*it)->touch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViewProviderDrawingClip::isShow(void) const
|
||||||
|
{
|
||||||
|
return Visibility.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingClip::startRestoring()
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderDrawingClip::finishRestoring()
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
void ViewProviderDrawingClip::updateData(const App::Property*)
|
void ViewProviderDrawingClip::updateData(const App::Property*)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,17 @@ public:
|
||||||
/// returns a list of all possible modes
|
/// returns a list of all possible modes
|
||||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||||
virtual void updateData(const App::Property*);
|
virtual void updateData(const App::Property*);
|
||||||
|
/// Hide the object in the view
|
||||||
|
virtual void hide(void);
|
||||||
|
/// Show the object in the view
|
||||||
|
virtual void show(void);
|
||||||
|
virtual bool isShow(void) const;
|
||||||
|
|
||||||
|
/** @name Restoring view provider from document load */
|
||||||
|
//@{
|
||||||
|
virtual void startRestoring();
|
||||||
|
virtual void finishRestoring();
|
||||||
|
//@}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawingGuiExport ViewProviderDrawingClip : public Gui::ViewProviderDocumentObjectGroup
|
class DrawingGuiExport ViewProviderDrawingClip : public Gui::ViewProviderDocumentObjectGroup
|
||||||
|
@ -68,7 +78,17 @@ public:
|
||||||
/// returns a list of all possible modes
|
/// returns a list of all possible modes
|
||||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||||
virtual void updateData(const App::Property*);
|
virtual void updateData(const App::Property*);
|
||||||
|
/// Hide the object in the view
|
||||||
|
virtual void hide(void);
|
||||||
|
/// Show the object in the view
|
||||||
|
virtual void show(void);
|
||||||
|
virtual bool isShow(void) const;
|
||||||
|
|
||||||
|
/** @name Restoring view provider from document load */
|
||||||
|
//@{
|
||||||
|
virtual void startRestoring();
|
||||||
|
virtual void finishRestoring();
|
||||||
|
//@}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace DrawingGui
|
} // namespace DrawingGui
|
||||||
|
|
Loading…
Reference in New Issue
Block a user