[TD]add progress reporting framework
This commit is contained in:
committed by
WandererFan
parent
5a92b30f17
commit
ae3a955877
@@ -581,7 +581,12 @@ void DrawView::requestPaint()
|
||||
signalGuiPaint(this);
|
||||
}
|
||||
|
||||
PyObject *DrawView::getPyObject()
|
||||
void DrawView::showProgressMessage(std::string featureName, std::string text)
|
||||
{
|
||||
signalProgressMessage(this, featureName, text);
|
||||
}
|
||||
|
||||
PyObject *DrawView::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
@@ -590,6 +595,8 @@ PyObject *DrawView::getPyObject()
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/App/moc_DrawView.cpp>
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
||||
@@ -94,16 +94,22 @@ public:
|
||||
virtual bool checkFit() const;
|
||||
virtual bool checkFit(DrawPage*) const;
|
||||
virtual void setPosition(double x, double y, bool force = false);
|
||||
virtual bool keepUpdated();
|
||||
boost::signals2::signal<void (const DrawView*)> signalGuiPaint;
|
||||
virtual double getScale() const;
|
||||
void checkScale();
|
||||
void requestPaint();
|
||||
virtual void handleXYLock();
|
||||
virtual bool isLocked() const;
|
||||
virtual bool showLock() const;
|
||||
virtual bool keepUpdated(void);
|
||||
|
||||
boost::signals2::signal<void (const DrawView*)> signalGuiPaint;
|
||||
boost::signals2::signal<void (const DrawView*, std::string, std::string)> signalProgressMessage;
|
||||
void requestPaint(void);
|
||||
void showProgressMessage(std::string featureName, std::string text);
|
||||
|
||||
virtual double getScale(void) const;
|
||||
void checkScale(void);
|
||||
|
||||
virtual void handleXYLock(void);
|
||||
virtual bool isLocked(void) const;
|
||||
virtual bool showLock(void) const;
|
||||
|
||||
std::vector<TechDraw::DrawLeaderLine*> getLeaders(void) const;
|
||||
|
||||
std::vector<TechDraw::DrawLeaderLine*> getLeaders() const;
|
||||
void setScaleAttribute();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -282,6 +282,8 @@ void DrawViewPart::addShapes2d(void)
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::execute() - %s\n", getNameInDocument());
|
||||
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
@@ -387,7 +389,8 @@ void DrawViewPart::partExec(TopoDS_Shape shape)
|
||||
{
|
||||
// Base::Console().Message("DVP::partExec()\n");
|
||||
if (waitingForResult()) {
|
||||
// Base::Console().Message("DVP::partExec - %s - GO is waiting for result\n", getNameInDocument());
|
||||
//finish what we are already doing before starting over
|
||||
// Base::Console().Message("DVP::partExec - %s - waiting for result\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -395,11 +398,13 @@ void DrawViewPart::partExec(TopoDS_Shape shape)
|
||||
delete geometryObject;
|
||||
geometryObject = nullptr;
|
||||
}
|
||||
showProgressMessage(getNameInDocument(), "is finding hidden lines");
|
||||
geometryObject = makeGeometryForShape(shape);
|
||||
}
|
||||
|
||||
GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape shape)
|
||||
{
|
||||
// Base::Console().Message("DVP::makeGeometryForShape()\n");
|
||||
gp_Pnt inputCenter;
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
|
||||
@@ -435,6 +440,7 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape shape)
|
||||
//note: slightly different than routine with same name in DrawProjectSplit
|
||||
TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis)
|
||||
{
|
||||
// Base::Console().Message("DVP::buildGeometryObject()\n");
|
||||
TechDraw::GeometryObject* go = new TechDraw::GeometryObject(getNameInDocument(), this);
|
||||
go->setIsoCount(IsoCount.getValue());
|
||||
go->isPerspective(Perspective.getValue());
|
||||
@@ -447,6 +453,7 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
|
||||
onHlrFinished(); //poly algo does not run in separate thread, so we need to invoke
|
||||
//the post hlr processing manually
|
||||
} else {
|
||||
// Base::Console().Message("DVP::buildGeometryObject - starting projectShape\n");
|
||||
waitingForHlr(true);
|
||||
QObject::connect(&m_hlrWatcher, SIGNAL(finished()), this, SLOT(onHlrFinished()));
|
||||
m_hlrFuture = QtConcurrent::run(go, &GeometryObject::projectShape, shape, viewAxis);
|
||||
@@ -459,17 +466,27 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
|
||||
//continue processing after hlr thread completes
|
||||
void DrawViewPart::onHlrFinished(void)
|
||||
{
|
||||
waitingForHlr(false);
|
||||
// Base::Console().Message("DVP::onHlrFinished()\n");
|
||||
|
||||
//the last hlr task is to make a bbox of the results
|
||||
bbox = geometryObject->calcBoundingBox();
|
||||
|
||||
waitingForHlr(false);
|
||||
QObject::disconnect(&m_hlrWatcher, SIGNAL(finished()), this, SLOT(onHlrFinished()));
|
||||
|
||||
showProgressMessage(getNameInDocument(), "has finished finding hidden lines");
|
||||
|
||||
postHlrTasks();
|
||||
|
||||
if (handleFaces() && !CoarseView.getValue()) {
|
||||
try {
|
||||
// Base::Console().Message("DVP::onHlrFinished - starting extractFaces\n");
|
||||
QObject::connect(&m_faceWatcher, SIGNAL(finished()), this, SLOT(onFacesFinished()));
|
||||
m_faceFuture = QtConcurrent::run(this, &DrawViewPart::extractFaces);
|
||||
m_faceWatcher.setFuture(m_faceFuture);
|
||||
}
|
||||
catch (Standard_Failure& e4) {
|
||||
waitingForFaces(false);
|
||||
Base::Console().Message("DVP::partExec - extractFaces failed for %s - %s **\n",getNameInDocument(),e4.GetMessageString());
|
||||
}
|
||||
}
|
||||
@@ -480,28 +497,42 @@ void DrawViewPart::onHlrFinished(void)
|
||||
|
||||
addReferencesToGeom();
|
||||
|
||||
postHlrTasks();
|
||||
|
||||
requestPaint();
|
||||
}
|
||||
|
||||
void DrawViewPart::postHlrTasks(void)
|
||||
{
|
||||
//nothing to do here. DVDetail and DVSection have special needs.
|
||||
//DVDetail and DVSection have special needs.
|
||||
//dimensions and balloons need to be recomputed here to get their references sorted
|
||||
|
||||
std::vector<TechDraw::DrawViewDimension*> dims = getDimensions();
|
||||
for (auto& d : dims) {
|
||||
d->recomputeFeature();
|
||||
}
|
||||
std::vector<TechDraw::DrawViewBalloon*> bals = getBalloons();
|
||||
for (auto& b : bals) {
|
||||
b->recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
//! make faces from the existing edge geometry
|
||||
void DrawViewPart::extractFaces()
|
||||
{
|
||||
if (!geometryObject) {
|
||||
// Base::Console().Message("DVP::extractFaces()\n");
|
||||
|
||||
if (geometryObject == nullptr) {
|
||||
//no geometry yet so don't bother
|
||||
// Base::Console().Message("DVP::extractFaces - GO is null\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (waitingForFaces()) {
|
||||
return;
|
||||
}
|
||||
// if (waitingForFaces()) {
|
||||
// Base::Console().Message("DVP::extractFaces - already extracting faces\n");
|
||||
// }
|
||||
|
||||
waitingForFaces(true);
|
||||
showProgressMessage(getNameInDocument(), "is extracting faces");
|
||||
|
||||
geometryObject->clearFaceGeom();
|
||||
const std::vector<TechDraw::BaseGeomPtr>& goEdges =
|
||||
geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue());
|
||||
@@ -635,6 +666,8 @@ void DrawViewPart::onFacesFinished(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::onFacesFinished()\n");
|
||||
waitingForFaces(false);
|
||||
QObject::disconnect(&m_faceWatcher, SIGNAL(finished()), this, SLOT(onFacesFinished()));
|
||||
showProgressMessage(getNameInDocument(), "has finished extracting faces");
|
||||
requestPaint();
|
||||
}
|
||||
|
||||
|
||||
@@ -458,8 +458,7 @@ void QGIViewPart::drawViewPart()
|
||||
removePrimitives(); //clean the slate
|
||||
removeDecorations();
|
||||
|
||||
#if MOD_TECHDRAW_HANDLE_FACES
|
||||
if (viewPart->handleFaces()) {
|
||||
if (viewPart->handleFaces() && !viewPart->CoarseView.getValue()) {
|
||||
// Draw Faces
|
||||
std::vector<TechDraw::DrawHatch*> hatchObjs = viewPart->getHatches();
|
||||
std::vector<TechDraw::DrawGeomHatch*> geomObjs = viewPart->getGeomHatches();
|
||||
@@ -529,7 +528,6 @@ void QGIViewPart::drawViewPart()
|
||||
newFace->draw();
|
||||
}
|
||||
}
|
||||
#endif //#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
// Draw Edges
|
||||
QColor edgeColor = PreferencesGui::normalQColor();
|
||||
|
||||
@@ -1201,11 +1201,11 @@ void QGSPage::postProcessXml(QTemporaryFile& temporaryFile, QString fileName, QS
|
||||
QDomDocument exportDoc(QString::fromUtf8("SvgDoc"));
|
||||
QFile file(temporaryFile.fileName());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
Base::Console().Message("QGSPage::ppsvg - tempfile open error\n");
|
||||
Base::Console().Error("QGSPage::ppsvg - tempfile open error\n");
|
||||
return;
|
||||
}
|
||||
if (!exportDoc.setContent(&file)) {
|
||||
Base::Console().Message("QGSPage::ppsvg - xml error\n");
|
||||
Base::Console().Error("QGSPage::ppsvg - xml error\n");
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
@@ -60,7 +61,6 @@ ViewProviderDrawingView::ViewProviderDrawingView()
|
||||
// Do not show in property editor why? wf WF: because DisplayMode applies only to coin and we
|
||||
// don't use coin.
|
||||
DisplayMode.setStatus(App::Property::Hidden,true);
|
||||
m_docReady = true;
|
||||
}
|
||||
|
||||
ViewProviderDrawingView::~ViewProviderDrawingView()
|
||||
@@ -73,9 +73,11 @@ void ViewProviderDrawingView::attach(App::DocumentObject *pcFeat)
|
||||
ViewProviderDocumentObject::attach(pcFeat);
|
||||
|
||||
auto bnd = boost::bind(&ViewProviderDrawingView::onGuiRepaint, this, bp::_1);
|
||||
auto bndProgressMessage = boost::bind(&ViewProviderDrawingView::onProgressMessage, this, bp::_1, bp::_2, bp::_3);
|
||||
auto feature = getViewObject();
|
||||
if (feature) {
|
||||
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
|
||||
connectProgressMessage = feature->signalProgressMessage.connect(bndProgressMessage);
|
||||
//TODO: would be good to start the QGIV creation process here, but no guarantee we actually have
|
||||
// MDIVP or QGVP yet.
|
||||
// but parent page might. we may not be part of the document yet though!
|
||||
@@ -152,9 +154,8 @@ QGIView* ViewProviderDrawingView::getQView()
|
||||
TechDraw::DrawView* dv = getViewObject();
|
||||
if (dv) {
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
|
||||
if (guiDoc != nullptr) {
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
|
||||
ViewProviderPage* vpp = dynamic_cast<ViewProviderPage*>(vp);
|
||||
if (guiDoc) {
|
||||
ViewProviderPage* vpp = getViewProviderPage();
|
||||
if (vpp) {
|
||||
if (vpp->getQGSPage()) {
|
||||
qView = dynamic_cast<QGIView *>(vpp->getQGSPage()->findQViewForDocObj(getViewObject()));
|
||||
@@ -172,13 +173,11 @@ bool ViewProviderDrawingView::isShow() const
|
||||
|
||||
void ViewProviderDrawingView::startRestoring()
|
||||
{
|
||||
m_docReady = false;
|
||||
Gui::ViewProviderDocumentObject::startRestoring();
|
||||
}
|
||||
|
||||
void ViewProviderDrawingView::finishRestoring()
|
||||
{
|
||||
m_docReady = true;
|
||||
if (Visibility.getValue()) {
|
||||
show();
|
||||
} else {
|
||||
@@ -201,18 +200,23 @@ void ViewProviderDrawingView::updateData(const App::Property* prop)
|
||||
Gui::ViewProviderDocumentObject::updateData(prop);
|
||||
}
|
||||
|
||||
MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const
|
||||
ViewProviderPage* ViewProviderDrawingView::getViewProviderPage() const
|
||||
{
|
||||
MDIViewPage* result = nullptr;
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
|
||||
if (guiDoc) {
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
|
||||
ViewProviderPage* vpp = dynamic_cast<ViewProviderPage*>(vp);
|
||||
if (vpp) {
|
||||
result = vpp->getMDIViewPage();
|
||||
}
|
||||
return dynamic_cast<ViewProviderPage*>(vp);
|
||||
}
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const
|
||||
{
|
||||
ViewProviderPage* vpp = getViewProviderPage();
|
||||
if (vpp) {
|
||||
return vpp->getMDIViewPage();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Gui::MDIView *ViewProviderDrawingView::getMDIView() const
|
||||
@@ -235,8 +239,7 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
|
||||
for (auto& v: views) {
|
||||
if (v == getViewObject()) {
|
||||
//view v belongs to this page p
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(p);
|
||||
ViewProviderPage* vpPage = dynamic_cast<ViewProviderPage*>(vp);
|
||||
ViewProviderPage* vpPage = getViewProviderPage();
|
||||
if (vpPage) {
|
||||
if (vpPage->getQGSPage()) {
|
||||
QGIView* qView = dynamic_cast<QGIView *>(vpPage->getQGSPage()->findQViewForDocObj(v));
|
||||
@@ -255,9 +258,8 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
} else { //we are not part of the Gui page yet. ask page to add us.
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
|
||||
ViewProviderPage* vpPage = dynamic_cast<ViewProviderPage*>(vp);
|
||||
} else { //we are not part of the Gui page yet. ask page to add us.
|
||||
ViewProviderPage* vpPage = getViewProviderPage();
|
||||
if (vpPage) {
|
||||
if (vpPage->getQGSPage()) {
|
||||
vpPage->getQGSPage()->addView(dv);
|
||||
@@ -268,6 +270,32 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
|
||||
}
|
||||
}
|
||||
|
||||
//handle status updates from App/DrawView
|
||||
void ViewProviderDrawingView::onProgressMessage(const TechDraw::DrawView* dv,
|
||||
const std::string featureName,
|
||||
const std::string text)
|
||||
{
|
||||
// Q_UNUSED(featureName)
|
||||
Q_UNUSED(dv)
|
||||
// Q_UNUSED(text)
|
||||
showProgressMessage(featureName, text);
|
||||
}
|
||||
|
||||
void ViewProviderDrawingView::showProgressMessage(const std::string featureName, const std::string text) const
|
||||
{
|
||||
QString msg = QString::fromUtf8("%1 %2")
|
||||
.arg(Base::Tools::fromStdString(featureName),
|
||||
Base::Tools::fromStdString(text));
|
||||
if (Gui::getMainWindow()) {
|
||||
//neither of these work! Base::Console().Message() output preempts these messages??
|
||||
// Gui::getMainWindow()->showMessage(msg, 3000);
|
||||
// Gui::getMainWindow()->showStatus(Gui::MainWindow::Msg, msg);
|
||||
//Temporary implementation. This works, but the messages are queued up and
|
||||
//not displayed in the report window in real time??
|
||||
Base::Console().Message("%s\n", qPrintable(msg));
|
||||
}
|
||||
}
|
||||
|
||||
TechDraw::DrawView* ViewProviderDrawingView::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawView*>(pcObject);
|
||||
|
||||
@@ -76,14 +76,17 @@ public:
|
||||
//@}
|
||||
|
||||
virtual TechDraw::DrawView* getViewObject() const;
|
||||
void showProgressMessage(const std::string featureName, const std::string text) const;
|
||||
|
||||
void onGuiRepaint(const TechDraw::DrawView* dv);
|
||||
void onGuiRepaint(const TechDraw::DrawView* dv);
|
||||
void onProgressMessage(const TechDraw::DrawView* dv,
|
||||
const std::string featureName,
|
||||
const std::string text);
|
||||
typedef boost::signals2::scoped_connection Connection;
|
||||
Connection connectGuiRepaint;
|
||||
|
||||
Connection connectProgressMessage;
|
||||
|
||||
private:
|
||||
bool m_docReady; //sb MDI + QGraphicsScene ready
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderPage, Gui::ViewProviderDocumentObject)
|
||||
|
||||
ViewProviderPage::ViewProviderPage()
|
||||
: m_mdiView(nullptr),
|
||||
m_docReady(true),
|
||||
m_pageName(""),
|
||||
m_graphicsView(nullptr),
|
||||
m_graphicsScene(nullptr)
|
||||
{
|
||||
@@ -416,23 +416,7 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPage::startRestoring()
|
||||
{
|
||||
// Base::Console().Message("VPP::startRestoring()\n");
|
||||
//VPDO::startRestoring hides this VPP
|
||||
Gui::ViewProviderDocumentObject::startRestoring();
|
||||
}
|
||||
|
||||
//note this is called when this ViewProvider has been restored, not
|
||||
//when the whole document has been restored.
|
||||
void ViewProviderPage::finishRestoring()
|
||||
{
|
||||
// Base::Console().Message("VPP::finishRestoring() - canUpdate: %d viz: %d\n",
|
||||
// getDrawPage()->canUpdate(), Visibility.getValue());
|
||||
Gui::ViewProviderDocumentObject::finishRestoring();
|
||||
}
|
||||
|
||||
bool ViewProviderPage::isShow() const
|
||||
bool ViewProviderPage::isShow(void) const
|
||||
{
|
||||
return Visibility.getValue();
|
||||
}
|
||||
|
||||
@@ -77,9 +77,6 @@ public:
|
||||
bool onDelete(const std::vector<std::string> &) override;
|
||||
void onChanged(const App::Property *prop) override;
|
||||
void updateData(const App::Property* prop) override;
|
||||
void startRestoring() override;
|
||||
void finishRestoring() override;
|
||||
bool isRestoring() {return !m_docReady;}
|
||||
|
||||
TechDraw::DrawPage* getDrawPage() const;
|
||||
|
||||
@@ -115,7 +112,6 @@ protected:
|
||||
|
||||
private:
|
||||
QPointer<MDIViewPage> m_mdiView;
|
||||
bool m_docReady;
|
||||
std::string m_pageName;
|
||||
QGVPage* m_graphicsView;
|
||||
QGSPage* m_graphicsScene;
|
||||
|
||||
Reference in New Issue
Block a user