Skip to content

Commit

Permalink
Feature Request 1880 - hide Template
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Feb 6, 2017
1 parent 2c7afff commit c47d043
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/Mod/TechDraw/Gui/QGISVGTemplate.cpp
Expand Up @@ -126,7 +126,6 @@ void QGISVGTemplate::draw()
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
if(!tmplte)
throw Base::Exception("Template Feature not set for QGISVGTemplate");

load(QString::fromUtf8(tmplte->PageResult.getValue()));
}

Expand Down
2 changes: 0 additions & 2 deletions src/Mod/TechDraw/Gui/QGVPage.cpp
Expand Up @@ -471,8 +471,6 @@ QGIView * QGVPage::findParent(QGIView *view) const

void QGVPage::setPageTemplate(TechDraw::DrawTemplate *obj)
{
// Remove currently set background template
// Assign a base template class and create object dependent on
removeTemplate();

if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) {
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp
Expand Up @@ -92,7 +92,7 @@ void ViewProviderDrawingView::onChanged(const App::Property *prop)
}

if (prop == &Visibility) {
if(Visibility.getValue()) {
if(Visibility.getValue()) {
show();
} else {
hide();
Expand Down
67 changes: 66 additions & 1 deletion src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp
Expand Up @@ -37,10 +37,15 @@
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>

#include <Mod/TechDraw/App/DrawTemplate.h>
#include "QGITemplate.h"
#include "QGVPage.h"
#include "MDIViewPage.h"
#include "ViewProviderTemplate.h"

using namespace TechDrawGui;
Expand All @@ -53,6 +58,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderTemplate, Gui::ViewProviderDocumentObje
ViewProviderTemplate::ViewProviderTemplate()
{
sPixmap = "TechDraw_Tree_PageTemplate";
DisplayMode.setStatus(App::Property::ReadOnly,true);
}

ViewProviderTemplate::~ViewProviderTemplate()
Expand Down Expand Up @@ -80,10 +86,69 @@ std::vector<std::string> ViewProviderTemplate::getDisplayModes(void) const

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);
}

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
{
return dynamic_cast<TechDraw::DrawTemplate*>(pcObject);
Expand Down
12 changes: 8 additions & 4 deletions src/Mod/TechDraw/Gui/ViewProviderTemplate.h
@@ -1,7 +1,7 @@
/***************************************************************************
* 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 *
* modify it under the terms of the GNU Library General Public *
Expand All @@ -10,7 +10,7 @@
* *
* This library is distributed in the hope that it will be useful, *
* 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. *
* *
* You should have received a copy of the GNU Library General Public *
Expand All @@ -31,6 +31,7 @@ namespace TechDraw{
}

namespace TechDrawGui {
class QGITemplate;

class TechDrawGuiExport ViewProviderTemplate : public Gui::ViewProviderDocumentObject
{
Expand All @@ -48,8 +49,11 @@ class TechDrawGuiExport ViewProviderTemplate : public Gui::ViewProviderDocumentO
/// returns a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);

public:
virtual void onChanged(const App::Property *prop);
virtual void hide(void);
virtual void show(void);
virtual bool isShow(void) const;
QGITemplate* getQTemplate(void);
TechDraw::DrawTemplate* getTemplate() const;
};

Expand Down

0 comments on commit c47d043

Please sign in to comment.