Commit 989133e3 authored by pugmire's avatar pugmire

add Inverse option.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21737 18c085ea-50e0-402c-830e-de6fd14e8384
parent 9a25f5d8
<?xml version="1.0"?>
<Plugin name="Cylinder" type="operator" label="Cylinder" version="1.0" enabled="true" iconFile="Cylinder.xpm" category="Selection">
<Attribute name="CylinderAttributes" purpose="Contain the attributes for a cylinder" persistent="true" exportAPI="" exportInclude="" codefile="CylinderAttributes.code">
<Plugin name="Cylinder" type="operator" label="Cylinder" version="1.0" enabled="true" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" iconFile="Cylinder.xpm" category="Selection">
<Attribute name="CylinderAttributes" purpose="Contain the attributes for a cylinder" persistent="true" keyframe="true" exportAPI="" exportInclude="" codefile="CylinderAttributes.code">
<Field name="point1" label="Endpoint 1" type="doubleArray" length="3">
0.000000
0.000000
......@@ -14,6 +14,9 @@
<Field name="radius" label="Radius" type="double">
1.000000
</Field>
<Field name="inverse" label="Inverse" type="bool">
false
</Field>
<Function name="CopyAttributes" user="false" member="true">
</Function>
<Function name="CreateCompatible" user="false" member="true">
......
......@@ -63,6 +63,7 @@ void CylinderAttributes::Init()
point2[1] = 0;
point2[2] = 0;
radius = 1;
inverse = false;
CylinderAttributes::SelectAll();
}
......@@ -93,6 +94,7 @@ void CylinderAttributes::Copy(const CylinderAttributes &obj)
point2[2] = obj.point2[2];
radius = obj.radius;
inverse = obj.inverse;
CylinderAttributes::SelectAll();
}
......@@ -262,7 +264,8 @@ CylinderAttributes::operator == (const CylinderAttributes &obj) const
// Create the return value
return (point1_equal &&
point2_equal &&
(radius == obj.radius));
(radius == obj.radius) &&
(inverse == obj.inverse));
}
// ****************************************************************************
......@@ -396,9 +399,10 @@ CylinderAttributes::NewInstance(bool copy) const
void
CylinderAttributes::SelectAll()
{
Select(ID_point1, (void *)point1, 3);
Select(ID_point2, (void *)point2, 3);
Select(ID_radius, (void *)&radius);
Select(ID_point1, (void *)point1, 3);
Select(ID_point2, (void *)point2, 3);
Select(ID_radius, (void *)&radius);
Select(ID_inverse, (void *)&inverse);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -449,6 +453,12 @@ CylinderAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool for
node->AddNode(new DataNode("radius", radius));
}
if(completeSave || !FieldsEqual(ID_inverse, &defaultObject))
{
addToParent = true;
node->AddNode(new DataNode("inverse", inverse));
}
// Add the node to the parent node.
if(addToParent || forceAdd)
......@@ -491,6 +501,8 @@ CylinderAttributes::SetFromNode(DataNode *parentNode)
SetPoint2(node->AsDoubleArray());
if((node = searchNode->GetNode("radius")) != 0)
SetRadius(node->AsDouble());
if((node = searchNode->GetNode("inverse")) != 0)
SetInverse(node->AsBool());
}
///////////////////////////////////////////////////////////////////////////////
......@@ -522,6 +534,13 @@ CylinderAttributes::SetRadius(double radius_)
Select(ID_radius, (void *)&radius);
}
void
CylinderAttributes::SetInverse(bool inverse_)
{
inverse = inverse_;
Select(ID_inverse, (void *)&inverse);
}
///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////
......@@ -556,6 +575,12 @@ CylinderAttributes::GetRadius() const
return radius;
}
bool
CylinderAttributes::GetInverse() const
{
return inverse;
}
///////////////////////////////////////////////////////////////////////////////
// Select property methods
///////////////////////////////////////////////////////////////////////////////
......@@ -596,9 +621,10 @@ CylinderAttributes::GetFieldName(int index) const
{
switch (index)
{
case ID_point1: return "point1";
case ID_point2: return "point2";
case ID_radius: return "radius";
case ID_point1: return "point1";
case ID_point2: return "point2";
case ID_radius: return "radius";
case ID_inverse: return "inverse";
default: return "invalid index";
}
}
......@@ -623,9 +649,10 @@ CylinderAttributes::GetFieldType(int index) const
{
switch (index)
{
case ID_point1: return FieldType_doubleArray;
case ID_point2: return FieldType_doubleArray;
case ID_radius: return FieldType_double;
case ID_point1: return FieldType_doubleArray;
case ID_point2: return FieldType_doubleArray;
case ID_radius: return FieldType_double;
case ID_inverse: return FieldType_bool;
default: return FieldType_unknown;
}
}
......@@ -650,9 +677,10 @@ CylinderAttributes::GetFieldTypeName(int index) const
{
switch (index)
{
case ID_point1: return "doubleArray";
case ID_point2: return "doubleArray";
case ID_radius: return "double";
case ID_point1: return "doubleArray";
case ID_point2: return "doubleArray";
case ID_radius: return "double";
case ID_inverse: return "bool";
default: return "invalid index";
}
}
......@@ -704,6 +732,11 @@ CylinderAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
retval = (radius == obj.radius);
}
break;
case ID_inverse:
{ // new scope
retval = (inverse == obj.inverse);
}
break;
default: retval = false;
}
......
......@@ -92,6 +92,7 @@ public:
void SetPoint1(const double *point1_);
void SetPoint2(const double *point2_);
void SetRadius(double radius_);
void SetInverse(bool inverse_);
// Property getting methods
const double *GetPoint1() const;
......@@ -99,6 +100,7 @@ public:
const double *GetPoint2() const;
double *GetPoint2();
double GetRadius() const;
bool GetInverse() const;
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -117,6 +119,7 @@ public:
ID_point1 = 0,
ID_point2,
ID_radius,
ID_inverse,
ID__LAST
};
......@@ -124,11 +127,12 @@ private:
double point1[3];
double point2[3];
double radius;
bool inverse;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define CYLINDERATTRIBUTES_TMFS "DDd"
#define CYLINDERATTRIBUTES_TMFS "DDdb"
#endif
......@@ -59,7 +59,7 @@ import llnl.visit.Plugin;
public class CylinderAttributes extends AttributeSubject implements Plugin
{
private static int CylinderAttributes_numAdditionalAtts = 3;
private static int CylinderAttributes_numAdditionalAtts = 4;
public CylinderAttributes()
{
......@@ -74,6 +74,7 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
point2[1] = 0;
point2[2] = 0;
radius = 1;
inverse = false;
}
public CylinderAttributes(int nMoreFields)
......@@ -89,6 +90,7 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
point2[1] = 0;
point2[2] = 0;
radius = 1;
inverse = false;
}
public CylinderAttributes(CylinderAttributes obj)
......@@ -108,6 +110,7 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
point2[2] = obj.point2[2];
radius = obj.radius;
inverse = obj.inverse;
SelectAll();
}
......@@ -139,7 +142,8 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
// Create the return value
return (point1_equal &&
point2_equal &&
(radius == obj.radius));
(radius == obj.radius) &&
(inverse == obj.inverse));
}
public String GetName() { return "Cylinder"; }
......@@ -184,10 +188,17 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
Select(2);
}
public void SetInverse(boolean inverse_)
{
inverse = inverse_;
Select(3);
}
// Property getting methods
public double[] GetPoint1() { return point1; }
public double[] GetPoint2() { return point2; }
public double GetRadius() { return radius; }
public boolean GetInverse() { return inverse; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
......@@ -198,6 +209,8 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
buf.WriteDoubleArray(point2);
if(WriteSelect(2, buf))
buf.WriteDouble(radius);
if(WriteSelect(3, buf))
buf.WriteBool(inverse);
}
public void ReadAtts(int index, CommunicationBuffer buf)
......@@ -213,6 +226,9 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
case 2:
SetRadius(buf.ReadDouble());
break;
case 3:
SetInverse(buf.ReadBool());
break;
}
}
......@@ -222,6 +238,7 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
str = str + doubleArrayToString("point1", point1, indent) + "\n";
str = str + doubleArrayToString("point2", point2, indent) + "\n";
str = str + doubleToString("radius", radius, indent) + "\n";
str = str + boolToString("inverse", inverse, indent) + "\n";
return str;
}
......@@ -230,5 +247,6 @@ public class CylinderAttributes extends AttributeSubject implements Plugin
private double[] point1;
private double[] point2;
private double radius;
private boolean inverse;
}
......@@ -110,6 +110,11 @@ PyCylinderAttributes_ToString(const CylinderAttributes *atts, const char *prefix
}
SNPRINTF(tmpStr, 1000, "%sradius = %g\n", prefix, atts->GetRadius());
str += tmpStr;
if(atts->GetInverse())
SNPRINTF(tmpStr, 1000, "%sinverse = 1\n", prefix);
else
SNPRINTF(tmpStr, 1000, "%sinverse = 0\n", prefix);
str += tmpStr;
return str;
}
......@@ -254,6 +259,30 @@ CylinderAttributes_GetRadius(PyObject *self, PyObject *args)
return retval;
}
/*static*/ PyObject *
CylinderAttributes_SetInverse(PyObject *self, PyObject *args)
{
CylinderAttributesObject *obj = (CylinderAttributesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the inverse in the object.
obj->data->SetInverse(ival != 0);
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
CylinderAttributes_GetInverse(PyObject *self, PyObject *args)
{
CylinderAttributesObject *obj = (CylinderAttributesObject *)self;
PyObject *retval = PyInt_FromLong(obj->data->GetInverse()?1L:0L);
return retval;
}
PyMethodDef PyCylinderAttributes_methods[CYLINDERATTRIBUTES_NMETH] = {
......@@ -264,6 +293,8 @@ PyMethodDef PyCylinderAttributes_methods[CYLINDERATTRIBUTES_NMETH] = {
{"GetPoint2", CylinderAttributes_GetPoint2, METH_VARARGS},
{"SetRadius", CylinderAttributes_SetRadius, METH_VARARGS},
{"GetRadius", CylinderAttributes_GetRadius, METH_VARARGS},
{"SetInverse", CylinderAttributes_SetInverse, METH_VARARGS},
{"GetInverse", CylinderAttributes_GetInverse, METH_VARARGS},
{NULL, NULL}
};
......@@ -298,6 +329,8 @@ PyCylinderAttributes_getattr(PyObject *self, char *name)
return CylinderAttributes_GetPoint2(self, NULL);
if(strcmp(name, "radius") == 0)
return CylinderAttributes_GetRadius(self, NULL);
if(strcmp(name, "inverse") == 0)
return CylinderAttributes_GetInverse(self, NULL);
return Py_FindMethod(PyCylinderAttributes_methods, self, name);
}
......@@ -318,6 +351,8 @@ PyCylinderAttributes_setattr(PyObject *self, char *name, PyObject *args)
obj = CylinderAttributes_SetPoint2(self, tuple);
else if(strcmp(name, "radius") == 0)
obj = CylinderAttributes_SetRadius(self, tuple);
else if(strcmp(name, "inverse") == 0)
obj = CylinderAttributes_SetInverse(self, tuple);
if(obj != NULL)
Py_DECREF(obj);
......
......@@ -44,7 +44,7 @@
//
// Functions exposed to the VisIt module.
//
#define CYLINDERATTRIBUTES_NMETH 8
#define CYLINDERATTRIBUTES_NMETH 10
void PyCylinderAttributes_StartUp(CylinderAttributes *subj, void *data);
void PyCylinderAttributes_CloseDown();
PyMethodDef * PyCylinderAttributes_GetMethodTable(int *nMethods);
......
......@@ -148,6 +148,11 @@ QvisCylinderWindow::CreateWindowContents()
this, SLOT(radiusProcessText()));
mainLayout->addWidget(radius, 2,1);
inverse = new QCheckBox(tr("Inverse"), central);
connect(inverse, SIGNAL(toggled(bool)),
this, SLOT(inverseChanged(bool)));
mainLayout->addWidget(inverse, 3,0);
}
......@@ -191,6 +196,11 @@ QvisCylinderWindow::UpdateWindow(bool doAll)
case CylinderAttributes::ID_radius:
radius->setText(DoubleToQString(atts->GetRadius()));
break;
case CylinderAttributes::ID_inverse:
inverse->blockSignals(true);
inverse->setChecked(atts->GetInverse());
inverse->blockSignals(false);
break;
}
}
}
......@@ -290,3 +300,12 @@ QvisCylinderWindow::radiusProcessText()
}
void
QvisCylinderWindow::inverseChanged(bool val)
{
atts->SetInverse(val);
SetUpdate(false);
Apply();
}
......@@ -89,10 +89,12 @@ class QvisCylinderWindow : public QvisOperatorWindow
void point1ProcessText();
void point2ProcessText();
void radiusProcessText();
void inverseChanged(bool val);
private:
QLineEdit *point1;
QLineEdit *point2;
QLineEdit *radius;
QCheckBox *inverse;
QLabel *point1Label;
QLabel *point2Label;
QLabel *radiusLabel;
......
......@@ -236,13 +236,20 @@ avtCylinderFilter::Equivalent(const AttributeGroup *a)
// Brad Whitlock, Fri May 6 13:41:40 PDT 2011
// Do clipping instead of cutting so we can leave the dataset interior.
//
// Dave Pugmire, Fri Aug 30 14:43:48 EDT 2013
// Add Inverse clipping option.
//
// ****************************************************************************
vtkDataSet *
avtCylinderFilter::ExecuteData(vtkDataSet *in_ds, int, std::string)
{
vtkVisItClipper *clipper = vtkVisItClipper::New();
clipper->SetInsideOut(true);
if (atts.GetInverse())
clipper->SetInsideOut(false);
else
clipper->SetInsideOut(true);
clipper->SetClipFunction(cylinderSlice);
clipper->SetInputData(in_ds);
clipper->Update();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment