Preserve True/Projected state on save/restore
This commit is contained in:
@@ -186,7 +186,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
||||
,contentStr.c_str());
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
@@ -272,7 +272,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = 'r%%value%%'", FeatName.c_str());
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
@@ -359,7 +359,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '\u00d8%%value%%'", FeatName.c_str()); // \u00d8 is Capital O with stroke
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
@@ -450,7 +450,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
||||
doCommand(Doc,"App.activeDocument().%s.Type = '%s'", FeatName.c_str()
|
||||
, "Distance");
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
@@ -541,7 +541,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
||||
,"DistanceX");
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
@@ -631,7 +631,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
||||
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
|
||||
,"DistanceY");
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
@@ -713,7 +713,7 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
||||
,"%value%\u00b0"); // \u00b0 is degree sign
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
@@ -782,17 +782,14 @@ void CmdTechDrawLinkDimension::activated(int iMsg)
|
||||
|
||||
if (!page || !obj3D) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can't link a dimension from this selection"));
|
||||
QObject::tr("Can't link a dimension to this selection"));
|
||||
return;
|
||||
}
|
||||
|
||||
// dialog to select the Dimension to link
|
||||
Gui::Control().showDialog(new TaskDlgLinkDim(obj3D,subs,page));
|
||||
|
||||
//openCommand("Link Dimension");
|
||||
//commitCommand();
|
||||
page->getDocument()->recompute();
|
||||
|
||||
page->getDocument()->recompute(); //still need to recompute in Gui. why?
|
||||
}
|
||||
|
||||
bool CmdTechDrawLinkDimension::isActive(void)
|
||||
|
||||
@@ -250,7 +250,7 @@ void QGIViewDimension::updateView(bool update)
|
||||
return;
|
||||
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension*>(getViewObject());
|
||||
|
||||
std::vector<App::DocumentObject *> refs = dim->References.getValues();
|
||||
std::vector<App::DocumentObject *> refs = dim->References2D.getValues();
|
||||
|
||||
QGIDatumLabel *dLabel = dynamic_cast<QGIDatumLabel *>(datumLabel);
|
||||
|
||||
@@ -327,7 +327,7 @@ void QGIViewDimension::draw()
|
||||
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(getViewObject());
|
||||
if((!dim) || //nothing to draw, don't try
|
||||
(!dim->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) ||
|
||||
(!dim->hasReferences()) ) {
|
||||
(!dim->has2DReferences()) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,8 +351,8 @@ void QGIViewDimension::draw()
|
||||
Base::Vector3d lblCenter(lbl->X(), lbl->Y(), 0);
|
||||
|
||||
//we always draw based on Projected geometry.
|
||||
//const std::vector<App::DocumentObject*> &objects = dim->References.getValues();
|
||||
const std::vector<std::string> &SubNames = dim->References.getSubValues();
|
||||
//const std::vector<App::DocumentObject*> &objects = dim->References2D.getValues();
|
||||
const std::vector<std::string> &SubNames = dim->References2D.getSubValues();
|
||||
|
||||
const char *dimType = dim->Type.getValueAsString();
|
||||
|
||||
@@ -360,7 +360,7 @@ void QGIViewDimension::draw()
|
||||
strcmp(dimType, "DistanceX") == 0 ||
|
||||
strcmp(dimType, "DistanceY") == 0) {
|
||||
Base::Vector3d distStart, distEnd;
|
||||
if((dim->References.getValues().size() == 1) &&
|
||||
if((dim->References2D.getValues().size() == 1) &&
|
||||
(DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge")) {
|
||||
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = refObj->getProjEdgeByIndex(idx);
|
||||
@@ -378,7 +378,7 @@ void QGIViewDimension::draw()
|
||||
} else {
|
||||
throw Base::Exception("FVD::draw - Original edge not found or is invalid type (1)");
|
||||
}
|
||||
} else if(dim->References.getValues().size() == 2 &&
|
||||
} else if(dim->References2D.getValues().size() == 2 &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Vertex" &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex") {
|
||||
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
@@ -393,7 +393,7 @@ void QGIViewDimension::draw()
|
||||
}
|
||||
distStart = Base::Vector3d (v0->pnt.fX, v0->pnt.fY, 0.);
|
||||
distEnd = Base::Vector3d (v1->pnt.fX, v1->pnt.fY, 0.);
|
||||
} else if(dim->References.getValues().size() == 2 &&
|
||||
} else if(dim->References2D.getValues().size() == 2 &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
@@ -599,7 +599,7 @@ void QGIViewDimension::draw()
|
||||
Base::Vector3d lblCenter(label->X(), label->Y(), 0);
|
||||
double radius;
|
||||
|
||||
if(dim->References.getValues().size() == 1 &&
|
||||
if(dim->References2D.getValues().size() == 1 &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") {
|
||||
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
TechDrawGeometry::BaseGeom *geom = refObj->getProjEdgeByIndex(idx);
|
||||
@@ -864,7 +864,7 @@ void QGIViewDimension::draw()
|
||||
|
||||
Base::Vector3d pointOnCurve,curveCenter;
|
||||
double radius;
|
||||
if(dim->References.getValues().size() == 1 &&
|
||||
if(dim->References2D.getValues().size() == 1 &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") {
|
||||
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = refObj->getProjEdgeByIndex(idx);
|
||||
@@ -974,7 +974,7 @@ void QGIViewDimension::draw()
|
||||
|
||||
} else if(strcmp(dimType, "Angle") == 0) {
|
||||
// Only use two straight line edeges for angle
|
||||
if(dim->References.getValues().size() == 2 &&
|
||||
if(dim->References2D.getValues().size() == 2 &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
|
||||
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
|
||||
@@ -312,10 +312,10 @@ QGIView * QGVPage::findParent(QGIView *view) const
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(myView);
|
||||
|
||||
if(dim) {
|
||||
std::vector<App::DocumentObject *> objs = dim->References.getValues();
|
||||
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();
|
||||
|
||||
if(objs.size() > 0) {
|
||||
std::vector<App::DocumentObject *> objs = dim->References.getValues();
|
||||
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();
|
||||
// Attach the dimension to the first object's group
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
TechDraw::DrawView *viewObj = (*it)->getViewObject();
|
||||
|
||||
@@ -94,7 +94,7 @@ void TaskLinkDim::loadAvailDims()
|
||||
for (; itView != pageViews.end(); itView++) {
|
||||
if ((*itView)->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
||||
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>((*itView));
|
||||
if (dim->References.getValues().size() == m_subs.size()) {
|
||||
if (dim->References2D.getValues().size() == m_subs.size()) {
|
||||
QString label = QString::fromUtf8((*itView)->Label.getValue());
|
||||
QString name = QString::fromUtf8((*itView)->getNameInDocument());
|
||||
QString tooltip = label + QString::fromUtf8(" / ") + name;
|
||||
@@ -117,13 +117,17 @@ void TaskLinkDim::updateDims()
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
for (int i=0; i<count; i++) {
|
||||
QTreeWidgetItem* child = ui->selector->selectedTreeWidget()->topLevelItem(i);
|
||||
for (int iDim=0; iDim<count; iDim++) {
|
||||
QTreeWidgetItem* child = ui->selector->selectedTreeWidget()->topLevelItem(iDim);
|
||||
QString name = child->data(0, Qt::UserRole).toString();
|
||||
App::DocumentObject* obj = m_page->getDocument()->getObject(name.toStdString().c_str());
|
||||
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>(obj);
|
||||
dim->clearMeasurements();
|
||||
dim->setMeasurement(m_part,m_subs);
|
||||
std::vector<App::DocumentObject*> parts;
|
||||
for (unsigned int iPart = 0; iPart < m_subs.size(); iPart++) {
|
||||
parts.push_back(m_part);
|
||||
}
|
||||
dim->References3D.setValues(parts,m_subs);
|
||||
//dim->setMeasurement(m_part,m_subs);
|
||||
dim->MeasureType.setValue("True");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ std::vector<App::DocumentObject*> ViewProviderViewPart::claimChildren(void) cons
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
if((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
||||
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(*it);
|
||||
const std::vector<App::DocumentObject *> &refs = dim->References.getValues();
|
||||
const std::vector<App::DocumentObject *> &refs = dim->References2D.getValues();
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = refs.begin(); it != refs.end(); ++it) {
|
||||
if(strcmp(getViewPart()->getNameInDocument(), (*it)->getNameInDocument()) == 0) { //wf: isn't this test redundant?
|
||||
temp.push_back(dim); // if a dim is in the inlist,
|
||||
|
||||
Reference in New Issue
Block a user