Remove superfluous updates

- under certain conditions, unnecessary screen paints
  were being performed.
This commit is contained in:
wandererfan
2019-03-04 12:55:50 -05:00
committed by wmayer
parent 2c700b72be
commit db3a69ba11
10 changed files with 52 additions and 44 deletions

View File

@@ -316,17 +316,20 @@ void CmdTechDrawNewView::activated(int iMsg)
if (subFound) {
std::pair<Base::Vector3d,Base::Vector3d> dirs = DrawGuiUtil::getProjDirFromFace(partFeat,faceName);
projDir = dirs.first;
getDocument()->setStatus(App::Document::Status::SkipRecompute, true);
doCommand(Doc,"App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)",
FeatName.c_str(), projDir.x,projDir.y,projDir.z);
doCommand(Doc,"App.activeDocument().%s.recompute()", FeatName.c_str());
getDocument()->setStatus(App::Document::Status::SkipRecompute, false);
} else {
std::pair<Base::Vector3d,Base::Vector3d> dirs = DrawGuiUtil::get3DDirAndRot();
projDir = dirs.first;
getDocument()->setStatus(App::Document::Status::SkipRecompute, true);
doCommand(Doc,"App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)",
FeatName.c_str(), projDir.x,projDir.y,projDir.z);
getDocument()->setStatus(App::Document::Status::SkipRecompute, false);
doCommand(Doc,"App.activeDocument().%s.recompute()", FeatName.c_str());
}
updateActive();
commitCommand();
}
@@ -390,7 +393,7 @@ void CmdTechDrawNewViewSection::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.Scale = %0.6f",FeatName.c_str(),baseScale);
Gui::Control().showDialog(new TaskDlgSectionView(dvp,dsv));
updateActive();
updateActive(); //ok here since dialog doesn't call doc.recompute()
commitCommand();
}
@@ -457,7 +460,7 @@ void CmdTechDrawNewViewDetail::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.Direction = App.activeDocument().%s.Direction",FeatName.c_str(),dvp->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
updateActive();
updateActive(); //ok here, no preceeding recompute
commitCommand();
}
@@ -545,10 +548,12 @@ void CmdTechDrawProjGroup::activated(int iMsg)
App::DocumentObject *docObj = getDocument()->getObject(multiViewName.c_str());
auto multiView( static_cast<TechDraw::DrawProjGroup *>(docObj) );
doCommand(Doc,"App.activeDocument().%s.addProjection('Front')",multiViewName.c_str());
multiView->Source.setValues(shapes);
if (subFound) {
std::pair<Base::Vector3d,Base::Vector3d> dirs = DrawGuiUtil::getProjDirFromFace(partFeat,faceName);
getDocument()->setStatus(App::Document::Status::SkipRecompute, true);
doCommand(Doc,"App.activeDocument().%s.Anchor.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)",
multiViewName.c_str(), dirs.first.x,dirs.first.y,dirs.first.z);
doCommand(Doc,"App.activeDocument().%s.Anchor.RotationVector = FreeCAD.Vector(%.3f,%.3f,%.3f)",
@@ -565,7 +570,6 @@ void CmdTechDrawProjGroup::activated(int iMsg)
getDocument()->setStatus(App::Document::Status::SkipRecompute, false);
doCommand(Doc,"App.activeDocument().%s.Anchor.recompute()", multiViewName.c_str());
}
//updateActive(); //exec all pending actions, but there's nothing to do here.
commitCommand(); //write the undo
// create the rest of the desired views
@@ -1192,7 +1196,6 @@ void CmdTechDrawExportPageDxf::activated(int iMsg)
openCommand("Save page to dxf");
doCommand(Doc,"import TechDraw");
doCommand(Doc,"TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")",PageName.c_str(),(const char*)fileName.toUtf8());
updateActive();
commitCommand();
}

View File

@@ -852,7 +852,6 @@ void MDIViewPage::saveDXF(std::string fileName)
Gui::Command::doCommand(Gui::Command::Doc,"import TechDraw");
Gui::Command::doCommand(Gui::Command::Doc,"TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")",
PageName.c_str(),(const char*)fileName.c_str());
Gui::Command::updateActive();
Gui::Command::commitCommand();
}

View File

@@ -275,6 +275,7 @@ QGIViewClip* QGIView::getClipGroup(void)
void QGIView::updateView(bool update)
{
// Base::Console().Message("QGIV::updateView() - %s\n",getViewObject()->getNameInDocument());
(void) update;
if (getViewObject()->isLocked()) {
setFlag(QGraphicsItem::ItemIsMovable, false);
} else {
@@ -294,10 +295,7 @@ void QGIView::updateView(bool update)
rotateView();
}
draw();
if (update)
QGraphicsItem::update();
QGIView::draw();
}
//QGIVP derived classes do not need a rotate view method as rotation is handled on App side.

View File

@@ -125,9 +125,7 @@ void QGIViewPart::setViewPartFeature(TechDraw::DrawViewPart *obj)
if (!obj)
return;
// called from QGVPage
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
draw();
}
QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom) const
@@ -315,7 +313,7 @@ void QGIViewPart::updateView(bool update)
auto end = std::chrono::high_resolution_clock::now();
auto diff = end - start;
double diffOut = std::chrono::duration <double, std::milli> (diff).count();
Base::Console().Log("TIMING - QGIVP::updateView - total %.3f millisecs\n",diffOut);
Base::Console().Log("TIMING - QGIVP::updateView - %s - total %.3f millisecs\n",getViewName(),diffOut);
}
void QGIViewPart::draw() {
@@ -324,7 +322,6 @@ void QGIViewPart::draw() {
QGIView::draw();
drawCenterLines(true); //have to draw centerlines after border to get size correct.
drawAllSectionLines(); //same for section lines
}
void QGIViewPart::drawViewPart()

View File

@@ -279,6 +279,13 @@ void QGVPage::removeQViewFromScene(QGIView *view)
QGIView * QGVPage::addViewPart(TechDraw::DrawViewPart *part)
{
QGIView* existing = findQViewForDocObj(part);
if (existing != nullptr) {
Base::Console().Log("INFO - QGVP::addViewPart - %s - QView exists\n",
part->getNameInDocument());
return existing;
}
auto viewPart( new QGIViewPart );
viewPart->setViewPartFeature(part);
@@ -666,7 +673,7 @@ void QGVPage::postProcessXml(QTemporaryFile* tempFile, QString fileName, QString
QFile outFile( fileName );
if( !outFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) {
Base::Console().Message("QGVP::ppxml - failed to open file for writing: %s\n.",qPrintable(fileName) );
Base::Console().Message("QGVP::ppxml - failed to open file for writing: %s\n",qPrintable(fileName) );
}
QTextStream stream( &outFile );
stream << doc.toString();

View File

@@ -170,7 +170,6 @@ void TaskProjGroup::rotateButtonClicked(void)
multiView->spinCCW();
}
setUiPrimary();
Gui::Command::updateActive();
}
}
@@ -257,7 +256,6 @@ void TaskProjGroup::scaleTypeChanged(int index)
}
multiView->recomputeFeature();
Gui::Command::updateActive();
}
std::pair<int, int> TaskProjGroup::nearestFraction(const double val, const long int maxDenom) const
@@ -375,7 +373,6 @@ void TaskProjGroup::scaleManuallyChanged(int i)
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.Scale = %f", multiView->getNameInDocument()
, scale);
multiView->recomputeFeature(); //just a repaint. multiView is already marked for recompute by changed to Scale
Gui::Command::updateActive();
}
void TaskProjGroup::changeEvent(QEvent *e)
@@ -500,7 +497,6 @@ bool TaskProjGroup::reject()
Base::Console().Log("TaskProjGroup: Edit mode - NO command is active\n");
}
Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
}
return false;