TechDraw: fix drawing update on undo/redo
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QAction>
|
||||
#include <QTimer>
|
||||
#include <QApplication>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QFileDialog>
|
||||
@@ -138,6 +139,10 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||
setWindowTitle(tabText);
|
||||
setCentralWidget(m_view); //this makes m_view a Qt child of MDIViewPage
|
||||
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setSingleShot(true);
|
||||
QObject::connect(m_timer,SIGNAL(timeout()),this,SLOT(onTimer()));
|
||||
|
||||
// Connect Signals and Slots
|
||||
QObject::connect(
|
||||
m_view->scene(), SIGNAL(selectionChanged()),
|
||||
@@ -383,6 +388,10 @@ void MDIViewPage::onDeleteObject(const App::DocumentObject& obj)
|
||||
}
|
||||
}
|
||||
|
||||
void MDIViewPage::onTimer() {
|
||||
updateDrawing(true);
|
||||
}
|
||||
|
||||
void MDIViewPage::updateTemplate(bool forceUpdate)
|
||||
{
|
||||
App::DocumentObject *templObj = m_vpPage->getDrawPage()->Template.getValue();
|
||||
@@ -412,11 +421,21 @@ void MDIViewPage::updateTemplate(bool forceUpdate)
|
||||
//this is time consuming. should only be used when there is a problem.
|
||||
//should have been called MDIViewPage::fixWidowAndOrphans()
|
||||
//void MDIViewPage::updateDrawing(bool forceUpdate)
|
||||
void MDIViewPage::updateDrawing(void)
|
||||
void MDIViewPage::updateDrawing(bool force)
|
||||
{
|
||||
if(!force) {
|
||||
m_timer->start(100);
|
||||
return;
|
||||
}
|
||||
m_timer->stop();
|
||||
|
||||
// get all the DrawViews for this page, including the second level ones
|
||||
// if we ever have collections of collections, we'll need to revisit this
|
||||
DrawPage* thisPage = m_vpPage->getDrawPage();
|
||||
|
||||
if(!thisPage->getNameInDocument())
|
||||
return;
|
||||
|
||||
std::vector<App::DocumentObject*> pChildren = thisPage->getAllViews();
|
||||
|
||||
// if dv doesn't have a graphic, make one
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QTimer;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TechDraw {
|
||||
@@ -66,8 +67,7 @@ public:
|
||||
|
||||
void attachTemplate(TechDraw::DrawTemplate *obj);
|
||||
void updateTemplate(bool force = false);
|
||||
// void updateDrawing(bool force = false);
|
||||
void updateDrawing(void);
|
||||
void updateDrawing(bool force = false);
|
||||
void matchSceneRectToTemplate(void);
|
||||
|
||||
bool onMsg(const char* pMsg,const char** ppReturn);
|
||||
@@ -112,6 +112,7 @@ public Q_SLOTS:
|
||||
void toggleKeepUpdated(void);
|
||||
// void testAction(void);
|
||||
void sceneSelectionChanged();
|
||||
void onTimer();
|
||||
|
||||
protected:
|
||||
void findMissingViews( const std::vector<App::DocumentObject*> &list, std::vector<App::DocumentObject*> &missing);
|
||||
@@ -151,6 +152,7 @@ private:
|
||||
std::string m_documentName;
|
||||
bool isSelectionBlocked;
|
||||
QGVPage *m_view;
|
||||
QTimer *m_timer;
|
||||
|
||||
QString m_currentPath;
|
||||
QPrinter::Orientation m_orientation;
|
||||
|
||||
@@ -158,7 +158,12 @@ void ViewProviderPage::removeMDIView(void)
|
||||
|
||||
void ViewProviderPage::updateData(const App::Property* prop)
|
||||
{
|
||||
if (prop == &(getDrawPage()->KeepUpdated)) {
|
||||
auto page = getDrawPage();
|
||||
if(!page) {
|
||||
Gui::ViewProviderDocumentObject::updateData(prop);
|
||||
return;
|
||||
}
|
||||
if (prop == &(page->KeepUpdated)) {
|
||||
if (getDrawPage()->KeepUpdated.getValue()) {
|
||||
sPixmap = "TechDraw_Tree_Page";
|
||||
} else {
|
||||
@@ -166,18 +171,22 @@ void ViewProviderPage::updateData(const App::Property* prop)
|
||||
}
|
||||
signalChangeIcon();
|
||||
//if the template is changed, rebuild the visual
|
||||
} else if (prop == &(getDrawPage()->Template)) {
|
||||
} else if (prop == &(page->Template)) {
|
||||
if(m_mdiView &&
|
||||
!getDrawPage()->isUnsetting()) {
|
||||
!page->isUnsetting()) {
|
||||
m_mdiView->matchSceneRectToTemplate();
|
||||
m_mdiView->updateTemplate();
|
||||
}
|
||||
} else if (prop == &(getDrawPage()->Label)) {
|
||||
} else if (prop == &(page->Label)) {
|
||||
if(m_mdiView &&
|
||||
!getDrawPage()->isUnsetting()) {
|
||||
m_mdiView->setTabText(getDrawPage()->Label.getValue());
|
||||
!page->isUnsetting()) {
|
||||
m_mdiView->setTabText(page->Label.getValue());
|
||||
}
|
||||
} else if (prop == &page->Views) {
|
||||
if(m_mdiView && !page->isUnsetting())
|
||||
m_mdiView->updateDrawing();
|
||||
}
|
||||
|
||||
Gui::ViewProviderDocumentObject::updateData(prop);
|
||||
}
|
||||
|
||||
@@ -245,14 +254,14 @@ bool ViewProviderPage::showMDIViewPage()
|
||||
|
||||
m_mdiView->setWindowTitle(tabTitle + QString::fromLatin1("[*]"));
|
||||
m_mdiView->setWindowIcon(Gui::BitmapFactory().pixmap("TechDraw_Tree_Page"));
|
||||
m_mdiView->updateDrawing();
|
||||
m_mdiView->updateDrawing(true);
|
||||
Gui::getMainWindow()->addWindow(m_mdiView);
|
||||
m_mdiView->viewAll(); //this is empty function
|
||||
m_mdiView->showMaximized();
|
||||
if(!getDrawPage()->KeepUpdated.getValue())
|
||||
getDrawPage()->KeepUpdated.setValue(true);
|
||||
} else {
|
||||
m_mdiView->updateDrawing();
|
||||
m_mdiView->updateDrawing(true);
|
||||
m_mdiView->redrawAllViews();
|
||||
m_mdiView->updateTemplate(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user