Skip to content

Commit

Permalink
+ fixes #1678: Visibility property is ignored on drawing sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 3, 2015
1 parent e796347 commit d8e0df9
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/Gui/Document.cpp
Expand Up @@ -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();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Gui/ViewProviderDocumentObject.cpp
Expand Up @@ -71,6 +71,7 @@ void ViewProviderDocumentObject::getTaskViewContent(std::vector<Gui::TaskView::T

void ViewProviderDocumentObject::startRestoring()
{
hide();
}

void ViewProviderDocumentObject::finishRestoring()
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Drawing/App/FeatureClip.cpp
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Drawing/App/FeatureClip.h
Expand Up @@ -48,6 +48,7 @@ class DrawingExport FeatureClip: public App::DocumentObjectGroup
App::PropertyFloat Height;
App::PropertyBool ShowFrame;
App::PropertyString ViewResult;
App::PropertyBool Visible;

/** @name methods overide Feature */
//@{
Expand Down
18 changes: 12 additions & 6 deletions src/Mod/Drawing/App/FeaturePage.cpp
Expand Up @@ -148,21 +148,27 @@ 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);
const std::vector<App::DocumentObject*> &SubGrp = SubGroup->Group.getValues();
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;
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Drawing/App/FeatureView.cpp
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Drawing/App/FeatureView.h
Expand Up @@ -50,6 +50,7 @@ class DrawingExport FeatureView : public App::DocumentObject

App::PropertyFloat X,Y,Scale,Rotation;
App::PropertyString ViewResult;
App::PropertyBool Visible;


/** @name methods overide Feature */
Expand Down
109 changes: 106 additions & 3 deletions src/Mod/Drawing/Gui/ViewProviderView.cpp
Expand Up @@ -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"


Expand All @@ -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()
Expand All @@ -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*)
{
}
Expand All @@ -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()
Expand All @@ -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*)
{
}
24 changes: 22 additions & 2 deletions src/Mod/Drawing/Gui/ViewProviderView.h
Expand Up @@ -48,7 +48,17 @@ class DrawingGuiExport ViewProviderDrawingView : public Gui::ViewProviderDocumen
/// 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
Expand All @@ -68,7 +78,17 @@ class DrawingGuiExport ViewProviderDrawingClip : public Gui::ViewProviderDocumen
/// 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
Expand Down

0 comments on commit d8e0df9

Please sign in to comment.