Add Page level redraw signal

This commit is contained in:
WandererFan
2017-08-03 11:24:13 -04:00
committed by wmayer
parent ddbbae9956
commit 2524053887
4 changed files with 38 additions and 10 deletions

View File

@@ -128,7 +128,6 @@ void DrawPage::onChanged(const App::Property* prop)
}
} else if(prop == &Scale) {
// touch all views in the Page as they may be dependent on this scale
// but the views know how to get their own Scale correctly.
const std::vector<App::DocumentObject*> &vals = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = vals.begin(); it < vals.end(); ++it) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(*it);
@@ -281,6 +280,11 @@ int DrawPage::removeView(App::DocumentObject *docObj)
return Views.getSize();
}
void DrawPage::requestPaint(void)
{
signalGuiPaint(this);
}
void DrawPage::onDocumentRestored()
{
std::vector<App::DocumentObject*> featViews = Views.getValues();

View File

@@ -24,6 +24,8 @@
#ifndef _DrawPage_h_
#define _DrawPage_h_
#include <boost/signals.hpp>
#include <App/DocumentObject.h>
#include <App/DocumentObjectGroup.h>
#include <App/PropertyStandard.h>
@@ -57,6 +59,7 @@ public:
int addView(App::DocumentObject *docObj);
int removeView(App::DocumentObject* docObj);
short mustExecute() const;
boost::signal<void (const DrawPage*)> signalGuiPaint;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
@@ -84,6 +87,7 @@ public:
double getPageHeight() const;
const char* getPageOrientation() const;
bool isDeleting(void) { return nowDeleting; }
void requestPaint(void);
protected:

View File

@@ -29,6 +29,9 @@
# include <QMenu>
# include <QTimer>
#include <QPointer>
#include <boost/signal.hpp>
#include <boost/bind.hpp>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
@@ -76,13 +79,6 @@ ViewProviderPage::ViewProviderPage()
{
sPixmap = "TechDraw_Tree_Page";
// ADD_PROPERTY(HintScale,(10.0));
// ADD_PROPERTY(HintOffsetX,(10.0));
// ADD_PROPERTY(HintOffsetY,(10.0));
// do not show this in the property editor
//Visibility.StatusBits.set(3, true);
//DisplayMode.StatusBits.set(3, true);
Visibility.setStatus(App::Property::Hidden,true);
DisplayMode.setStatus(App::Property::Hidden,true);
}
@@ -94,6 +90,15 @@ ViewProviderPage::~ViewProviderPage()
void ViewProviderPage::attach(App::DocumentObject *pcFeat)
{
ViewProviderDocumentObject::attach(pcFeat);
auto bnd = boost::bind(&ViewProviderPage::onGuiRepaint, this, _1);
auto feature = getDrawPage();
if (feature != nullptr) {
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
} else {
Base::Console().Log("VPP::attach has no Feature!\n");
}
}
void ViewProviderPage::setDisplayMode(const char* ModeName)
@@ -138,11 +143,13 @@ void ViewProviderPage::updateData(const App::Property* prop)
}
}
//if a view is added/deleted, rebuild the visual
if (prop == &(getDrawPage()->Views)) {
if(!m_mdiView.isNull() &&
!getDrawPage()->isDeleting()) {
m_mdiView->updateDrawing();
}
//if the template is changed, rebuild the visual
} else if (prop == &(getDrawPage()->Template)) {
if(m_mdiView &&
!getDrawPage()->isDeleting()) {
@@ -207,7 +214,6 @@ bool ViewProviderPage::showMDIViewPage()
m_mdiView->setWindowTitle(QObject::tr("Drawing viewer") + QString::fromLatin1("[*]"));
m_mdiView->setWindowIcon(Gui::BitmapFactory().pixmap("TechDraw_Tree_Page"));
m_mdiView->updateDrawing(true);
// m_mdiView->updateTemplate(true); //TODO: I don't think this is necessary? Ends up triggering a reload of SVG template, but the MDIViewPage constructor does too.
Gui::getMainWindow()->addWindow(m_mdiView);
m_mdiView->viewAll();
} else {
@@ -221,7 +227,6 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
{
std::vector<App::DocumentObject*> temp;
// Attach the template if it exists
App::DocumentObject *templateFeat = 0;
templateFeat = getDrawPage()->Template.getValue();
@@ -349,6 +354,17 @@ bool ViewProviderPage::isShow(void) const
return Visibility.getValue();
}
//! Redo the whole visual page
void ViewProviderPage::onGuiRepaint(const TechDraw::DrawPage* dp)
{
if (dp == getDrawPage()) {
if(!m_mdiView.isNull() &&
!getDrawPage()->isDeleting()) {
m_mdiView->updateDrawing();
}
}
}
TechDraw::DrawPage* ViewProviderPage::getDrawPage() const
{
//during redo, pcObject can become invalid, but non-zero??

View File

@@ -80,6 +80,10 @@ public:
bool isRestoring(void) {return !m_docReady;}
TechDraw::DrawPage* getDrawPage() const;
void onGuiRepaint(const TechDraw::DrawPage* dp);
typedef boost::signals::connection Connection;
Connection connectGuiRepaint;
void unsetEdit(int ModNum);
MDIViewPage* getMDIViewPage();
bool showMDIViewPage();