change Dimension.ProjectionType -> MeasureType
This commit is contained in:
parent
e4b5bba140
commit
88ad069817
|
@ -76,34 +76,34 @@ void Measurement::clear()
|
|||
{
|
||||
std::vector<App::DocumentObject*> Objects;
|
||||
std::vector<std::string> SubElements;
|
||||
References.setValues(Objects, SubElements);
|
||||
References3D.setValues(Objects, SubElements);
|
||||
measureType = Invalid;
|
||||
}
|
||||
|
||||
bool Measurement::hasReferences()
|
||||
{
|
||||
return (References.getSize() > 0);
|
||||
return (References3D.getSize() > 0);
|
||||
}
|
||||
|
||||
/// Convenience Methods for adding points
|
||||
int Measurement::addReference(App::DocumentObject *obj, const char* subName)
|
||||
int Measurement::addReference3D(App::DocumentObject *obj, const char* subName)
|
||||
{
|
||||
std::vector<App::DocumentObject*> objects = References.getValues();
|
||||
std::vector<std::string> subElements = References.getSubValues();
|
||||
std::vector<App::DocumentObject*> objects = References3D.getValues();
|
||||
std::vector<std::string> subElements = References3D.getSubValues();
|
||||
|
||||
objects.push_back(obj);
|
||||
subElements.push_back(subName);
|
||||
|
||||
References.setValues(objects, subElements);
|
||||
References3D.setValues(objects, subElements);
|
||||
|
||||
measureType = getType();
|
||||
return References.getSize();
|
||||
return References3D.getSize();
|
||||
}
|
||||
|
||||
MeasureType Measurement::getType()
|
||||
{
|
||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
const std::vector<App::DocumentObject*> &objects = References3D.getValues();
|
||||
const std::vector<std::string> &subElements = References3D.getSubValues();
|
||||
|
||||
std::vector<App::DocumentObject*>::const_iterator obj = objects.begin();
|
||||
std::vector<std::string>::const_iterator subEl = subElements.begin();
|
||||
|
@ -112,7 +112,7 @@ MeasureType Measurement::getType()
|
|||
//int dims = -1;
|
||||
MeasureType mode;
|
||||
|
||||
// Type of References
|
||||
// Type of References3D
|
||||
int verts = 0;
|
||||
int edges = 0;
|
||||
int faces = 0;
|
||||
|
@ -226,14 +226,14 @@ TopoDS_Shape Measurement::getShape(App::DocumentObject *obj , const char *subNam
|
|||
// Methods for distances (edge length, two points, edge and a point
|
||||
double Measurement::length() const
|
||||
{
|
||||
int numRefs = References.getSize();
|
||||
int numRefs = References3D.getSize();
|
||||
if(!numRefs || measureType == Invalid) {
|
||||
throw Base::Exception("Measurement - length - Invalid References Provided");
|
||||
throw Base::Exception("Measurement - length - Invalid References3D Provided");
|
||||
}
|
||||
|
||||
double result = 0.0;
|
||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
const std::vector<App::DocumentObject*> &objects = References3D.getValues();
|
||||
const std::vector<std::string> &subElements = References3D.getSubValues();
|
||||
|
||||
if(measureType == Points ||
|
||||
measureType == PointToEdge ||
|
||||
|
@ -293,15 +293,15 @@ double Measurement::length() const
|
|||
|
||||
double Measurement::angle(const Base::Vector3d ¶m) const
|
||||
{
|
||||
int numRefs = References.getSize();
|
||||
int numRefs = References3D.getSize();
|
||||
if(!numRefs)
|
||||
throw Base::Exception("Measurement - angle - No references provided");
|
||||
throw Base::Exception("Measurement - angle - No References3D provided");
|
||||
|
||||
if(measureType == Edges) {
|
||||
// Only case that is supported is edge to edge
|
||||
if(numRefs == 2) {
|
||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
const std::vector<App::DocumentObject*> &objects = References3D.getValues();
|
||||
const std::vector<std::string> &subElements = References3D.getSubValues();
|
||||
|
||||
TopoDS_Shape shape1 = getShape(objects.at(0), subElements.at(0).c_str());
|
||||
TopoDS_Shape shape2 = getShape(objects.at(1), subElements.at(1).c_str());
|
||||
|
@ -325,22 +325,22 @@ double Measurement::angle(const Base::Vector3d ¶m) const
|
|||
throw Base::Exception("Objects must both be lines");
|
||||
}
|
||||
} else {
|
||||
throw Base::Exception("Can not compute angle. Too many references");
|
||||
throw Base::Exception("Can not compute angle. Too many References3D");
|
||||
}
|
||||
}
|
||||
throw Base::Exception("References are not Edges");
|
||||
throw Base::Exception("References3D are not Edges");
|
||||
}
|
||||
|
||||
double Measurement::radius() const
|
||||
{
|
||||
int numRefs = References.getSize();
|
||||
int numRefs = References3D.getSize();
|
||||
if(!numRefs) {
|
||||
throw Base::Exception("Measurement - radius - No references provided");
|
||||
throw Base::Exception("Measurement - radius - No References3D provided");
|
||||
}
|
||||
|
||||
if(numRefs == 1 || measureType == Edges) {
|
||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
const std::vector<App::DocumentObject*> &objects = References3D.getValues();
|
||||
const std::vector<std::string> &subElements = References3D.getSubValues();
|
||||
|
||||
TopoDS_Shape shape = getShape(objects.at(0), subElements.at(0).c_str());
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(shape);
|
||||
|
@ -350,17 +350,17 @@ double Measurement::radius() const
|
|||
return (double) curve.Circle().Radius();
|
||||
}
|
||||
}
|
||||
throw Base::Exception("Measurement - radius - Invalid References Provided");
|
||||
throw Base::Exception("Measurement - radius - Invalid References3D Provided");
|
||||
}
|
||||
|
||||
Base::Vector3d Measurement::delta() const
|
||||
{
|
||||
int numRefs = References.getSize();
|
||||
int numRefs = References3D.getSize();
|
||||
if(!numRefs || measureType == Invalid)
|
||||
throw Base::Exception("Measurement - delta - Invalid References Provided");
|
||||
throw Base::Exception("Measurement - delta - Invalid References3D Provided");
|
||||
|
||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
const std::vector<App::DocumentObject*> &objects = References3D.getValues();
|
||||
const std::vector<std::string> &subElements = References3D.getSubValues();
|
||||
|
||||
if(measureType == Points) {
|
||||
if(numRefs == 2) {
|
||||
|
@ -437,12 +437,12 @@ Base::Vector3d Measurement::delta() const
|
|||
Base::Vector3d Measurement::massCenter() const
|
||||
{
|
||||
|
||||
int numRefs = References.getSize();
|
||||
int numRefs = References3D.getSize();
|
||||
if(!numRefs || measureType == Invalid)
|
||||
throw Base::Exception("Measurement - massCenter - Invalid References Provided");
|
||||
throw Base::Exception("Measurement - massCenter - Invalid References3D Provided");
|
||||
|
||||
const std::vector<App::DocumentObject*> &objects = References.getValues();
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
const std::vector<App::DocumentObject*> &objects = References3D.getValues();
|
||||
const std::vector<std::string> &subElements = References3D.getSubValues();
|
||||
|
||||
|
||||
GProp_GProps gprops = GProp_GProps();
|
||||
|
@ -470,7 +470,7 @@ Base::Vector3d Measurement::massCenter() const
|
|||
return Base::Vector3d(cog.X(), cog.Y(), cog.Z());
|
||||
|
||||
} else {
|
||||
throw Base::Exception("Measurement - massCenter - Invalid References Provided");
|
||||
throw Base::Exception("Measurement - massCenter - Invalid References3D Provided");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class MeasureExport Measurement : public Base::BaseClass {
|
|||
TYPESYSTEM_HEADER();
|
||||
public:
|
||||
|
||||
App::PropertyLinkSubList References;
|
||||
App::PropertyLinkSubList References3D;
|
||||
|
||||
public:
|
||||
Measurement();
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
bool hasReferences();
|
||||
|
||||
/// Add a reference
|
||||
int addReference(App::DocumentObject *obj, const char *subName);
|
||||
int addReference3D(App::DocumentObject *obj, const char *subName);
|
||||
|
||||
MeasureType getType();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<Author Licence="LGPL" Name="Luke Parry" EMail="l.parry@warwick.ac.uk" />
|
||||
<UserDocu>Make a measurement</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="addReference">
|
||||
<Methode Name="addReference3D">
|
||||
<Documentation>
|
||||
<UserDocu>add a geometric reference</UserDocu>
|
||||
</Documentation>
|
||||
|
|
|
@ -57,7 +57,7 @@ int MeasurementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
|||
return 0;
|
||||
}
|
||||
|
||||
PyObject* MeasurementPy::addReference(PyObject *args)
|
||||
PyObject* MeasurementPy::addReference3D(PyObject *args)
|
||||
{
|
||||
char *ObjectName;
|
||||
char *SubName;
|
||||
|
@ -74,7 +74,7 @@ PyObject* MeasurementPy::addReference(PyObject *args)
|
|||
}
|
||||
|
||||
// add the external
|
||||
if (this->getMeasurementPtr()->addReference(Obj,SubName) < 0) {
|
||||
if (this->getMeasurementPtr()->addReference3D(Obj,SubName) < 0) {
|
||||
std::stringstream str;
|
||||
str << "Not able to add reference";
|
||||
PyErr_SetString(PyExc_ValueError, str.str().c_str());
|
||||
|
@ -139,5 +139,3 @@ int MeasurementPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ const char* DrawViewDimension::TypeEnums[]= {"Distance",
|
|||
"Angle",
|
||||
NULL};
|
||||
|
||||
const char* DrawViewDimension::ProjTypeEnums[]= {"True",
|
||||
const char* DrawViewDimension::MeasureTypeEnums[]= {"True",
|
||||
"Projected",
|
||||
NULL};
|
||||
|
||||
|
@ -95,8 +95,8 @@ DrawViewDimension::DrawViewDimension(void)
|
|||
Type.setEnums(TypeEnums); //dimension type: length, radius etc
|
||||
ADD_PROPERTY(Type,((long)0));
|
||||
|
||||
ProjectionType.setEnums(ProjTypeEnums);
|
||||
ADD_PROPERTY(ProjectionType, ((long)0)); //True or Projected measurement
|
||||
MeasureType.setEnums(MeasureTypeEnums);
|
||||
ADD_PROPERTY(MeasureType, ((long)0)); //True or Projected measurement
|
||||
|
||||
//hide the DrawView properties that don't apply to Dimensions
|
||||
//App::PropertyType propType = static_cast<App::PropertyType>(App::Prop_Hidden|App::Prop_Output);
|
||||
|
@ -141,7 +141,7 @@ void DrawViewDimension::onChanged(const App::Property* prop)
|
|||
catch (...) {
|
||||
}
|
||||
}
|
||||
if (prop == &ProjectionType) {
|
||||
if (prop == &MeasureType) {
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
if (subElements.empty()) {
|
||||
Base::Console().Log("INFO - DrawViewDimension::onChanged - no References yet\n");
|
||||
|
@ -158,9 +158,9 @@ void DrawViewDimension::onChanged(const App::Property* prop)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (ProjectionType.isValue("True") && !trueAllowed) {
|
||||
if (MeasureType.isValue("True") && !trueAllowed) {
|
||||
Base::Console().Warning("Dimension %s missing Reference to 3D model. Must be Projected.\n", getNameInDocument());
|
||||
ProjectionType.setValue("Projected");
|
||||
MeasureType.setValue("Projected");
|
||||
}
|
||||
try {
|
||||
App::DocumentObjectExecReturn *ret = recompute();
|
||||
|
@ -178,7 +178,7 @@ short DrawViewDimension::mustExecute() const
|
|||
bool result = 0;
|
||||
if (References.isTouched() ||
|
||||
Type.isTouched() ||
|
||||
ProjectionType.isTouched()) {
|
||||
MeasureType.isTouched()) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
|
@ -195,7 +195,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
|||
//Clear the previous measurement made
|
||||
measurement->clear();
|
||||
|
||||
if (ProjectionType.isValue("True")) {
|
||||
if (MeasureType.isValue("True")) {
|
||||
//Update Dimension.measurement with 3D References
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
ProjDirection.setValue(getViewPart()->Direction.getValue());
|
||||
|
@ -213,11 +213,11 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
|||
if (ref < 0) {
|
||||
Base::Console().Log("INFO - FVD::execute - no 3D ref yet. Probably loading document.\n");
|
||||
} else {
|
||||
measurement->addReference(docObj,newName.c_str());
|
||||
measurement->addReference3D(docObj,newName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: if ProjectionType = Projected and the Projected shape changes, the Dimension may become invalid (see tilted Cube example)
|
||||
//TODO: if MeasureType = Projected and the Projected shape changes, the Dimension may become invalid (see tilted Cube example)
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ double DrawViewDimension::getDimValue() const
|
|||
return result;
|
||||
}
|
||||
|
||||
if (ProjectionType.isValue("True")) {
|
||||
if (MeasureType.isValue("True")) {
|
||||
// True Values
|
||||
if (!measurement->hasReferences()) {
|
||||
return result;
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
DrawViewDimension();
|
||||
virtual ~DrawViewDimension();
|
||||
|
||||
App::PropertyEnumeration ProjectionType; //True/Projected
|
||||
App::PropertyEnumeration MeasureType; //True/Projected
|
||||
App::PropertyVector ProjDirection; //??why would dim have different projDir from View?
|
||||
App::PropertyLinkSubList References; //Points to Projection SubFeatures
|
||||
App::PropertyEnumeration Type; //DistanceX,DistanceY,Diameter, etc
|
||||
|
@ -94,7 +94,7 @@ protected:
|
|||
Base::Vector2D e2) const;
|
||||
private:
|
||||
static const char* TypeEnums[];
|
||||
static const char* ProjTypeEnums[];
|
||||
static const char* MeasureTypeEnums[];
|
||||
void dumpRefs(char* text) const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user