Feature Request 1880 - hide Template

This commit is contained in:
WandererFan 2017-02-01 20:30:56 -05:00 committed by Yorik van Havre
parent 12346a67ef
commit 18cd5b5166
5 changed files with 75 additions and 9 deletions

View File

@ -126,7 +126,6 @@ void QGISVGTemplate::draw()
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate(); TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
if(!tmplte) if(!tmplte)
throw Base::Exception("Template Feature not set for QGISVGTemplate"); throw Base::Exception("Template Feature not set for QGISVGTemplate");
load(QString::fromUtf8(tmplte->PageResult.getValue())); load(QString::fromUtf8(tmplte->PageResult.getValue()));
} }

View File

@ -471,8 +471,6 @@ QGIView * QGVPage::findParent(QGIView *view) const
void QGVPage::setPageTemplate(TechDraw::DrawTemplate *obj) void QGVPage::setPageTemplate(TechDraw::DrawTemplate *obj)
{ {
// Remove currently set background template
// Assign a base template class and create object dependent on
removeTemplate(); removeTemplate();
if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) { if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) {

View File

@ -92,7 +92,7 @@ void ViewProviderDrawingView::onChanged(const App::Property *prop)
} }
if (prop == &Visibility) { if (prop == &Visibility) {
if(Visibility.getValue()) { if(Visibility.getValue()) {
show(); show();
} else { } else {
hide(); hide();

View File

@ -37,10 +37,15 @@
#include <App/Application.h> #include <App/Application.h>
#include <App/Document.h> #include <App/Document.h>
#include <App/DocumentObject.h> #include <App/DocumentObject.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/SoFCSelection.h> #include <Gui/SoFCSelection.h>
#include <Gui/Selection.h> #include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawTemplate.h> #include <Mod/TechDraw/App/DrawTemplate.h>
#include "QGITemplate.h"
#include "QGVPage.h"
#include "MDIViewPage.h"
#include "ViewProviderTemplate.h" #include "ViewProviderTemplate.h"
using namespace TechDrawGui; using namespace TechDrawGui;
@ -53,6 +58,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderTemplate, Gui::ViewProviderDocumentObje
ViewProviderTemplate::ViewProviderTemplate() ViewProviderTemplate::ViewProviderTemplate()
{ {
sPixmap = "TechDraw_Tree_PageTemplate"; sPixmap = "TechDraw_Tree_PageTemplate";
DisplayMode.setStatus(App::Property::ReadOnly,true);
} }
ViewProviderTemplate::~ViewProviderTemplate() ViewProviderTemplate::~ViewProviderTemplate()
@ -80,10 +86,69 @@ std::vector<std::string> ViewProviderTemplate::getDisplayModes(void) const
void ViewProviderTemplate::updateData(const App::Property* prop) void ViewProviderTemplate::updateData(const App::Property* prop)
{ {
//Base::Console().Log("ViewProviderTemplate::updateData(%s)/n",prop->getName()); //Base::Console().Log("ViewProviderTemplate::updateData(%s)/n",prop->getName());
Gui::ViewProviderDocumentObject::updateData(prop); Gui::ViewProviderDocumentObject::updateData(prop);
} }
void ViewProviderTemplate::onChanged(const App::Property *prop)
{
App::DocumentObject* obj = getObject();
if (!obj || obj->isRestoring()) {
Gui::ViewProviderDocumentObject::onChanged(prop);
return;
}
if (prop == &Visibility) {
if(Visibility.getValue()) {
show();
} else {
hide();
}
}
Gui::ViewProviderDocumentObject::onChanged(prop);
}
void ViewProviderTemplate::show(void)
{
QGITemplate* qTemplate = getQTemplate();
if (qTemplate != nullptr) {
qTemplate->show();
}
ViewProviderDocumentObject::show();
}
void ViewProviderTemplate::hide(void)
{
QGITemplate* qTemplate = getQTemplate();
if (qTemplate != nullptr) {
qTemplate->hide();
}
ViewProviderDocumentObject::hide();
}
bool ViewProviderTemplate::isShow(void) const
{
return Visibility.getValue();
}
QGITemplate* ViewProviderTemplate::getQTemplate(void)
{
QGITemplate *result = nullptr;
TechDraw::DrawTemplate* dt = getTemplate();
if (dt) {
Gui::MDIView* gmdi = getActiveView();
if (gmdi != nullptr) {
MDIViewPage* mdi = dynamic_cast<MDIViewPage*>(gmdi);
if (mdi != nullptr) {
result = mdi->getQGVPage()->getTemplate();
}
}
}
return result;
}
TechDraw::DrawTemplate* ViewProviderTemplate::getTemplate() const TechDraw::DrawTemplate* ViewProviderTemplate::getTemplate() const
{ {
return dynamic_cast<TechDraw::DrawTemplate*>(pcObject); return dynamic_cast<TechDraw::DrawTemplate*>(pcObject);

View File

@ -1,7 +1,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (c) 2014 Luke Parry <l.parry@warwick.ac.uk> * * Copyright (c) 2014 Luke Parry <l.parry@warwick.ac.uk> *
* * * *
* This file is part of the FreeCAD CAx development system. * * This file is part of the FreeCAD CAx development system. *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public * * modify it under the terms of the GNU Library General Public *
@ -10,7 +10,7 @@
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. * * GNU Library General Public License for more details. *
* * * *
* You should have received a copy of the GNU Library General Public * * You should have received a copy of the GNU Library General Public *
@ -31,6 +31,7 @@ namespace TechDraw{
} }
namespace TechDrawGui { namespace TechDrawGui {
class QGITemplate;
class TechDrawGuiExport ViewProviderTemplate : public Gui::ViewProviderDocumentObject class TechDrawGuiExport ViewProviderTemplate : public Gui::ViewProviderDocumentObject
{ {
@ -48,8 +49,11 @@ 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*);
virtual void onChanged(const App::Property *prop);
public: virtual void hide(void);
virtual void show(void);
virtual bool isShow(void) const;
QGITemplate* getQTemplate(void);
TechDraw::DrawTemplate* getTemplate() const; TechDraw::DrawTemplate* getTemplate() const;
}; };