Commit 9a25f5d8 authored by pugmire's avatar pugmire

add Inverse option.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21736 18c085ea-50e0-402c-830e-de6fd14e8384
parent 5c4c26c7
<?xml version="1.0"?>
<Plugin name="Box" type="operator" label="Box" version="1.0" iconFile="Box.xpm" category="Selection">
<Attribute name="BoxAttributes" purpose="This class contains attributes for the box operator." persistent="true" codefile="BoxAttributes.code">
<Plugin name="Box" type="operator" label="Box" version="1.0" enabled="true" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" iconFile="Box.xpm" category="Selection">
<Attribute name="BoxAttributes" purpose="This class contains attributes for the box operator." persistent="true" keyframe="true" exportAPI="" exportInclude="" codefile="BoxAttributes.code">
<Enum name="Amount">
Some
All
......@@ -26,6 +26,9 @@
<Field name="maxz" label="Z-Maximum" 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">
......
......@@ -101,6 +101,7 @@ void BoxAttributes::Init()
maxy = 1;
minz = 0;
maxz = 1;
inverse = false;
BoxAttributes::SelectAll();
}
......@@ -129,6 +130,7 @@ void BoxAttributes::Copy(const BoxAttributes &obj)
maxy = obj.maxy;
minz = obj.minz;
maxz = obj.maxz;
inverse = obj.inverse;
BoxAttributes::SelectAll();
}
......@@ -292,7 +294,8 @@ BoxAttributes::operator == (const BoxAttributes &obj) const
(miny == obj.miny) &&
(maxy == obj.maxy) &&
(minz == obj.minz) &&
(maxz == obj.maxz));
(maxz == obj.maxz) &&
(inverse == obj.inverse));
}
// ****************************************************************************
......@@ -471,13 +474,14 @@ BoxAttributes::NewInstance(bool copy) const
void
BoxAttributes::SelectAll()
{
Select(ID_amount, (void *)&amount);
Select(ID_minx, (void *)&minx);
Select(ID_maxx, (void *)&maxx);
Select(ID_miny, (void *)&miny);
Select(ID_maxy, (void *)&maxy);
Select(ID_minz, (void *)&minz);
Select(ID_maxz, (void *)&maxz);
Select(ID_amount, (void *)&amount);
Select(ID_minx, (void *)&minx);
Select(ID_maxx, (void *)&maxx);
Select(ID_miny, (void *)&miny);
Select(ID_maxy, (void *)&maxy);
Select(ID_minz, (void *)&minz);
Select(ID_maxz, (void *)&maxz);
Select(ID_inverse, (void *)&inverse);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -552,6 +556,12 @@ BoxAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd
node->AddNode(new DataNode("maxz", maxz));
}
if(completeSave || !FieldsEqual(ID_inverse, &defaultObject))
{
addToParent = true;
node->AddNode(new DataNode("inverse", inverse));
}
// Add the node to the parent node.
if(addToParent || forceAdd)
......@@ -616,6 +626,8 @@ BoxAttributes::SetFromNode(DataNode *parentNode)
SetMinz(node->AsDouble());
if((node = searchNode->GetNode("maxz")) != 0)
SetMaxz(node->AsDouble());
if((node = searchNode->GetNode("inverse")) != 0)
SetInverse(node->AsBool());
}
///////////////////////////////////////////////////////////////////////////////
......@@ -671,6 +683,13 @@ BoxAttributes::SetMaxz(double maxz_)
Select(ID_maxz, (void *)&maxz);
}
void
BoxAttributes::SetInverse(bool inverse_)
{
inverse = inverse_;
Select(ID_inverse, (void *)&inverse);
}
///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////
......@@ -717,6 +736,12 @@ BoxAttributes::GetMaxz() const
return maxz;
}
bool
BoxAttributes::GetInverse() const
{
return inverse;
}
///////////////////////////////////////////////////////////////////////////////
// Keyframing methods
///////////////////////////////////////////////////////////////////////////////
......@@ -741,13 +766,14 @@ BoxAttributes::GetFieldName(int index) const
{
switch (index)
{
case ID_amount: return "amount";
case ID_minx: return "minx";
case ID_maxx: return "maxx";
case ID_miny: return "miny";
case ID_maxy: return "maxy";
case ID_minz: return "minz";
case ID_maxz: return "maxz";
case ID_amount: return "amount";
case ID_minx: return "minx";
case ID_maxx: return "maxx";
case ID_miny: return "miny";
case ID_maxy: return "maxy";
case ID_minz: return "minz";
case ID_maxz: return "maxz";
case ID_inverse: return "inverse";
default: return "invalid index";
}
}
......@@ -772,13 +798,14 @@ BoxAttributes::GetFieldType(int index) const
{
switch (index)
{
case ID_amount: return FieldType_enum;
case ID_minx: return FieldType_double;
case ID_maxx: return FieldType_double;
case ID_miny: return FieldType_double;
case ID_maxy: return FieldType_double;
case ID_minz: return FieldType_double;
case ID_maxz: return FieldType_double;
case ID_amount: return FieldType_enum;
case ID_minx: return FieldType_double;
case ID_maxx: return FieldType_double;
case ID_miny: return FieldType_double;
case ID_maxy: return FieldType_double;
case ID_minz: return FieldType_double;
case ID_maxz: return FieldType_double;
case ID_inverse: return FieldType_bool;
default: return FieldType_unknown;
}
}
......@@ -803,13 +830,14 @@ BoxAttributes::GetFieldTypeName(int index) const
{
switch (index)
{
case ID_amount: return "enum";
case ID_minx: return "double";
case ID_maxx: return "double";
case ID_miny: return "double";
case ID_maxy: return "double";
case ID_minz: return "double";
case ID_maxz: return "double";
case ID_amount: return "enum";
case ID_minx: return "double";
case ID_maxx: return "double";
case ID_miny: return "double";
case ID_maxy: return "double";
case ID_minz: return "double";
case ID_maxz: return "double";
case ID_inverse: return "bool";
default: return "invalid index";
}
}
......@@ -871,6 +899,11 @@ BoxAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
retval = (maxz == obj.maxz);
}
break;
case ID_inverse:
{ // new scope
retval = (inverse == obj.inverse);
}
break;
default: retval = false;
}
......
......@@ -92,3 +92,4 @@ BoxAttributes::CreateCompatible(const std::string &tname) const
return retval;
}
......@@ -100,6 +100,7 @@ public:
void SetMaxy(double maxy_);
void SetMinz(double minz_);
void SetMaxz(double maxz_);
void SetInverse(bool inverse_);
// Property getting methods
Amount GetAmount() const;
......@@ -109,6 +110,7 @@ public:
double GetMaxy() const;
double GetMinz() const;
double GetMaxz() const;
bool GetInverse() const;
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -137,6 +139,7 @@ public:
ID_maxy,
ID_minz,
ID_maxz,
ID_inverse,
ID__LAST
};
......@@ -148,11 +151,12 @@ private:
double maxy;
double minz;
double maxz;
bool inverse;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define BOXATTRIBUTES_TMFS "idddddd"
#define BOXATTRIBUTES_TMFS "iddddddb"
#endif
......@@ -59,7 +59,7 @@ import llnl.visit.Plugin;
public class BoxAttributes extends AttributeSubject implements Plugin
{
private static int BoxAttributes_numAdditionalAtts = 7;
private static int BoxAttributes_numAdditionalAtts = 8;
// Enum values
public final static int AMOUNT_SOME = 0;
......@@ -77,6 +77,7 @@ public class BoxAttributes extends AttributeSubject implements Plugin
maxy = 1;
minz = 0;
maxz = 1;
inverse = false;
}
public BoxAttributes(int nMoreFields)
......@@ -90,6 +91,7 @@ public class BoxAttributes extends AttributeSubject implements Plugin
maxy = 1;
minz = 0;
maxz = 1;
inverse = false;
}
public BoxAttributes(BoxAttributes obj)
......@@ -103,6 +105,7 @@ public class BoxAttributes extends AttributeSubject implements Plugin
maxy = obj.maxy;
minz = obj.minz;
maxz = obj.maxz;
inverse = obj.inverse;
SelectAll();
}
......@@ -126,7 +129,8 @@ public class BoxAttributes extends AttributeSubject implements Plugin
(miny == obj.miny) &&
(maxy == obj.maxy) &&
(minz == obj.minz) &&
(maxz == obj.maxz));
(maxz == obj.maxz) &&
(inverse == obj.inverse));
}
public String GetName() { return "Box"; }
......@@ -175,14 +179,21 @@ public class BoxAttributes extends AttributeSubject implements Plugin
Select(6);
}
public void SetInverse(boolean inverse_)
{
inverse = inverse_;
Select(7);
}
// Property getting methods
public int GetAmount() { return amount; }
public double GetMinx() { return minx; }
public double GetMaxx() { return maxx; }
public double GetMiny() { return miny; }
public double GetMaxy() { return maxy; }
public double GetMinz() { return minz; }
public double GetMaxz() { return maxz; }
public int GetAmount() { return amount; }
public double GetMinx() { return minx; }
public double GetMaxx() { return maxx; }
public double GetMiny() { return miny; }
public double GetMaxy() { return maxy; }
public double GetMinz() { return minz; }
public double GetMaxz() { return maxz; }
public boolean GetInverse() { return inverse; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
......@@ -201,6 +212,8 @@ public class BoxAttributes extends AttributeSubject implements Plugin
buf.WriteDouble(minz);
if(WriteSelect(6, buf))
buf.WriteDouble(maxz);
if(WriteSelect(7, buf))
buf.WriteBool(inverse);
}
public void ReadAtts(int index, CommunicationBuffer buf)
......@@ -228,6 +241,9 @@ public class BoxAttributes extends AttributeSubject implements Plugin
case 6:
SetMaxz(buf.ReadDouble());
break;
case 7:
SetInverse(buf.ReadBool());
break;
}
}
......@@ -246,17 +262,19 @@ public class BoxAttributes extends AttributeSubject implements Plugin
str = str + doubleToString("maxy", maxy, indent) + "\n";
str = str + doubleToString("minz", minz, indent) + "\n";
str = str + doubleToString("maxz", maxz, indent) + "\n";
str = str + boolToString("inverse", inverse, indent) + "\n";
return str;
}
// Attributes
private int amount;
private double minx;
private double maxx;
private double miny;
private double maxy;
private double minz;
private double maxz;
private int amount;
private double minx;
private double maxx;
private double miny;
private double maxy;
private double minz;
private double maxz;
private boolean inverse;
}
......@@ -103,6 +103,11 @@ PyBoxAttributes_ToString(const BoxAttributes *atts, const char *prefix)
str += tmpStr;
SNPRINTF(tmpStr, 1000, "%smaxz = %g\n", prefix, atts->GetMaxz());
str += tmpStr;
if(atts->GetInverse())
SNPRINTF(tmpStr, 1000, "%sinverse = 1\n", prefix);
else
SNPRINTF(tmpStr, 1000, "%sinverse = 0\n", prefix);
str += tmpStr;
return str;
}
......@@ -292,6 +297,30 @@ BoxAttributes_GetMaxz(PyObject *self, PyObject *args)
return retval;
}
/*static*/ PyObject *
BoxAttributes_SetInverse(PyObject *self, PyObject *args)
{
BoxAttributesObject *obj = (BoxAttributesObject *)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 *
BoxAttributes_GetInverse(PyObject *self, PyObject *args)
{
BoxAttributesObject *obj = (BoxAttributesObject *)self;
PyObject *retval = PyInt_FromLong(obj->data->GetInverse()?1L:0L);
return retval;
}
PyMethodDef PyBoxAttributes_methods[BOXATTRIBUTES_NMETH] = {
......@@ -310,6 +339,8 @@ PyMethodDef PyBoxAttributes_methods[BOXATTRIBUTES_NMETH] = {
{"GetMinz", BoxAttributes_GetMinz, METH_VARARGS},
{"SetMaxz", BoxAttributes_SetMaxz, METH_VARARGS},
{"GetMaxz", BoxAttributes_GetMaxz, METH_VARARGS},
{"SetInverse", BoxAttributes_SetInverse, METH_VARARGS},
{"GetInverse", BoxAttributes_GetInverse, METH_VARARGS},
{NULL, NULL}
};
......@@ -357,6 +388,8 @@ PyBoxAttributes_getattr(PyObject *self, char *name)
return BoxAttributes_GetMinz(self, NULL);
if(strcmp(name, "maxz") == 0)
return BoxAttributes_GetMaxz(self, NULL);
if(strcmp(name, "inverse") == 0)
return BoxAttributes_GetInverse(self, NULL);
return Py_FindMethod(PyBoxAttributes_methods, self, name);
}
......@@ -385,6 +418,8 @@ PyBoxAttributes_setattr(PyObject *self, char *name, PyObject *args)
obj = BoxAttributes_SetMinz(self, tuple);
else if(strcmp(name, "maxz") == 0)
obj = BoxAttributes_SetMaxz(self, tuple);
else if(strcmp(name, "inverse") == 0)
obj = BoxAttributes_SetInverse(self, tuple);
if(obj != NULL)
Py_DECREF(obj);
......
......@@ -44,7 +44,7 @@
//
// Functions exposed to the VisIt module.
//
#define BOXATTRIBUTES_NMETH 16
#define BOXATTRIBUTES_NMETH 18
void PyBoxAttributes_StartUp(BoxAttributes *subj, void *data);
void PyBoxAttributes_CloseDown();
PyMethodDef * PyBoxAttributes_GetMethodTable(int *nMethods);
......
......@@ -186,6 +186,11 @@ QvisBoxWindow::CreateWindowContents()
this, SLOT(maxzProcessText()));
mainLayout->addWidget(maxz, 6,1);
inverse = new QCheckBox(tr("Inverse"), central);
connect(inverse, SIGNAL(toggled(bool)),
this, SLOT(inverseChanged(bool)));
mainLayout->addWidget(inverse, 7,0);
}
......@@ -244,6 +249,11 @@ QvisBoxWindow::UpdateWindow(bool doAll)
case BoxAttributes::ID_maxz:
maxz->setText(DoubleToQString(atts->GetMaxz()));
break;
case BoxAttributes::ID_inverse:
inverse->blockSignals(true);
inverse->setChecked(atts->GetInverse());
inverse->blockSignals(false);
break;
}
}
}
......@@ -421,3 +431,12 @@ QvisBoxWindow::maxzProcessText()
}
void
QvisBoxWindow::inverseChanged(bool val)
{
atts->SetInverse(val);
SetUpdate(false);
Apply();
}
......@@ -93,6 +93,7 @@ class QvisBoxWindow : public QvisOperatorWindow
void maxyProcessText();
void minzProcessText();
void maxzProcessText();
void inverseChanged(bool val);
private:
QWidget *amount;
QButtonGroup *amountButtonGroup;
......@@ -102,6 +103,7 @@ class QvisBoxWindow : public QvisOperatorWindow
QLineEdit *maxy;
QLineEdit *minz;
QLineEdit *maxz;
QCheckBox *inverse;
QLabel *amountLabel;
QLabel *minxLabel;
QLabel *maxxLabel;
......
......@@ -95,6 +95,10 @@ public:
vtkGetMacro(AllOfCell, int);
vtkBooleanMacro(AllOfCell, int);
vtkSetMacro(Inverse, bool)
vtkGetMacro(Inverse, bool)
vtkBooleanMacro(Inverse, bool)
protected:
vtkBoxFilter();
~vtkBoxFilter();
......@@ -109,6 +113,7 @@ protected:
float MinX, MaxX, MinY, MaxY, MinZ, MaxZ;
int AllOfCell;
bool Inverse;
};
......@@ -396,12 +401,11 @@ vtkBoxFilter::RequestData(
double t;
if (vtkBox::IntersectBox(bounds, pt1, ray, pt2, t)
&& t < 1)
&& t < 1)
{
meetsCriteria = true;
break;
}
}
}
......@@ -439,7 +443,7 @@ vtkBoxFilter::RequestData(
}
}
if (meetsCriteria)
if ((!GetInverse() && meetsCriteria) || (GetInverse() && !meetsCriteria))
{
//
// We must re-map the point ids from the input mesh to the
......@@ -626,6 +630,9 @@ avtBoxFilter::Equivalent(const AttributeGroup *a)
// Hank Childs, Sun Apr 24 11:11:46 PDT 2005
// Add special support for rectilinear grids.
//
// Dave Pugmire, Fri Aug 30 15:57:33 EDT 2013
// Add an inverse option for box clip.
//
// ****************************************************************************
vtkDataSet *
......@@ -643,7 +650,7 @@ avtBoxFilter::ExecuteData(vtkDataSet *in_ds, int, std::string)
}
vtkDataSet *outDS = NULL;
if (in_ds->GetDataObjectType() == VTK_RECTILINEAR_GRID)
if (!atts.GetInverse() && in_ds->GetDataObjectType() == VTK_RECTILINEAR_GRID)
{
int dims[3] = {0, 0, 0};
((vtkRectilinearGrid*)in_ds)->GetDimensions(dims);
......@@ -695,6 +702,7 @@ vtkUnstructuredGrid *
avtBoxFilter::GeneralExecute(vtkDataSet *in_ds)
{
vtkBoxFilter *bf = vtkBoxFilter::New();
bf->SetInverse(atts.GetInverse());
bf->SetInputData(in_ds);
//
......
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