Preserve True/Projected state on save/restore
This commit is contained in:
parent
7f7e63dfe0
commit
d73ffaa55b
|
@ -80,12 +80,12 @@ void Measurement::clear()
|
||||||
measureType = Invalid;
|
measureType = Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Measurement::hasReferences()
|
bool Measurement::has3DReferences()
|
||||||
{
|
{
|
||||||
return (References3D.getSize() > 0);
|
return (References3D.getSize() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience Methods for adding points
|
///add a 3D reference (obj+sub) to end of list
|
||||||
int Measurement::addReference3D(App::DocumentObject *obj, const char* subName)
|
int Measurement::addReference3D(App::DocumentObject *obj, const char* subName)
|
||||||
{
|
{
|
||||||
std::vector<App::DocumentObject*> objects = References3D.getValues();
|
std::vector<App::DocumentObject*> objects = References3D.getValues();
|
||||||
|
|
|
@ -55,10 +55,10 @@ public:
|
||||||
~Measurement();
|
~Measurement();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
bool hasReferences();
|
bool has3DReferences();
|
||||||
|
|
||||||
/// Add a reference
|
/// Add a reference
|
||||||
int addReference3D(App::DocumentObject *obj, const char *subName);
|
int addReference3D(App::DocumentObject* obj, const char *subName);
|
||||||
|
|
||||||
MeasureType getType();
|
MeasureType getType();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
<UserDocu>add a geometric reference</UserDocu>
|
<UserDocu>add a geometric reference</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</Methode>
|
||||||
|
<Methode Name="has3DReferences">
|
||||||
|
<Documentation>
|
||||||
|
<UserDocu>does Measurement have links to 3D geometry</UserDocu>
|
||||||
|
</Documentation>
|
||||||
|
</Methode>
|
||||||
<Methode Name="clear">
|
<Methode Name="clear">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>measure the difference between references to obtain resultant vector</UserDocu>
|
<UserDocu>measure the difference between references to obtain resultant vector</UserDocu>
|
||||||
|
|
|
@ -84,6 +84,19 @@ PyObject* MeasurementPy::addReference3D(PyObject *args)
|
||||||
Py_Return;
|
Py_Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject* MeasurementPy::has3DReferences(PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *result=Py_False;
|
||||||
|
if (!PyArg_ParseTuple(args, ""))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (getMeasurementPtr()->has3DReferences()) {
|
||||||
|
result = Py_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject* MeasurementPy::clear(PyObject *)
|
PyObject* MeasurementPy::clear(PyObject *)
|
||||||
{
|
{
|
||||||
this->getMeasurementPtr()->clear();
|
this->getMeasurementPtr()->clear();
|
||||||
|
|
|
@ -84,7 +84,8 @@ DrawViewDimension::DrawViewDimension(void)
|
||||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
|
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
|
||||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||||
|
|
||||||
ADD_PROPERTY_TYPE(References,(0,0),"Dimension",(App::PropertyType)(App::Prop_None),"Dimension Supporting References");
|
ADD_PROPERTY_TYPE(References2D,(0,0),"Dimension",(App::PropertyType)(App::Prop_None),"Projected Geometry References");
|
||||||
|
ADD_PROPERTY_TYPE(References3D,(0,0),"Dimension",(App::PropertyType)(App::Prop_None),"3D Geometry References");
|
||||||
ADD_PROPERTY_TYPE(Precision,(2) ,"Dimension",(App::PropertyType)(App::Prop_None),"Dimension Precision");
|
ADD_PROPERTY_TYPE(Precision,(2) ,"Dimension",(App::PropertyType)(App::Prop_None),"Dimension Precision");
|
||||||
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),"Dimension",App::Prop_None, "The name of the font to use");
|
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),"Dimension",App::Prop_None, "The name of the font to use");
|
||||||
ADD_PROPERTY_TYPE(Fontsize,(4) ,"Dimension",(App::PropertyType)(App::Prop_None),"Dimension text size in mm");
|
ADD_PROPERTY_TYPE(Fontsize,(4) ,"Dimension",(App::PropertyType)(App::Prop_None),"Dimension text size in mm");
|
||||||
|
@ -99,22 +100,12 @@ DrawViewDimension::DrawViewDimension(void)
|
||||||
ADD_PROPERTY(MeasureType, ((long)0)); //True or Projected measurement
|
ADD_PROPERTY(MeasureType, ((long)0)); //True or Projected measurement
|
||||||
|
|
||||||
//hide the DrawView properties that don't apply to Dimensions
|
//hide the DrawView properties that don't apply to Dimensions
|
||||||
//App::PropertyType propType = static_cast<App::PropertyType>(App::Prop_Hidden|App::Prop_Output);
|
|
||||||
//int bitReadOnly = 2;
|
|
||||||
//int bitHidden = 3;
|
|
||||||
//ScaleType.StatusBits.set(bitReadOnly, true);
|
|
||||||
//ScaleType.StatusBits.set(bitHidden, true);
|
|
||||||
//Scale.StatusBits.set(bitReadOnly, true);
|
|
||||||
//Scale.StatusBits.set(bitHidden,true);
|
|
||||||
//Rotation.StatusBits.set(bitReadOnly, true);
|
|
||||||
//Rotation.StatusBits.set(bitHidden, true);
|
|
||||||
ScaleType.setStatus(App::Property::ReadOnly,true);
|
ScaleType.setStatus(App::Property::ReadOnly,true);
|
||||||
ScaleType.setStatus(App::Property::Hidden,true);
|
ScaleType.setStatus(App::Property::Hidden,true);
|
||||||
Scale.setStatus(App::Property::ReadOnly,true);
|
Scale.setStatus(App::Property::ReadOnly,true);
|
||||||
Scale.setStatus(App::Property::Hidden,true);
|
Scale.setStatus(App::Property::Hidden,true);
|
||||||
Rotation.setStatus(App::Property::ReadOnly,true);
|
Rotation.setStatus(App::Property::ReadOnly,true);
|
||||||
Rotation.setStatus(App::Property::Hidden,true);
|
Rotation.setStatus(App::Property::Hidden,true);
|
||||||
//TODO: hide Dimension X,Y?
|
|
||||||
|
|
||||||
measurement = new Measure::Measurement();
|
measurement = new Measure::Measurement();
|
||||||
}
|
}
|
||||||
|
@ -128,7 +119,7 @@ DrawViewDimension::~DrawViewDimension()
|
||||||
void DrawViewDimension::onChanged(const App::Property* prop)
|
void DrawViewDimension::onChanged(const App::Property* prop)
|
||||||
{
|
{
|
||||||
if (!isRestoring()) {
|
if (!isRestoring()) {
|
||||||
if (prop == &References ||
|
if (prop == &References2D ||
|
||||||
prop == &Precision ||
|
prop == &Precision ||
|
||||||
prop == &Font ||
|
prop == &Font ||
|
||||||
prop == &Fontsize ||
|
prop == &Fontsize ||
|
||||||
|
@ -142,7 +133,7 @@ void DrawViewDimension::onChanged(const App::Property* prop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prop == &MeasureType) {
|
if (prop == &MeasureType) {
|
||||||
if (MeasureType.isValue("True") && !measurement->hasReferences()) {
|
if (MeasureType.isValue("True") && !measurement->has3DReferences()) {
|
||||||
Base::Console().Warning("Dimension %s missing Reference to 3D model. Must be Projected.\n", getNameInDocument());
|
Base::Console().Warning("Dimension %s missing Reference to 3D model. Must be Projected.\n", getNameInDocument());
|
||||||
MeasureType.setValue("Projected");
|
MeasureType.setValue("Projected");
|
||||||
}
|
}
|
||||||
|
@ -153,14 +144,29 @@ void DrawViewDimension::onChanged(const App::Property* prop)
|
||||||
catch (...) {
|
catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (prop == &References3D) { //have to rebuild the Measurement object
|
||||||
|
clear3DMeasurements();
|
||||||
|
set3DMeasurement(References3D.getValues().at(0),References3D.getSubValues());
|
||||||
|
}
|
||||||
|
|
||||||
DrawView::onChanged(prop);
|
DrawView::onChanged(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawViewDimension::onDocumentRestored()
|
||||||
|
{
|
||||||
|
if (has3DReferences()) {
|
||||||
|
clear3DMeasurements();
|
||||||
|
set3DMeasurement(References3D.getValues().at(0),References3D.getSubValues());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
short DrawViewDimension::mustExecute() const
|
short DrawViewDimension::mustExecute() const
|
||||||
{
|
{
|
||||||
bool result = 0;
|
bool result = 0;
|
||||||
if (References.isTouched() ||
|
if (References2D.isTouched() ||
|
||||||
Type.isTouched() ||
|
Type.isTouched() ||
|
||||||
MeasureType.isTouched()) {
|
MeasureType.isTouched()) {
|
||||||
result = 1;
|
result = 1;
|
||||||
|
@ -172,7 +178,7 @@ short DrawViewDimension::mustExecute() const
|
||||||
|
|
||||||
App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||||
{
|
{
|
||||||
if (!hasReferences()) { //too soon
|
if (!has2DReferences()) { //too soon
|
||||||
return App::DocumentObject::StdReturn;
|
return App::DocumentObject::StdReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +220,7 @@ std::string DrawViewDimension::getFormatedValue() const
|
||||||
double DrawViewDimension::getDimValue() const
|
double DrawViewDimension::getDimValue() const
|
||||||
{
|
{
|
||||||
double result = 0.0;
|
double result = 0.0;
|
||||||
if (!hasReferences()) { //happens during Dimension creation
|
if (!has2DReferences()) { //happens during Dimension creation
|
||||||
Base::Console().Message("INFO - DVD::getDimValue - Dimension has no References\n");
|
Base::Console().Message("INFO - DVD::getDimValue - Dimension has no References\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +232,7 @@ double DrawViewDimension::getDimValue() const
|
||||||
|
|
||||||
if (MeasureType.isValue("True")) {
|
if (MeasureType.isValue("True")) {
|
||||||
// True Values
|
// True Values
|
||||||
if (!measurement->hasReferences()) {
|
if (!measurement->has3DReferences()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(Type.isValue("Distance")) {
|
if(Type.isValue("Distance")) {
|
||||||
|
@ -251,8 +257,8 @@ double DrawViewDimension::getDimValue() const
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Projected Values
|
// Projected Values
|
||||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
|
||||||
const std::vector<std::string> &subElements = References.getSubValues();
|
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||||
if (Type.isValue("Distance") && getRefType() == oneEdge) {
|
if (Type.isValue("Distance") && getRefType() == oneEdge) {
|
||||||
//TODO: Check for straight line Edge?
|
//TODO: Check for straight line Edge?
|
||||||
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
int idx = DrawUtil::getIndexFromName(subElements[0]);
|
||||||
|
@ -397,13 +403,13 @@ DrawViewPart* DrawViewDimension::getViewPart() const
|
||||||
{
|
{
|
||||||
//TODO: range_check here if no References. valid situation during Dimension creation. what happens if return NULL??
|
//TODO: range_check here if no References. valid situation during Dimension creation. what happens if return NULL??
|
||||||
//need checks everywhere?
|
//need checks everywhere?
|
||||||
return dynamic_cast<TechDraw::DrawViewPart * >(References.getValues().at(0));
|
return dynamic_cast<TechDraw::DrawViewPart * >(References2D.getValues().at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrawViewDimension::getRefType() const
|
int DrawViewDimension::getRefType() const
|
||||||
{
|
{
|
||||||
int refType = invalidRef;
|
int refType = invalidRef;
|
||||||
const std::vector<std::string> &subElements = References.getSubValues();
|
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||||
if ((subElements.size() == 1) &&
|
if ((subElements.size() == 1) &&
|
||||||
(DrawUtil::getGeomTypeFromName(subElements[0]) == "Edge")) {
|
(DrawUtil::getGeomTypeFromName(subElements[0]) == "Edge")) {
|
||||||
refType = oneEdge;
|
refType = oneEdge;
|
||||||
|
@ -421,9 +427,9 @@ int DrawViewDimension::getRefType() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//!add 1 3D measurement Reference
|
//!add 1 3D measurement Reference
|
||||||
void DrawViewDimension::setMeasurement(DocumentObject* obj, std::vector<std::string>& subElements) const
|
void DrawViewDimension::set3DMeasurement(DocumentObject* const &obj, const std::vector<std::string>& subElements)
|
||||||
{
|
{
|
||||||
std::vector<std::string>::iterator itSub = subElements.begin();
|
std::vector<std::string>::const_iterator itSub = subElements.begin();
|
||||||
for (; itSub != subElements.end(); itSub++) {
|
for (; itSub != subElements.end(); itSub++) {
|
||||||
//int rc =
|
//int rc =
|
||||||
static_cast<void> (measurement->addReference3D(obj,(*itSub).c_str()));
|
static_cast<void> (measurement->addReference3D(obj,(*itSub).c_str()));
|
||||||
|
@ -431,28 +437,16 @@ void DrawViewDimension::setMeasurement(DocumentObject* obj, std::vector<std::str
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete all previous measurements
|
//delete all previous measurements
|
||||||
void DrawViewDimension::clearMeasurements()
|
void DrawViewDimension::clear3DMeasurements()
|
||||||
{
|
{
|
||||||
measurement->clear();
|
measurement->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrawViewDimension::get3DRef(int refIndex, std::string geomType) const
|
void DrawViewDimension::dumpRefs2D(char* text) const
|
||||||
{
|
|
||||||
int ref = -1;
|
|
||||||
if (geomType.compare("Edge") == 0) {
|
|
||||||
ref = getViewPart()->getEdgeRefByIndex(refIndex);
|
|
||||||
} else if (geomType.compare("Vertex") == 0) {
|
|
||||||
ref = getViewPart()->getVertexRefByIndex(refIndex);
|
|
||||||
}
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DrawViewDimension::dumpRefs(char* text) const
|
|
||||||
{
|
{
|
||||||
Base::Console().Message("DUMP - %s\n",text);
|
Base::Console().Message("DUMP - %s\n",text);
|
||||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
|
||||||
const std::vector<std::string> &subElements = References.getSubValues();
|
const std::vector<std::string> &subElements = References2D.getSubValues();
|
||||||
std::vector<App::DocumentObject*>::const_iterator objIt = objects.begin();
|
std::vector<App::DocumentObject*>::const_iterator objIt = objects.begin();
|
||||||
std::vector<std::string>::const_iterator subIt = subElements.begin();
|
std::vector<std::string>::const_iterator subIt = subElements.begin();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -493,9 +487,14 @@ double DrawViewDimension::dist2Segs(Base::Vector2D s1,
|
||||||
return minDist;
|
return minDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrawViewDimension::hasReferences(void) const
|
bool DrawViewDimension::has2DReferences(void) const
|
||||||
{
|
{
|
||||||
return (References.getSize() > 0);
|
return (References2D.getSize() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DrawViewDimension::has3DReferences(void) const
|
||||||
|
{
|
||||||
|
return (References3D.getSize() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *DrawViewDimension::getPyObject(void)
|
PyObject *DrawViewDimension::getPyObject(void)
|
||||||
|
|
|
@ -47,7 +47,8 @@ public:
|
||||||
|
|
||||||
App::PropertyEnumeration MeasureType; //True/Projected
|
App::PropertyEnumeration MeasureType; //True/Projected
|
||||||
App::PropertyVector ProjDirection; //??why would dim have different projDir from View?
|
App::PropertyVector ProjDirection; //??why would dim have different projDir from View?
|
||||||
App::PropertyLinkSubList References; //Points to Projection SubFeatures
|
App::PropertyLinkSubList References2D; //Points to Projection SubFeatures
|
||||||
|
App::PropertyLinkSubList References3D; //Points to 3D Geometry SubFeatures
|
||||||
App::PropertyEnumeration Type; //DistanceX,DistanceY,Diameter, etc
|
App::PropertyEnumeration Type; //DistanceX,DistanceY,Diameter, etc
|
||||||
App::PropertyVector XAxisDirection; //??always equal to View??
|
App::PropertyVector XAxisDirection; //??always equal to View??
|
||||||
|
|
||||||
|
@ -61,7 +62,8 @@ public:
|
||||||
//TODO: do we need a property for the actual dimension value? how else to access from Py?
|
//TODO: do we need a property for the actual dimension value? how else to access from Py?
|
||||||
|
|
||||||
short mustExecute() const;
|
short mustExecute() const;
|
||||||
bool hasReferences(void) const;
|
bool has2DReferences(void) const;
|
||||||
|
bool has3DReferences(void) const;
|
||||||
|
|
||||||
/** @name methods overide Feature */
|
/** @name methods overide Feature */
|
||||||
//@{
|
//@{
|
||||||
|
@ -79,17 +81,17 @@ public:
|
||||||
virtual std::string getFormatedValue() const;
|
virtual std::string getFormatedValue() const;
|
||||||
virtual double getDimValue() const;
|
virtual double getDimValue() const;
|
||||||
DrawViewPart* getViewPart() const;
|
DrawViewPart* getViewPart() const;
|
||||||
void setMeasurement(DocumentObject* obj, std::vector<std::string>& subElements) const;
|
|
||||||
void clearMeasurements(void);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onChanged(const App::Property* prop);
|
void onChanged(const App::Property* prop);
|
||||||
|
virtual void onDocumentRestored();
|
||||||
int getIndexFromName(std::string geomName) const;
|
int getIndexFromName(std::string geomName) const;
|
||||||
int getRefType() const; //Vertex-Vertex, Edge, Edge-Edge
|
int getRefType() const; //Vertex-Vertex, Edge, Edge-Edge
|
||||||
int get3DRef(int refIndex, std::string geomType) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Measure::Measurement *measurement;
|
Measure::Measurement *measurement;
|
||||||
|
void set3DMeasurement(DocumentObject* const &obj, const std::vector<std::string>& subElements);
|
||||||
|
void clear3DMeasurements(void);
|
||||||
double dist2Segs(Base::Vector2D s1,
|
double dist2Segs(Base::Vector2D s1,
|
||||||
Base::Vector2D e1,
|
Base::Vector2D e1,
|
||||||
Base::Vector2D s2,
|
Base::Vector2D s2,
|
||||||
|
@ -97,7 +99,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
static const char* TypeEnums[];
|
static const char* TypeEnums[];
|
||||||
static const char* MeasureTypeEnums[];
|
static const char* MeasureTypeEnums[];
|
||||||
void dumpRefs(char* text) const;
|
void dumpRefs2D(char* text) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace TechDraw
|
} //namespace TechDraw
|
||||||
|
|
|
@ -186,7 +186,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
||||||
,contentStr.c_str());
|
,contentStr.c_str());
|
||||||
|
|
||||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(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());
|
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());
|
doCommand(Doc, "App.activeDocument().%s.FormatSpec = 'r%%value%%'", FeatName.c_str());
|
||||||
|
|
||||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(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());
|
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
|
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 = 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());
|
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()
|
doCommand(Doc,"App.activeDocument().%s.Type = '%s'", FeatName.c_str()
|
||||||
, "Distance");
|
, "Distance");
|
||||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(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.FormatSpec = '%%value%%'", FeatName.c_str());
|
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
||||||
,"DistanceX");
|
,"DistanceX");
|
||||||
|
|
||||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(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.FormatSpec = '%%value%%'", FeatName.c_str());
|
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()
|
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
|
||||||
,"DistanceY");
|
,"DistanceY");
|
||||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(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.FormatSpec = '%%value%%'", FeatName.c_str());
|
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
|
,"%value%\u00b0"); // \u00b0 is degree sign
|
||||||
|
|
||||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(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());
|
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||||
|
|
||||||
|
@ -782,17 +782,14 @@ void CmdTechDrawLinkDimension::activated(int iMsg)
|
||||||
|
|
||||||
if (!page || !obj3D) {
|
if (!page || !obj3D) {
|
||||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dialog to select the Dimension to link
|
// dialog to select the Dimension to link
|
||||||
Gui::Control().showDialog(new TaskDlgLinkDim(obj3D,subs,page));
|
Gui::Control().showDialog(new TaskDlgLinkDim(obj3D,subs,page));
|
||||||
|
|
||||||
//openCommand("Link Dimension");
|
page->getDocument()->recompute(); //still need to recompute in Gui. why?
|
||||||
//commitCommand();
|
|
||||||
page->getDocument()->recompute();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CmdTechDrawLinkDimension::isActive(void)
|
bool CmdTechDrawLinkDimension::isActive(void)
|
||||||
|
|
|
@ -250,7 +250,7 @@ void QGIViewDimension::updateView(bool update)
|
||||||
return;
|
return;
|
||||||
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension*>(getViewObject());
|
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);
|
QGIDatumLabel *dLabel = dynamic_cast<QGIDatumLabel *>(datumLabel);
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ void QGIViewDimension::draw()
|
||||||
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(getViewObject());
|
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(getViewObject());
|
||||||
if((!dim) || //nothing to draw, don't try
|
if((!dim) || //nothing to draw, don't try
|
||||||
(!dim->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) ||
|
(!dim->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) ||
|
||||||
(!dim->hasReferences()) ) {
|
(!dim->has2DReferences()) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,8 +351,8 @@ void QGIViewDimension::draw()
|
||||||
Base::Vector3d lblCenter(lbl->X(), lbl->Y(), 0);
|
Base::Vector3d lblCenter(lbl->X(), lbl->Y(), 0);
|
||||||
|
|
||||||
//we always draw based on Projected geometry.
|
//we always draw based on Projected geometry.
|
||||||
//const std::vector<App::DocumentObject*> &objects = dim->References.getValues();
|
//const std::vector<App::DocumentObject*> &objects = dim->References2D.getValues();
|
||||||
const std::vector<std::string> &SubNames = dim->References.getSubValues();
|
const std::vector<std::string> &SubNames = dim->References2D.getSubValues();
|
||||||
|
|
||||||
const char *dimType = dim->Type.getValueAsString();
|
const char *dimType = dim->Type.getValueAsString();
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ void QGIViewDimension::draw()
|
||||||
strcmp(dimType, "DistanceX") == 0 ||
|
strcmp(dimType, "DistanceX") == 0 ||
|
||||||
strcmp(dimType, "DistanceY") == 0) {
|
strcmp(dimType, "DistanceY") == 0) {
|
||||||
Base::Vector3d distStart, distEnd;
|
Base::Vector3d distStart, distEnd;
|
||||||
if((dim->References.getValues().size() == 1) &&
|
if((dim->References2D.getValues().size() == 1) &&
|
||||||
(DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge")) {
|
(DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge")) {
|
||||||
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
||||||
TechDrawGeometry::BaseGeom* geom = refObj->getProjEdgeByIndex(idx);
|
TechDrawGeometry::BaseGeom* geom = refObj->getProjEdgeByIndex(idx);
|
||||||
|
@ -378,7 +378,7 @@ void QGIViewDimension::draw()
|
||||||
} else {
|
} else {
|
||||||
throw Base::Exception("FVD::draw - Original edge not found or is invalid type (1)");
|
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[0]) == "Vertex" &&
|
||||||
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex") {
|
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex") {
|
||||||
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
||||||
|
@ -393,7 +393,7 @@ void QGIViewDimension::draw()
|
||||||
}
|
}
|
||||||
distStart = Base::Vector3d (v0->pnt.fX, v0->pnt.fY, 0.);
|
distStart = Base::Vector3d (v0->pnt.fX, v0->pnt.fY, 0.);
|
||||||
distEnd = Base::Vector3d (v1->pnt.fX, v1->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[0]) == "Edge" &&
|
||||||
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||||
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
||||||
|
@ -599,7 +599,7 @@ void QGIViewDimension::draw()
|
||||||
Base::Vector3d lblCenter(label->X(), label->Y(), 0);
|
Base::Vector3d lblCenter(label->X(), label->Y(), 0);
|
||||||
double radius;
|
double radius;
|
||||||
|
|
||||||
if(dim->References.getValues().size() == 1 &&
|
if(dim->References2D.getValues().size() == 1 &&
|
||||||
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") {
|
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") {
|
||||||
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
||||||
TechDrawGeometry::BaseGeom *geom = refObj->getProjEdgeByIndex(idx);
|
TechDrawGeometry::BaseGeom *geom = refObj->getProjEdgeByIndex(idx);
|
||||||
|
@ -864,7 +864,7 @@ void QGIViewDimension::draw()
|
||||||
|
|
||||||
Base::Vector3d pointOnCurve,curveCenter;
|
Base::Vector3d pointOnCurve,curveCenter;
|
||||||
double radius;
|
double radius;
|
||||||
if(dim->References.getValues().size() == 1 &&
|
if(dim->References2D.getValues().size() == 1 &&
|
||||||
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") {
|
DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") {
|
||||||
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
int idx = DrawUtil::getIndexFromName(SubNames[0]);
|
||||||
TechDrawGeometry::BaseGeom* geom = refObj->getProjEdgeByIndex(idx);
|
TechDrawGeometry::BaseGeom* geom = refObj->getProjEdgeByIndex(idx);
|
||||||
|
@ -974,7 +974,7 @@ void QGIViewDimension::draw()
|
||||||
|
|
||||||
} else if(strcmp(dimType, "Angle") == 0) {
|
} else if(strcmp(dimType, "Angle") == 0) {
|
||||||
// Only use two straight line edeges for angle
|
// 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[0]) == "Edge" &&
|
||||||
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||||
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
int idx0 = DrawUtil::getIndexFromName(SubNames[0]);
|
||||||
|
|
|
@ -312,10 +312,10 @@ QGIView * QGVPage::findParent(QGIView *view) const
|
||||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(myView);
|
dim = dynamic_cast<TechDraw::DrawViewDimension *>(myView);
|
||||||
|
|
||||||
if(dim) {
|
if(dim) {
|
||||||
std::vector<App::DocumentObject *> objs = dim->References.getValues();
|
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();
|
||||||
|
|
||||||
if(objs.size() > 0) {
|
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
|
// Attach the dimension to the first object's group
|
||||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||||
TechDraw::DrawView *viewObj = (*it)->getViewObject();
|
TechDraw::DrawView *viewObj = (*it)->getViewObject();
|
||||||
|
|
|
@ -94,7 +94,7 @@ void TaskLinkDim::loadAvailDims()
|
||||||
for (; itView != pageViews.end(); itView++) {
|
for (; itView != pageViews.end(); itView++) {
|
||||||
if ((*itView)->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
if ((*itView)->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
||||||
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>((*itView));
|
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 label = QString::fromUtf8((*itView)->Label.getValue());
|
||||||
QString name = QString::fromUtf8((*itView)->getNameInDocument());
|
QString name = QString::fromUtf8((*itView)->getNameInDocument());
|
||||||
QString tooltip = label + QString::fromUtf8(" / ") + name;
|
QString tooltip = label + QString::fromUtf8(" / ") + name;
|
||||||
|
@ -117,13 +117,17 @@ void TaskLinkDim::updateDims()
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i=0; i<count; i++) {
|
for (int iDim=0; iDim<count; iDim++) {
|
||||||
QTreeWidgetItem* child = ui->selector->selectedTreeWidget()->topLevelItem(i);
|
QTreeWidgetItem* child = ui->selector->selectedTreeWidget()->topLevelItem(iDim);
|
||||||
QString name = child->data(0, Qt::UserRole).toString();
|
QString name = child->data(0, Qt::UserRole).toString();
|
||||||
App::DocumentObject* obj = m_page->getDocument()->getObject(name.toStdString().c_str());
|
App::DocumentObject* obj = m_page->getDocument()->getObject(name.toStdString().c_str());
|
||||||
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>(obj);
|
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>(obj);
|
||||||
dim->clearMeasurements();
|
std::vector<App::DocumentObject*> parts;
|
||||||
dim->setMeasurement(m_part,m_subs);
|
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");
|
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) {
|
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||||
if((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
if((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
||||||
TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(*it);
|
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) {
|
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?
|
if(strcmp(getViewPart()->getNameInDocument(), (*it)->getNameInDocument()) == 0) { //wf: isn't this test redundant?
|
||||||
temp.push_back(dim); // if a dim is in the inlist,
|
temp.push_back(dim); // if a dim is in the inlist,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user