+ 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
|
||||
std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::iterator it;
|
||||
for (it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) {
|
||||
it->second->hide();
|
||||
it->second->startRestoring();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ void ViewProviderDocumentObject::getTaskViewContent(std::vector<Gui::TaskView::T
|
|||
|
||||
void ViewProviderDocumentObject::startRestoring()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
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(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");
|
||||
// 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()
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
App::PropertyFloat Height;
|
||||
App::PropertyBool ShowFrame;
|
||||
App::PropertyString ViewResult;
|
||||
App::PropertyBool Visible;
|
||||
|
||||
/** @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) {
|
||||
if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
|
||||
Drawing::FeatureView *View = dynamic_cast<Drawing::FeatureView *>(*It);
|
||||
ofile << View->ViewResult.getValue();
|
||||
ofile << tempendl << tempendl << tempendl;
|
||||
if (View->Visible.getValue()) {
|
||||
ofile << View->ViewResult.getValue();
|
||||
ofile << tempendl << tempendl << tempendl;
|
||||
}
|
||||
} else if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId()) ) {
|
||||
Drawing::FeatureClip *Clip = dynamic_cast<Drawing::FeatureClip *>(*It);
|
||||
ofile << Clip->ViewResult.getValue();
|
||||
ofile << tempendl << tempendl << tempendl;
|
||||
if (Clip->Visible.getValue()) {
|
||||
ofile << Clip->ViewResult.getValue();
|
||||
ofile << tempendl << tempendl << tempendl;
|
||||
}
|
||||
} else if ( (*It)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()) ) {
|
||||
// getting children inside subgroups too
|
||||
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) {
|
||||
if ( (*Grit)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
|
||||
Drawing::FeatureView *SView = dynamic_cast<Drawing::FeatureView *>(*Grit);
|
||||
ofile << SView->ViewResult.getValue();
|
||||
ofile << tempendl << tempendl << tempendl;
|
||||
if (SView->Visible.getValue()) {
|
||||
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(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");
|
||||
// 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);
|
||||
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::PropertyString ViewResult;
|
||||
App::PropertyBool Visible;
|
||||
|
||||
|
||||
/** @name methods overide Feature */
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
#include <Gui/SoFCSelection.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
|
||||
#include <Mod/Drawing/App/FeatureView.h>
|
||||
#include <Mod/Drawing/App/FeatureClip.h>
|
||||
#include "ViewProviderView.h"
|
||||
|
||||
|
||||
|
@ -51,6 +52,9 @@ PROPERTY_SOURCE(DrawingGui::ViewProviderDrawingView, Gui::ViewProviderDocumentOb
|
|||
ViewProviderDrawingView::ViewProviderDrawingView()
|
||||
{
|
||||
sPixmap = "Page";
|
||||
|
||||
// Do not show in property editor
|
||||
DisplayMode.StatusBits.set(3, true);
|
||||
}
|
||||
|
||||
ViewProviderDrawingView::~ViewProviderDrawingView()
|
||||
|
@ -70,12 +74,59 @@ void ViewProviderDrawingView::setDisplayMode(const char* ModeName)
|
|||
|
||||
std::vector<std::string> ViewProviderDrawingView::getDisplayModes(void) const
|
||||
{
|
||||
// get the modes of the father
|
||||
std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
|
||||
|
||||
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*)
|
||||
{
|
||||
}
|
||||
|
@ -87,6 +138,9 @@ PROPERTY_SOURCE(DrawingGui::ViewProviderDrawingClip, Gui::ViewProviderDocumentOb
|
|||
ViewProviderDrawingClip::ViewProviderDrawingClip()
|
||||
{
|
||||
sPixmap = "Page";
|
||||
|
||||
// Do not show in property editor
|
||||
DisplayMode.StatusBits.set(3, true);
|
||||
}
|
||||
|
||||
ViewProviderDrawingClip::~ViewProviderDrawingClip()
|
||||
|
@ -111,6 +165,55 @@ std::vector<std::string> ViewProviderDrawingClip::getDisplayModes(void) const
|
|||
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*)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -48,7 +48,17 @@ public:
|
|||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
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
|
||||
|
@ -68,7 +78,17 @@ public:
|
|||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user