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

@@ -92,16 +92,17 @@ void DrawProjGroup::onChanged(const App::Property* prop)
TechDraw::DrawPage *page = getPage();
if (!isRestoring() && page) {
if (prop == &Source) {
std::vector<App::DocumentObject*> sourceObjs = Source.getValues();
if (!sourceObjs.empty()) {
if (!hasAnchor()) {
// if we have a Source, but no Anchor, make an anchor
Anchor.setValue(addProjection("Front"));
Anchor.purgeTouched(); //don't need to mark this
}
} else {
//Source has been changed to null! Why? What to do?
}
// std::vector<App::DocumentObject*> sourceObjs = Source.getValues();
// if (!sourceObjs.empty()) {
// if (!hasAnchor()) {
// // if we have a Source, but no Anchor, make an anchor
// Anchor.setValue(addProjection("Front")); //<<<<< semi-loop here!
// //add projection marks object as changed -> onChanged, but anchor value isn't set
// Anchor.purgeTouched(); //don't need to mark this
// }
// } else {
// //Source has been changed to null! Why? What to do?
// }
}
if (prop == &Scale) {
updateChildren();
@@ -143,7 +144,7 @@ void DrawProjGroup::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
{
// Base::Console().Message("DPG::execute()\n");
Base::Console().Message("DPG::execute()\n");
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
@@ -161,6 +162,7 @@ App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
App::DocumentObject* docObj = Anchor.getValue();
if (docObj == nullptr) {
//no anchor yet. Should we create 1 here?
return DrawViewCollection::execute();
}
@@ -370,6 +372,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
auto docObj( getDocument()->addObject( "TechDraw::DrawProjGroupItem", //add to Document
FeatName.c_str() ) );
view = static_cast<TechDraw::DrawProjGroupItem *>( docObj );
addView(view); //from DrawViewCollection
view->Source.setValues( Source.getValues() );
view->Scale.setValue( getScale() );
view->Type.setValue( viewProjType );
@@ -379,18 +382,21 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
vecs = getDirsFromFront(view);
view->Direction.setValue(vecs.first);
view->RotationVector.setValue(vecs.second);
view->recomputeFeature();
} else { //Front
//where do direction & Rotation Vector get set for front???
//where do direction & Rotation Vector get set for front??? from cmd::newDPG
Anchor.setValue(view);
Anchor.purgeTouched();
view->LockPosition.setValue(true); //lock "Front" position within DPG (note not Page!).
view->LockPosition.setStatus(App::Property::ReadOnly,true); //Front should stay locked.
App::GetApplication().signalChangePropertyEditor(view->LockPosition);
view->LockPosition.purgeTouched();
requestPaint();
}
addView(view); //from DrawViewCollection
if (view != getAnchor()) { //anchor is done elsewhere
view->recomputeFeature();
// requestPaint();
}
// addView(view); //from DrawViewCollection
// if (view != getAnchor()) { //anchor is done elsewhere
// view->recomputeFeature();
// }
}
return view;
@@ -802,6 +808,7 @@ void DrawProjGroup::updateChildrenLock(void)
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
if( view ) {
Base::Console().Message("DPG::updateChildrenLock requests paint for %s\n",view->getNameInDocument());
view->requestPaint();
}
}

View File

@@ -124,7 +124,6 @@ App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
return ret;
} else {
autoPosition();
requestPaint();
delete ret;
}
return App::DocumentObject::StdReturn;
@@ -141,11 +140,11 @@ void DrawProjGroupItem::autoPosition()
newPos = pgroup->getXYPosition(Type.getValueAsString());
X.setValue(newPos.x);
Y.setValue(newPos.y);
requestPaint();
purgeTouched(); //prevents "still touched after recompute" message
}
}
}
requestPaint();
purgeTouched(); //prevents "still touched after recompute" message
}
void DrawProjGroupItem::onDocumentRestored()

View File

@@ -142,7 +142,6 @@ void DrawView::onChanged(const App::Property* prop)
} else if (prop == &LockPosition) {
handleXYLock();
LockPosition.purgeTouched();
requestPaint();
}
}
App::DocumentObject::onChanged(prop);
@@ -161,26 +160,22 @@ void DrawView::handleXYLock(void)
X.setStatus(App::Property::ReadOnly,true);
App::GetApplication().signalChangePropertyEditor(X);
X.purgeTouched();
requestPaint();
}
if (!Y.testStatus(App::Property::ReadOnly)) {
Y.setStatus(App::Property::ReadOnly,true);
App::GetApplication().signalChangePropertyEditor(Y);
Y.purgeTouched();
requestPaint();
}
} else {
if (X.testStatus(App::Property::ReadOnly)) {
X.setStatus(App::Property::ReadOnly,false);
App::GetApplication().signalChangePropertyEditor(X);
X.purgeTouched();
requestPaint();
}
if (Y.testStatus(App::Property::ReadOnly)) {
Y.setStatus(App::Property::ReadOnly,false);
App::GetApplication().signalChangePropertyEditor(Y);
Y.purgeTouched();
requestPaint();
}
}
}

View File

@@ -266,6 +266,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
#if MOD_TECHDRAW_HANDLE_FACES
auto start = chrono::high_resolution_clock::now();
if (handleFaces() && !geometryObject->usePolygonHLR()) {
try {
extractFaces();
@@ -275,6 +276,12 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
return new App::DocumentObjectExecReturn(e4.GetMessageString());
}
}
auto end = chrono::high_resolution_clock::now();
auto diff = end - start;
double diffOut = chrono::duration <double, milli> (diff).count();
Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs handling Faces\n",
getNameInDocument(),diffOut);
#endif //#if MOD_TECHDRAW_HANDLE_FACES
requestPaint();

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;