Eliminate superfluous DPG executes

This commit is contained in:
WandererFan
2017-08-14 19:49:42 -04:00
committed by wmayer
parent 2524053887
commit e35e2f2573
26 changed files with 159 additions and 242 deletions

View File

@@ -271,7 +271,7 @@ void CmdTechDrawNewView::activated(int iMsg)
if (!selectedProjections.empty()) {
const auto myView( static_cast<TechDraw::DrawView*>(selectedProjections.front()) );
newScale = myView->Scale.getValue();
newScale = myView->getScale();
newRotation = myView->Rotation.getValue();
// The "Direction" property does not belong to TechDraw::DrawView, but to one of the
@@ -490,17 +490,12 @@ void CmdTechDrawProjGroup::activated(int iMsg)
App::DocumentObject *docObj = getDocument()->getObject(multiViewName.c_str());
auto multiView( static_cast<TechDraw::DrawProjGroup *>(docObj) );
// set the anchor
// std::string anchor = "Front";
// doCommand(Doc,"App.activeDocument().%s.addProjection('%s')",multiViewName.c_str(),anchor.c_str());
// add the multiView to the page
// doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),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
Gui::Control().showDialog(new TaskDlgProjGroup(multiView,true));
updateActive();
commitCommand();
}
bool CmdTechDrawProjGroup::isActive(void)

View File

@@ -411,6 +411,7 @@ void MDIViewPage::updateDrawing(bool forceUpdate)
}
}
//NOTE: this doesn't add missing views. see updateDrawing()
void MDIViewPage::redrawAllViews()
{
const std::vector<QGIView *> &upviews = m_view->getViews();
@@ -419,6 +420,7 @@ void MDIViewPage::redrawAllViews()
}
}
//NOTE: this doesn't add missing views. see updateDrawing()
void MDIViewPage::redraw1View(TechDraw::DrawView* dv)
{
std::string dvName = dv->getNameInDocument();

View File

@@ -131,7 +131,7 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
// this is just a pair isn't it?
if (getViewObject()->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
TechDraw::DrawProjGroupItem* dpgi = static_cast<TechDraw::DrawProjGroupItem*>(getViewObject());
TechDraw::DrawProjGroup* dpg = dpgi->getGroup();
TechDraw::DrawProjGroup* dpg = dpgi->getPGroup();
if ((dpg != nullptr) && dpg->AutoDistribute.getValue()) {
if(alignHash.size() == 1) { //if aligned.
QGraphicsItem*item = alignHash.begin().value();

View File

@@ -137,7 +137,7 @@ void QGIViewImage::drawImage()
if (!viewImage->ImageFile.isEmpty()) {
QString fileSpec = QString::fromUtf8(viewImage->ImageFile.getValue(),strlen(viewImage->ImageFile.getValue()));
m_imageItem->load(fileSpec);
m_imageItem->setScale(viewImage->Scale.getValue());
m_imageItem->setScale(viewImage->getScale());
QRectF br = m_cliparea->rect();
double midX = br.width()/2.0;
double midY = br.height()/2.0;

View File

@@ -619,7 +619,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
sectionLine->setDirection(arrowDir.x,arrowDir.y);
Base::Vector3d org = viewSection->SectionOrigin.getValue();
double scale = viewPart->Scale.getValue();
double scale = viewPart->getScale();
Base::Vector3d pOrg = scale * viewPart->projectPoint(org);
//now project pOrg onto arrowDir
Base::Vector3d displace;
@@ -730,7 +730,7 @@ void QGIViewPart::drawMatting()
return;
}
double scale = dvd->Scale.getValue();
double scale = dvd->getScale();
double radius = dvd->Radius.getValue() * scale;
QGIMatting* mat = new QGIMatting();
addToGroup(mat);

View File

@@ -123,7 +123,7 @@ void QGIViewSymbol::drawSvg()
//due to 1 sceneUnit (1mm) = 1 pixel for some QtSvg functions
double rezfactor = Rez::getRezFactor();
double scaling = viewSymbol->Scale.getValue() * rezfactor;
double scaling = viewSymbol->getScale() * rezfactor;
m_svgItem->setScale(scaling);
QByteArray qba(viewSymbol->Symbol.getValue(),strlen(viewSymbol->Symbol.getValue()));

View File

@@ -59,14 +59,6 @@ using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
//TODO: Look into this, seems we might be able to delete it now? IR
#if 0 // needed for Qt's lupdate utility
qApp->translate("QObject", "Make axonometric...");
qApp->translate("QObject", "Edit axonometric settings...");
qApp->translate("QObject", "Make orthographic");
#endif
TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
ui(new Ui_TaskProjGroup),
multiView(featView),
@@ -78,7 +70,7 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
ui->projection->setCurrentIndex(multiView->ProjectionType.getValue());
setFractionalScale(multiView->Scale.getValue());
setFractionalScale(multiView->getScale());
ui->cmbScaleType->setCurrentIndex(multiView->ScaleType.getValue());
// Initially toggle view checkboxes if needed
@@ -129,21 +121,16 @@ void TaskProjGroup::viewToggled(bool toggle)
QString viewName = sender()->objectName();
int index = viewName.mid(7).toInt();
const char *viewNameCStr = viewChkIndexToCStr(index);
App::DocumentObject* newObj;
TechDraw::DrawView* newView;
if ( toggle && !multiView->hasProjection( viewNameCStr ) ) {
newObj = multiView->addProjection( viewNameCStr );
newView = static_cast<TechDraw::DrawView*>(newObj);
m_mdi->redraw1View(newView);
(void) multiView->addProjection( viewNameCStr );
changed = true;
} else if ( !toggle && multiView->hasProjection( viewNameCStr ) ) {
multiView->removeProjection( viewNameCStr );
changed = true;
}
if (changed) {
multiView->recomputeFeature();
if (multiView->ScaleType.isValue("Automatic")) {
double scale = multiView->Scale.getValue();
double scale = multiView->getScale();
setFractionalScale(scale);
}
}
@@ -306,7 +293,7 @@ void TaskProjGroup::updateTask()
ui->cmbScaleType->setCurrentIndex(multiView->ScaleType.getValue());
// Update the scale value
setFractionalScale(multiView->Scale.getValue());
setFractionalScale(multiView->getScale());
blockUpdate = false;
}
@@ -339,7 +326,7 @@ void TaskProjGroup::scaleManuallyChanged(int i)
double scale = (double) a / (double) b;
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.Scale = %f", multiView->getNameInDocument()
, scale);
multiView->recomputeFeature();
multiView->recomputeFeature(); //just a repaint. multiView is already marked for recompute by changed to Scale
Gui::Command::updateActive();
}
@@ -465,8 +452,10 @@ bool TaskProjGroup::accept()
Gui::Document* doc = Gui::Application::Instance->getDocument(multiView->getDocument());
if (!doc) return false;
Gui::Command::commitCommand();
Gui::Command::updateActive();
if (!getCreateMode()) { //this is an edit session, end the transaction
Gui::Command::commitCommand();
}
//Gui::Command::updateActive(); //no chain of updates here
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
return true;

View File

@@ -231,14 +231,12 @@ 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.
auto page = dv->findParentPage();
if (page != nullptr) {
page->requestPaint();
}
}
// } else {
// auto vo = getViewObject();
// auto page = vo->findParentPage();
// if (page != nullptr) {
// page->requestPaint() ;
// }
}
}