Eliminate superfluous DPG executes
This commit is contained in:
@@ -63,6 +63,7 @@ DrawProjGroup::DrawProjGroup(void)
|
||||
static const char *agroup = "Distribute";
|
||||
|
||||
|
||||
ADD_PROPERTY_TYPE(Source ,(0), group, App::Prop_None,"Shape to view");
|
||||
ADD_PROPERTY_TYPE(Anchor, (0), group, App::Prop_None, "The root view to align projections with");
|
||||
ProjectionType.setEnums(ProjectionTypeEnums);
|
||||
ADD_PROPERTY(ProjectionType, ((long)0));
|
||||
@@ -94,30 +95,21 @@ void DrawProjGroup::onChanged(const App::Property* prop)
|
||||
//if group hasn't been added to page yet, can't scale or distribute projItems
|
||||
TechDraw::DrawPage *page = getPage();
|
||||
if (!isRestoring() && page) {
|
||||
if ( prop == &Views ) {
|
||||
if (!isDeleting()) {
|
||||
recompute();
|
||||
}
|
||||
} else if (prop == &Scale) {
|
||||
updateChildren(Scale.getValue());
|
||||
//resetPositions();
|
||||
distributeProjections();
|
||||
} else if (prop == &Source) {
|
||||
if (prop == &Source) {
|
||||
App::DocumentObject* sourceObj = Source.getValue();
|
||||
if (sourceObj != nullptr) {
|
||||
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?
|
||||
}
|
||||
} else if (prop == &ScaleType) {
|
||||
recompute();
|
||||
} else if (prop == &AutoDistribute &&
|
||||
AutoDistribute.getValue()) {
|
||||
resetPositions();
|
||||
recompute();
|
||||
distributeProjections();
|
||||
|
||||
}
|
||||
}
|
||||
if (isRestoring() && (prop == &CubeDirs)) {
|
||||
@@ -164,30 +156,31 @@ App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
|
||||
return DrawViewCollection::execute();
|
||||
}
|
||||
|
||||
double newScale = Scale.getValue();
|
||||
double newScale = getScale();
|
||||
if (ScaleType.isValue("Automatic")) {
|
||||
//Recalculate scale if Group is too big or too small!
|
||||
if (!checkFit(page)) {
|
||||
newScale = calculateAutomaticScale();
|
||||
if(std::abs(Scale.getValue() - newScale) > FLT_EPSILON) {
|
||||
resetPositions();
|
||||
if(std::abs(getScale() - newScale) > FLT_EPSILON) {
|
||||
Scale.setValue(newScale);
|
||||
updateChildren(newScale);
|
||||
}
|
||||
}
|
||||
} else if (ScaleType.isValue("Page")) {
|
||||
} else if (ScaleType.isValue("Page")) { //don't really need this any more.
|
||||
newScale = page->Scale.getValue();
|
||||
if(std::abs(Scale.getValue() - newScale) > FLT_EPSILON) {
|
||||
resetPositions();
|
||||
if(std::abs(getScale() - newScale) > FLT_EPSILON) {
|
||||
Scale.setValue(newScale);
|
||||
updateChildren(newScale);
|
||||
}
|
||||
} else if (ScaleType.isValue("Custom")) {
|
||||
//don't have to do anything special
|
||||
updateChildren(newScale);
|
||||
}
|
||||
|
||||
// recalculate positions for children
|
||||
if (Views.getSize()) {
|
||||
updateChildren(newScale);
|
||||
distributeProjections();
|
||||
distributeProjections();
|
||||
|
||||
if (page != nullptr) {
|
||||
page->requestPaint();
|
||||
}
|
||||
|
||||
return DrawViewCollection::execute();
|
||||
@@ -219,8 +212,8 @@ Base::BoundBox3d DrawProjGroup::getBoundingBox() const
|
||||
DrawViewPart *part = static_cast<DrawViewPart *>(*it);
|
||||
Base::BoundBox3d bb = part->getBoundingBox();
|
||||
|
||||
bb.ScaleX(1. / part->Scale.getValue());
|
||||
bb.ScaleY(1. / part->Scale.getValue());
|
||||
bb.ScaleX(1. / part->getScale());
|
||||
bb.ScaleY(1. / part->getScale());
|
||||
|
||||
// X and Y of dependent views are relative to the anchorView
|
||||
if (part != anchorView) {
|
||||
@@ -290,10 +283,10 @@ QRectF DrawProjGroup::getRect() const //this is current rect, not potent
|
||||
arrangeViewPointers(viewPtrs);
|
||||
double width, height;
|
||||
minimumBbViews(viewPtrs, width, height); // w,h of just the views at 1:1 scale
|
||||
double xSpace = spacingX.getValue() * 3.0 * std::max(1.0,Scale.getValue());
|
||||
double ySpace = spacingY.getValue() * 2.0 * std::max(1.0,Scale.getValue());
|
||||
double rectW = Scale.getValue() * width + xSpace; //scale the 1:1 w,h and add whitespace
|
||||
double rectH = Scale.getValue() * height + ySpace;
|
||||
double xSpace = spacingX.getValue() * 3.0 * std::max(1.0,getScale());
|
||||
double ySpace = spacingY.getValue() * 2.0 * std::max(1.0,getScale());
|
||||
double rectW = getScale() * width + xSpace; //scale the 1:1 w,h and add whitespace
|
||||
double rectH = getScale() * height + ySpace;
|
||||
return QRectF(0,0,rectW,rectH);
|
||||
}
|
||||
|
||||
@@ -305,7 +298,7 @@ void DrawProjGroup::minimumBbViews(DrawProjGroupItem *viewPtrs[10],
|
||||
Base::BoundBox3d bboxes[10];
|
||||
makeViewBbs(viewPtrs, bboxes, false);
|
||||
|
||||
//TODO: note that TLF/TRF/BLF,BRF extent a bit farther than a strict row/col arrangement would suggest.
|
||||
//TODO: note that TLF/TRF/BLF,BRF extend a bit farther than a strict row/col arrangement would suggest.
|
||||
//get widest view in each row/column
|
||||
double col0w = std::max(std::max(bboxes[0].LengthX(), bboxes[3].LengthX()), bboxes[7].LengthX()),
|
||||
col1w = std::max(std::max(bboxes[1].LengthX(), bboxes[4].LengthX()), bboxes[8].LengthX()),
|
||||
@@ -399,15 +392,18 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
||||
} else {
|
||||
view->ScaleType.setValue( ScaleType.getValue() );
|
||||
}
|
||||
view->Scale.setValue( Scale.getValue() );
|
||||
view->Scale.setValue( getScale() );
|
||||
view->Type.setValue( viewProjType );
|
||||
view->Label.setValue( viewProjType );
|
||||
view->Source.setValue( Source.getValue() );
|
||||
view->Direction.setValue(m_cube->getViewDir(viewProjType));
|
||||
view->RotationVector.setValue(m_cube->getRotationDir(viewProjType));
|
||||
addView(view); //from DrawViewCollection - add to ProjGroup Views
|
||||
addView(view); //from DrawViewCollection
|
||||
moveToCentre();
|
||||
view->recomputeFeature();
|
||||
if (view != getAnchor()) { //anchor is done elsewhere
|
||||
view->recomputeFeature();
|
||||
}
|
||||
distributeProjections();
|
||||
}
|
||||
|
||||
return view;
|
||||
@@ -434,6 +430,7 @@ int DrawProjGroup::removeProjection(const char *viewProjType)
|
||||
}
|
||||
}
|
||||
}
|
||||
distributeProjections();
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -452,6 +449,11 @@ int DrawProjGroup::purgeProjections()
|
||||
removeProjection(itemName.c_str());
|
||||
}
|
||||
}
|
||||
auto page = findParentPage();
|
||||
if (page != nullptr) {
|
||||
page->requestPaint();
|
||||
}
|
||||
|
||||
return Views.getValues().size();
|
||||
}
|
||||
|
||||
@@ -524,7 +526,7 @@ void DrawProjGroup::makeViewBbs(DrawProjGroupItem *viewPtrs[10],
|
||||
if (viewPtrs[i]) {
|
||||
bboxes[i] = viewPtrs[i]->getBoundingBox();
|
||||
if (!documentScale) {
|
||||
double scale = 1.0 / viewPtrs[i]->Scale.getValue(); //convert bbx to 1:1 scale
|
||||
double scale = 1.0 / viewPtrs[i]->getScale(); //convert bbx to 1:1 scale
|
||||
bboxes[i].ScaleX(scale);
|
||||
bboxes[i].ScaleY(scale);
|
||||
bboxes[i].ScaleZ(scale);
|
||||
@@ -545,7 +547,6 @@ bool DrawProjGroup::distributeProjections()
|
||||
return true;
|
||||
}
|
||||
DrawProjGroupItem *viewPtrs[10];
|
||||
|
||||
arrangeViewPointers(viewPtrs);
|
||||
|
||||
// TODO: Work on not requiring the front view...
|
||||
@@ -607,6 +608,7 @@ bool DrawProjGroup::distributeProjections()
|
||||
}
|
||||
if (viewPtrs[4]) { // TODO: Move this check above, and figure out a sane bounding box based on other existing views
|
||||
}
|
||||
|
||||
if (viewPtrs[5] && viewPtrs[5]->allowAutoPos() &&
|
||||
bboxes[5].IsValid() &&
|
||||
bboxes[4].IsValid()) {
|
||||
@@ -637,49 +639,23 @@ bool DrawProjGroup::distributeProjections()
|
||||
viewPtrs[9]->X.setValue(bigCol + xSpacing);
|
||||
viewPtrs[9]->Y.setValue(-bigRow - ySpacing);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//!allow all child DPGI's to be automatically positioned
|
||||
void DrawProjGroup::resetPositions(void)
|
||||
{
|
||||
if (AutoDistribute.getValue()) {
|
||||
for( auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if( view ) {
|
||||
view->setAutoPos(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! tell children DPGIs that parent DPG has changed ?Scale?
|
||||
void DrawProjGroup::updateChildren(double scale)
|
||||
{
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if( view ) {
|
||||
if (ScaleType.isValue("Automatic")) {
|
||||
view->ScaleType.setValue("Custom");
|
||||
view->Scale.setStatus(App::Property::ReadOnly,true);
|
||||
} else if (ScaleType.isValue("Page")) {
|
||||
view->ScaleType.setValue("Page");
|
||||
view->Scale.setStatus(App::Property::ReadOnly,true);
|
||||
} else if (ScaleType.isValue("Custom")) {
|
||||
view->ScaleType.setValue("Custom");
|
||||
view->Scale.setStatus(App::Property::ReadOnly,true);
|
||||
}
|
||||
if(std::abs(view->Scale.getValue() - scale) > FLT_EPSILON) {
|
||||
if(std::abs(view->getScale() - scale) > FLT_EPSILON) {
|
||||
view->Scale.setValue(scale);
|
||||
view->recomputeFeature();
|
||||
}
|
||||
view->recomputeFeature();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//!check if ProjectionGroup fits on Page
|
||||
bool DrawProjGroup::checkFit(TechDraw::DrawPage* p) const
|
||||
{
|
||||
@@ -733,12 +709,7 @@ TechDraw::DrawProjGroupItem* DrawProjGroup::getAnchor(void)
|
||||
{
|
||||
DrawProjGroupItem* result = nullptr;
|
||||
App::DocumentObject* docObj = Anchor.getValue();
|
||||
if (docObj == nullptr) {
|
||||
//explode! DPG w/o anchor
|
||||
if (!isDeleting()) {
|
||||
Base::Console().Error("Error - DPG::getAnchor - DPG has no Anchor!!!\n");
|
||||
}
|
||||
} else {
|
||||
if (docObj != nullptr) {
|
||||
result = static_cast<DrawProjGroupItem*>(docObj);
|
||||
}
|
||||
return result;
|
||||
@@ -838,9 +809,13 @@ void DrawProjGroup::updateSecondaryDirs()
|
||||
}
|
||||
v->Direction.setValue(newDir);
|
||||
v->RotationVector.setValue(newAxis);
|
||||
// v->recomputeFeature();
|
||||
}
|
||||
setPropsFromCube();
|
||||
|
||||
auto page = findParentPage();
|
||||
if (page != nullptr) {
|
||||
page->requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
DrawProjGroup();
|
||||
~DrawProjGroup();
|
||||
|
||||
App::PropertyLink Source;
|
||||
App::PropertyEnumeration ProjectionType;
|
||||
|
||||
App::PropertyBool AutoDistribute;
|
||||
@@ -91,7 +92,6 @@ public:
|
||||
int purgeProjections();
|
||||
/// Automatically position child views
|
||||
bool distributeProjections(void);
|
||||
void resetPositions(void);
|
||||
|
||||
short mustExecute() const override;
|
||||
/** @name methods overide Feature */
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "GeometryObject.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "DrawPage.h"
|
||||
#include "DrawProjGroup.h"
|
||||
#include "DrawProjGroupItem.h"
|
||||
|
||||
@@ -104,7 +105,7 @@ void DrawProjGroupItem::onDocumentRestored()
|
||||
}
|
||||
}
|
||||
|
||||
DrawProjGroup* DrawProjGroupItem::getGroup() const
|
||||
DrawProjGroup* DrawProjGroupItem::getPGroup() const
|
||||
{
|
||||
DrawProjGroup* result = nullptr;
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
@@ -134,6 +135,7 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
|
||||
return viewAxis;
|
||||
}
|
||||
|
||||
//obs??
|
||||
//get the angle between the current RotationVector vector and the original X dir angle
|
||||
double DrawProjGroupItem::getRotateAngle()
|
||||
{
|
||||
@@ -160,15 +162,23 @@ double DrawProjGroupItem::getRotateAngle()
|
||||
return angle;
|
||||
}
|
||||
|
||||
//TODO: getScale is no longer needed and could revert to Scale.getValue
|
||||
double DrawProjGroupItem::getScale(void) const
|
||||
{
|
||||
double result = Scale.getValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void DrawProjGroupItem::unsetupObject()
|
||||
{
|
||||
if (getGroup() != nullptr) {
|
||||
if (getGroup()->hasProjection(Type.getValueAsString()) ) {
|
||||
if ((getGroup()->getAnchor() == this) &&
|
||||
!getGroup()->isDeleting() ) {
|
||||
if (getPGroup() != nullptr) {
|
||||
if (getPGroup()->hasProjection(Type.getValueAsString()) ) {
|
||||
if ((getPGroup()->getAnchor() == this) &&
|
||||
!getPGroup()->isDeleting() ) {
|
||||
Base::Console().Warning("Warning - DPG (%s/%s) may be corrupt - Anchor deleted\n",
|
||||
getGroup()->getNameInDocument(),getGroup()->Label.getValue());
|
||||
getGroup()->Anchor.setValue(nullptr); //this catches situation where DPGI is deleted w/o DPG::removeProjection
|
||||
getPGroup()->getNameInDocument(),getPGroup()->Label.getValue());
|
||||
getPGroup()->Anchor.setValue(nullptr); //this catches situation where DPGI is deleted w/o DPG::removeProjection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
virtual void onDocumentRestored() override;
|
||||
virtual void unsetupObject() override;
|
||||
|
||||
DrawProjGroup* getGroup(void) const;
|
||||
DrawProjGroup* getPGroup(void) const;
|
||||
double getRotateAngle();
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
@@ -76,6 +76,9 @@ public:
|
||||
const Base::Vector3d& direction,
|
||||
const bool flip=true) const override;
|
||||
|
||||
virtual double getScale(void) const override;
|
||||
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
|
||||
|
||||
@@ -94,57 +94,53 @@ DrawView::~DrawView()
|
||||
|
||||
App::DocumentObjectExecReturn *DrawView::execute(void)
|
||||
{
|
||||
TechDraw::DrawPage *page = findParentPage();
|
||||
if(page &&
|
||||
keepUpdated()) {
|
||||
if (ScaleType.isValue("Page")) {
|
||||
if(std::abs(page->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) {
|
||||
Scale.setValue(page->Scale.getValue());
|
||||
}
|
||||
} else if (ScaleType.isValue("Automatic")) {
|
||||
//check fit. if too big, rescale
|
||||
//if (dpg) { leave alone } else {
|
||||
if (this->isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId())) {
|
||||
//do nothing
|
||||
} else {
|
||||
if (!checkFit(page)) {
|
||||
double newScale = autoScale(page->getPageWidth(),page->getPageHeight());
|
||||
if(std::abs(newScale - Scale.getValue()) > FLT_EPSILON) { //stops onChanged/execute loop
|
||||
Scale.setValue(newScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ScaleType.isValue("Custom")) {
|
||||
//Base::Console().Message("TRACE - DV::execute - custom %s Scale: %.3f\n",getNameInDocument(),Scale.getValue());
|
||||
}
|
||||
requestPaint();
|
||||
}
|
||||
// TechDraw::DrawPage *page = findParentPage();
|
||||
// if(page &&
|
||||
// keepUpdated()) {
|
||||
// //nothing for DrawView to do
|
||||
// }
|
||||
return App::DocumentObject::StdReturn; //DO::execute returns 0
|
||||
}
|
||||
|
||||
void DrawView::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
//Base::Console().Message("TRACE - DV::onChanged(%s) - %s\n",prop->getName(),Label.getValue());
|
||||
if (prop == &ScaleType) {
|
||||
auto page = findParentPage();
|
||||
if (ScaleType.isValue("Page")) {
|
||||
Scale.setStatus(App::Property::ReadOnly,true);
|
||||
App::GetApplication().signalChangePropertyEditor(Scale);
|
||||
if (page != nullptr) {
|
||||
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
|
||||
Scale.setValue(page->Scale.getValue());
|
||||
}
|
||||
}
|
||||
} else if ( ScaleType.isValue("Custom") ) {
|
||||
//don't change Scale
|
||||
Scale.setStatus(App::Property::ReadOnly,false);
|
||||
App::GetApplication().signalChangePropertyEditor(Scale);
|
||||
} else if ( ScaleType.isValue("Automatic") ) {
|
||||
Scale.setStatus(App::Property::ReadOnly,true);
|
||||
App::GetApplication().signalChangePropertyEditor(Scale);
|
||||
if (this->isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId())) {
|
||||
//do nothing. DPG handles itself
|
||||
} else {
|
||||
if (!checkFit(page)) {
|
||||
double newScale = autoScale(page->getPageWidth(),page->getPageHeight());
|
||||
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
|
||||
Scale.setValue(newScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (prop == &X ||
|
||||
} else if (prop == &X || //nothing needs to be calculated, just the graphic needs to be shifted.
|
||||
prop == &Y) {
|
||||
if (isMouseMove()) { //actually "has mouse moved this item?"
|
||||
setAutoPos(false);
|
||||
}
|
||||
requestPaint();
|
||||
// if (isMouseMove()) { //actually "has mouse moved this item?"
|
||||
// setAutoPos(false);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
App::DocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
@@ -152,9 +148,7 @@ short DrawView::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (X.isTouched() ||
|
||||
Y.isTouched() ||
|
||||
Scale.isTouched() ||
|
||||
result = (Scale.isTouched() ||
|
||||
ScaleType.isTouched() );
|
||||
}
|
||||
if ((bool) result) {
|
||||
@@ -214,8 +208,8 @@ double DrawView::autoScale(double w, double h) const
|
||||
double fudgeFactor = 0.90;
|
||||
QRectF viewBox = getRect();
|
||||
//have to unscale rect to determine new scale
|
||||
double vbw = viewBox.width()/Scale.getValue();
|
||||
double vbh = viewBox.height()/Scale.getValue();
|
||||
double vbw = viewBox.width()/getScale();
|
||||
double vbh = viewBox.height()/getScale();
|
||||
double xScale = w/vbw;
|
||||
double yScale = h/vbh;
|
||||
//TODO: find a standard scale that's close? 1:2, 1:10, 1:100...? Logic in TaskProjGroup
|
||||
@@ -238,10 +232,15 @@ bool DrawView::checkFit(TechDraw::DrawPage* p) const
|
||||
|
||||
void DrawView::setPosition(double x, double y)
|
||||
{
|
||||
//recompute.lock()
|
||||
X.setValue(x);
|
||||
Y.setValue(y);
|
||||
//recompute.unlock()
|
||||
}
|
||||
|
||||
//TODO: getScale is no longer needed and could revert to Scale.getValue
|
||||
double DrawView::getScale(void) const
|
||||
{
|
||||
auto result = Scale.getValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawView::Restore(Base::XMLReader &reader)
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
DrawPage* findParentPage() const;
|
||||
bool allowAutoPos() {return autoPos;}; //sb in DPGI??
|
||||
void setAutoPos(bool state) {autoPos = state;};
|
||||
void setAutoPos(bool state) {autoPos = state;}; //autopos is obsolete
|
||||
bool isMouseMove() {return mouseMove;};
|
||||
void setMouseMove(bool state) {mouseMove = state;};
|
||||
virtual QRectF getRect() const; //must be overridden by derived class
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
virtual void setPosition(double x, double y);
|
||||
bool keepUpdated(void);
|
||||
boost::signal<void (const DrawView*)> signalGuiPaint;
|
||||
virtual double getScale(void) const;
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
|
||||
@@ -115,7 +115,7 @@ QRectF DrawViewAnnotation::getRect() const
|
||||
}
|
||||
int w = chars * std::max(1,(int)tSize);
|
||||
int h = lines * std::max(1,(int)tSize);
|
||||
result = QRectF(0,0,Scale.getValue() * w,Scale.getValue() * h);
|
||||
result = QRectF(0,0,getScale() * w,getScale() * h);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ App::DocumentObjectExecReturn *DrawViewArch::execute(void)
|
||||
<< ",renderMode=" << RenderMode.getValue()
|
||||
<< ",showHidden=" << (ShowHidden.getValue() ? "True" : "False")
|
||||
<< ",showFill=" << (ShowFill.getValue() ? "True" : "False")
|
||||
<< ",scale=" << Scale.getValue()
|
||||
<< ",scale=" << getScale()
|
||||
<< ",linewidth=" << LineWidth.getValue()
|
||||
<< ",fontsize=" << FontSize.getValue()
|
||||
<< ",techdraw=True"
|
||||
|
||||
@@ -46,7 +46,6 @@ DrawViewCollection::DrawViewCollection()
|
||||
{
|
||||
nowDeleting = false;
|
||||
static const char *group = "Drawing view";
|
||||
ADD_PROPERTY_TYPE(Source ,(0), group, App::Prop_None,"Shape to view");
|
||||
ADD_PROPERTY_TYPE(Views ,(0), group, App::Prop_None,"Attached Views");
|
||||
|
||||
}
|
||||
@@ -62,12 +61,6 @@ int DrawViewCollection::addView(DrawView *view)
|
||||
newViews.push_back(view);
|
||||
Views.setValues(newViews);
|
||||
|
||||
touch();
|
||||
//TODO: also have to touch the parent page's views to get repaint??
|
||||
DrawPage* page = findParentPage();
|
||||
if (page) {
|
||||
page->Views.touch();
|
||||
}
|
||||
return Views.getSize();
|
||||
}
|
||||
|
||||
@@ -85,11 +78,6 @@ int DrawViewCollection::removeView(DrawView *view)
|
||||
}
|
||||
Views.setValues(newViews);
|
||||
|
||||
//TODO: also have to touch the parent page's views to get repaint??
|
||||
DrawPage* page = findParentPage();
|
||||
if (page) {
|
||||
page->Views.touch();
|
||||
}
|
||||
return Views.getSize();
|
||||
}
|
||||
|
||||
@@ -101,7 +89,6 @@ void DrawViewCollection::rebuildViewList()
|
||||
std::vector<App::DocumentObject*> children = getOutList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) {
|
||||
//TechDraw::DrawView* view = static_cast<TechDraw::DrawView *>(*it);
|
||||
bool found = false;
|
||||
for (auto& v:currViews) {
|
||||
if (v == (*it)) {
|
||||
@@ -121,8 +108,7 @@ void DrawViewCollection::rebuildViewList()
|
||||
|
||||
short DrawViewCollection::mustExecute() const
|
||||
{
|
||||
if (Views.isTouched() ||
|
||||
Source.isTouched()) {
|
||||
if (Views.isTouched()) {
|
||||
return 1;
|
||||
} else {
|
||||
return TechDraw::DrawView::mustExecute();
|
||||
@@ -154,17 +140,6 @@ void DrawViewCollection::onDocumentRestored()
|
||||
|
||||
void DrawViewCollection::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &Views){
|
||||
if (!isRestoring()) {
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) {
|
||||
TechDraw::DrawPage *page = static_cast<TechDraw::DrawPage *>(*it);
|
||||
page->Views.touch(); //touches page only, not my_views!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TechDraw::DrawView::onChanged(prop);
|
||||
}
|
||||
|
||||
@@ -194,34 +169,6 @@ App::DocumentObjectExecReturn *DrawViewCollection::execute(void)
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
if (ScaleType.isValue("Page")) {
|
||||
const std::vector<App::DocumentObject *> &views = Views.getValues();
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::DocumentObject *docObj = *it;
|
||||
if(docObj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
TechDraw::DrawView *view = static_cast<TechDraw::DrawView *>(*it);
|
||||
|
||||
// Set scale factor of each view
|
||||
view->ScaleType.setValue("Page");
|
||||
view->touch();
|
||||
}
|
||||
}
|
||||
} else if(strcmp(ScaleType.getValueAsString(), "Custom") == 0) {
|
||||
// Rebuild the views
|
||||
const std::vector<App::DocumentObject *> &views = Views.getValues();
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::DocumentObject *docObj = *it;
|
||||
if(docObj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
TechDraw::DrawView *view = static_cast<TechDraw::DrawView *>(*it);
|
||||
|
||||
view->ScaleType.setValue("Custom");
|
||||
// Set scale factor of each view
|
||||
view->Scale.setValue(Scale.getValue());
|
||||
view->touch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
@@ -237,5 +184,5 @@ QRectF DrawViewCollection::getRect() const
|
||||
|
||||
result = result.united(view->getRect().translated(view->X.getValue(),view->Y.getValue()));
|
||||
}
|
||||
return QRectF(0,0,Scale.getValue() * result.width(),Scale.getValue() * result.height());
|
||||
return QRectF(0,0,getScale() * result.width(),getScale() * result.height());
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ class TechDrawExport DrawViewCollection : public DrawView
|
||||
PROPERTY_HEADER(TechDraw::DrawViewCollection);
|
||||
|
||||
public:
|
||||
App::PropertyLink Source;
|
||||
App::PropertyLinkList Views;
|
||||
public:
|
||||
/// Constructor
|
||||
|
||||
@@ -178,7 +178,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
||||
anchor = Base::Vector3d(anchor.x,anchor.y, 0.0);
|
||||
double radius = getFudgeRadius();
|
||||
Base::Vector3d dirDetail = dvp->Direction.getValue();
|
||||
double scale = Scale.getValue();
|
||||
double scale = getScale();
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(0.0,0.0,0.0), dirDetail, false);
|
||||
|
||||
Base::BoundBox3d bbxSource = partTopo.getBoundBox();
|
||||
|
||||
@@ -299,11 +299,11 @@ double DrawViewDimension::getDimValue()
|
||||
Base::Vector2d end = gen->points[1];
|
||||
Base::Vector2d line = end - start;
|
||||
if (Type.isValue("Distance")) {
|
||||
result = line.Length() / getViewPart()->Scale.getValue();
|
||||
result = line.Length() / getViewPart()->getScale();
|
||||
} else if (Type.isValue("DistanceX")) {
|
||||
return fabs(line.x) / getViewPart()->Scale.getValue();
|
||||
return fabs(line.x) / getViewPart()->getScale();
|
||||
} else {
|
||||
result = fabs(line.y) / getViewPart()->Scale.getValue();
|
||||
result = fabs(line.y) / getViewPart()->getScale();
|
||||
}
|
||||
}else if (getRefType() == twoEdge) {
|
||||
//only works for straight line edges
|
||||
@@ -332,15 +332,15 @@ double DrawViewDimension::getDimValue()
|
||||
Base::Vector2d s1 = gen1->points[0];
|
||||
Base::Vector2d e1 = gen1->points[1];
|
||||
if (Type.isValue("Distance")) {
|
||||
result = dist2Segs(s0,e0,s1,e1) / getViewPart()->Scale.getValue();
|
||||
result = dist2Segs(s0,e0,s1,e1) / getViewPart()->getScale();
|
||||
} else if (Type.isValue("DistanceX")) {
|
||||
Base::Vector2d p1 = geom0->nearPoint(geom1);
|
||||
Base::Vector2d p2 = geom1->nearPoint(geom0);
|
||||
result = fabs(p1.x - p2.x) / getViewPart()->Scale.getValue();
|
||||
result = fabs(p1.x - p2.x) / getViewPart()->getScale();
|
||||
} else if (Type.isValue("DistanceY")) {
|
||||
Base::Vector2d p1 = geom0->nearPoint(geom1);
|
||||
Base::Vector2d p2 = geom1->nearPoint(geom0);
|
||||
result = fabs(p1.y - p2.y) / getViewPart()->Scale.getValue();
|
||||
result = fabs(p1.y - p2.y) / getViewPart()->getScale();
|
||||
}
|
||||
} else if (getRefType() == twoVertex) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
@@ -357,11 +357,11 @@ double DrawViewDimension::getDimValue()
|
||||
Base::Vector2d end = v1->pnt;
|
||||
Base::Vector2d line = end - start;
|
||||
if (Type.isValue("Distance")) {
|
||||
result = line.Length() / getViewPart()->Scale.getValue();
|
||||
result = line.Length() / getViewPart()->getScale();
|
||||
} else if (Type.isValue("DistanceX")) {
|
||||
result = fabs(line.x) / getViewPart()->Scale.getValue();
|
||||
result = fabs(line.x) / getViewPart()->getScale();
|
||||
} else {
|
||||
result = fabs(line.y) / getViewPart()->Scale.getValue();
|
||||
result = fabs(line.y) / getViewPart()->getScale();
|
||||
}
|
||||
} else if (getRefType() == vertexEdge) {
|
||||
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
|
||||
@@ -384,11 +384,11 @@ double DrawViewDimension::getDimValue()
|
||||
Base::Vector2d nearPoint = e->nearPoint(v->pnt);
|
||||
Base::Vector2d line = nearPoint - v->pnt;
|
||||
if (Type.isValue("Distance")) {
|
||||
result = e->minDist(v->pnt) / getViewPart()->Scale.getValue();
|
||||
result = e->minDist(v->pnt) / getViewPart()->getScale();
|
||||
} else if (Type.isValue("DistanceX")) {
|
||||
result = fabs(line.x) / getViewPart()->Scale.getValue();
|
||||
result = fabs(line.x) / getViewPart()->getScale();
|
||||
} else {
|
||||
result = fabs(line.y) / getViewPart()->Scale.getValue();
|
||||
result = fabs(line.y) / getViewPart()->getScale();
|
||||
}
|
||||
} //else tarfu
|
||||
} else if(Type.isValue("Radius")){
|
||||
@@ -404,7 +404,7 @@ double DrawViewDimension::getDimValue()
|
||||
References2D.setValue(nullptr,"");
|
||||
return result;
|
||||
}
|
||||
result = circle->radius / getViewPart()->Scale.getValue(); //Projected BaseGeom is scaled for drawing
|
||||
result = circle->radius / getViewPart()->getScale(); //Projected BaseGeom is scaled for drawing
|
||||
|
||||
} else if(Type.isValue("Diameter")){
|
||||
//only 1 reference for a Diameter
|
||||
@@ -417,7 +417,7 @@ double DrawViewDimension::getDimValue()
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
result = (circle->radius * 2.0) / getViewPart()->Scale.getValue(); //Projected BaseGeom is scaled for drawing
|
||||
result = (circle->radius * 2.0) / getViewPart()->getScale(); //Projected BaseGeom is scaled for drawing
|
||||
} else if(Type.isValue("Angle")){
|
||||
// Must project lines to 2D so cannot use measurement framework this time
|
||||
//Relcalculate the measurement based on references stored.
|
||||
|
||||
@@ -103,7 +103,7 @@ App::DocumentObjectExecReturn *DrawViewDraft::execute(void)
|
||||
|
||||
std::stringstream paramStr;
|
||||
App::Color col = Color.getValue();
|
||||
paramStr << ",scale=" << Scale.getValue()
|
||||
paramStr << ",scale=" << getScale()
|
||||
<< ",linewidth=" << LineWidth.getValue()
|
||||
<< ",fontsize=" << FontSize.getValue()
|
||||
// TODO treat fillstyle here
|
||||
|
||||
@@ -149,7 +149,7 @@ App::DocumentObjectExecReturn *DrawViewMulti::execute(void)
|
||||
Direction.getValue());
|
||||
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(comp,
|
||||
inputCenter,
|
||||
Scale.getValue());
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
|
||||
|
||||
|
||||
@@ -172,8 +172,6 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
return new App::DocumentObjectExecReturn("DVP - Linked shape object is empty");
|
||||
}
|
||||
|
||||
(void) DrawView::execute(); //make sure Scale is up to date
|
||||
|
||||
gp_Pnt inputCenter;
|
||||
inputCenter = TechDrawGeometry::findCentroid(shape,
|
||||
Direction.getValue());
|
||||
@@ -182,10 +180,12 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
TopoDS_Shape mirroredShape;
|
||||
mirroredShape = TechDrawGeometry::mirrorShape(shape,
|
||||
inputCenter,
|
||||
Scale.getValue());
|
||||
getScale());
|
||||
|
||||
gp_Ax2 viewAxis = getViewAxis(shapeCentroid,Direction.getValue());
|
||||
// Base::Console().Message("Removing Hidden Lines from %s/%s\n",getNameInDocument(),Label.getValue());
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
|
||||
// Base::Console().Message("Finished Removing Hidden Lines\n");
|
||||
|
||||
//Base::Console().Message("TRACE - DVP::execute - u: %s v: %s w: %s\n",
|
||||
// DrawUtil::formatVector(getUDir()).c_str(), DrawUtil::formatVector(getVDir()).c_str(), DrawUtil::formatVector(getWDir()).c_str());
|
||||
@@ -226,7 +226,6 @@ short DrawViewPart::mustExecute() const
|
||||
|
||||
void DrawViewPart::onChanged(const App::Property* prop)
|
||||
{
|
||||
|
||||
DrawView::onChanged(prop);
|
||||
|
||||
//TODO: when scale changes, any Dimensions for this View sb recalculated. DVD should pick this up subject to topological naming issues.
|
||||
|
||||
@@ -260,7 +260,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
Direction.getValue());
|
||||
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(rawShape,
|
||||
inputCenter,
|
||||
Scale.getValue());
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis); //this is original shape after cut by section prism
|
||||
|
||||
@@ -277,7 +277,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
TopoDS_Compound sectionCompound = findSectionPlaneIntersections(rawShape);
|
||||
TopoDS_Shape mirroredSection = TechDrawGeometry::mirrorShape(sectionCompound,
|
||||
inputCenter,
|
||||
Scale.getValue());
|
||||
getScale());
|
||||
|
||||
sectionFaceWires.clear();
|
||||
TopoDS_Compound newFaces;
|
||||
|
||||
@@ -290,7 +290,7 @@ std::string DrawViewSpreadsheet::getSheetImage(void)
|
||||
if (std::find(skiplist.begin(), skiplist.end(), address.toString()) == skiplist.end()) {
|
||||
result << " <rect x=\"" << coloffset << "\" y=\"" << rowoffset << "\" width=\"" << cellwidth
|
||||
<< "\" height=\"" << cellheight << "\" style=\"fill:" << bcolor << ";stroke-width:"
|
||||
<< LineWidth.getValue()/Scale.getValue() << ";stroke:" << c.asCSSString() << ";\" />" << endl;
|
||||
<< LineWidth.getValue()/getScale() << ";stroke:" << c.asCSSString() << ";\" />" << endl;
|
||||
if (alignment & Spreadsheet::Cell::ALIGNMENT_LEFT)
|
||||
result << " <text style=\"" << textstyle << "\" x=\"" << coloffset + TextSize.getValue()/2 << "\" y=\"" << rowoffset + 0.75 * cellheight << "\" font-family=\"" ;
|
||||
if (alignment & Spreadsheet::Cell::ALIGNMENT_HCENTER)
|
||||
|
||||
@@ -144,7 +144,7 @@ QRectF DrawViewSymbol::getRect() const
|
||||
// std::string hNum = what[1].str();
|
||||
// h = std::stod(hNum);
|
||||
// }
|
||||
// return (QRectF(0,0,Scale.getValue() * w,Scale.getValue() * h));
|
||||
// return (QRectF(0,0,getScale() * w,getScale() * h));
|
||||
//we now have a w x h, but we don't really know what it means - px,mm,in,...
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() ;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user