...
 
Commits (3)
......@@ -287,7 +287,7 @@ smtk::attribute::ItemPtr GroupItem::find(std::size_t element, const std::string&
static_cast<const GroupItemDefinition*>(this->definition().get());
int i = def->findItemPosition(inName);
assert(m_items.size() > element);
assert(m_items[element].size() > static_cast<std::size_t>(i));
assert(i < 0 || m_items[element].size() > static_cast<std::size_t>(i));
return (i < 0) ? smtk::attribute::ItemPtr() : m_items[element][static_cast<std::size_t>(i)];
}
......
......@@ -1816,6 +1816,50 @@
</PropertyGroup>
</Proxy>
<!-- Axis-aligned box widget -->
<Proxy class="vtkPVBox" name="AABBox">
<InputProperty is_internal="1" name="Input" />
<DoubleVectorProperty
command="SetBounds"
default_values="0 1 0 1 0 1"
name="Bounds"
number_of_elements="6">
</DoubleVectorProperty>
<DoubleVectorProperty
animateable="1"
command="SetPosition"
default_values="0.0 0.0 0.0"
name="Position"
number_of_elements="3">
<DoubleRangeDomain name="range" />
<Documentation>
Set the position of the box.
</Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
animateable="1"
command="SetScale"
default_values="1.0 1.0 1.0"
name="Scale"
number_of_elements="3">
<DoubleRangeDomain name="range" />
<Documentation>
Set the size of the box via a scale factor.
</Documentation>
</DoubleVectorProperty>
<PropertyGroup label="Box Parameters" panel_widget="InteractiveBox">
<Property function="Position" name="Position" />
<Property function="Scale" name="Scale" />
<Property function="PlaceWidget" name="Bounds" />
<Property function="Input" name="Input" />
</PropertyGroup>
<Hints>
<ProxyList>
<Link name="Input" with_property="Input" />
</ProxyList>
</Hints>
</Proxy>
</ProxyGroup>
<ProxyGroup name="settings">
......
......@@ -58,7 +58,22 @@ bool pqSMTKBoxItemWidget::createProxyAndWidget(
pqServer* server = paraViewApp->getActiveServer();
pqObjectBuilder* builder = paraViewApp->getObjectBuilder();
proxy = builder->createProxy("implicit_functions", "Box", server, "");
ItemBindings binding;
std::vector<smtk::attribute::DoubleItemPtr> items;
bool haveRotation = false;
if (this->fetchBoxItems(binding, items))
{
haveRotation =
binding >= ItemBindings::EulerAngleMinMax &&
binding <= ItemBindings::EulerAngleCenterDeltas;
}
// The pqBoxPropertyWidget widget class from ParaView looks at the proxy's
// properties to decice what functionality to present. So, create a different
// proxy depending on whether rotation should be enabled or not:
proxy = haveRotation ?
builder->createProxy("implicit_functions", "Box", server, "") :
builder->createProxy("smtk_widgets", "AABBox", server, "");
if (!proxy)
{
return false;
......@@ -69,17 +84,19 @@ bool pqSMTKBoxItemWidget::createProxyAndWidget(
// For now, since we want to map this to a vector of 6 doubles,
// we do not allow rotation:
auto widgetProxy = widget->widgetProxy();
auto valueItem = this->itemAs<smtk::attribute::DoubleItem>();
double lo[3];
double hi[3];
double th[3];
// FIXME! Determine bounds properly from scene if requested by m_itemInfo.
// For now, just initialize the box using the item's values if they are
// non-default (or the item has no default).
if (valueItem && valueItem->numberOfValues() == 6)
switch (binding)
{
if (!valueItem->hasDefault() || !valueItem->isUsingDefault())
case ItemBindings::AxisAlignedBounds:
// if (!items[0]->hasDefault() || !items[0]->isUsingDefault())
{
double lo[3];
double hi[3];
auto valIt = valueItem->begin();
auto valIt = items[0]->begin();
for (int ii = 0; ii < 3; ++ii)
{
lo[ii] = *valIt;
......@@ -87,11 +104,77 @@ bool pqSMTKBoxItemWidget::createProxyAndWidget(
hi[ii] = *valIt;
++valIt;
}
vtkSMPropertyHelper(widgetProxy, "Position").Set(lo, 3);
vtkSMPropertyHelper(widgetProxy, "Scale").Set(hi, 3);
}
break;
case ItemBindings::AxisAlignedMinMax:
case ItemBindings::EulerAngleMinMax:
{
auto minIt = items[0]->begin();
auto maxIt = items[1]->begin();
for (int ii = 0; ii < 3; ++ii)
{
lo[ii] = *minIt;
++minIt;
hi[ii] = *maxIt;
++maxIt;
}
}
break;
case ItemBindings::AxisAlignedCenterDeltas:
case ItemBindings::EulerAngleCenterDeltas:
{
auto ctrIt = items[0]->begin();
auto dltIt = items[1]->begin();
for (int ii = 0; ii < 3; ++ii)
{
lo[ii] = *ctrIt - *dltIt;
hi[ii] = *ctrIt + *dltIt;
++ctrIt;
++dltIt;
}
}
break;
case ItemBindings::Invalid:
default:
lo[0] = lo[1] = lo[2] = 0.0;
hi[0] = hi[1] = hi[2] = 1.0;
break;
}
// If we have euler angles, fetch them
switch (binding)
{
case ItemBindings::EulerAngleMinMax:
case ItemBindings::EulerAngleCenterDeltas:
{
auto angIt = items[2]->begin();
for (int ii = 0; ii < 3; ++ii)
{
th[ii] = *angIt;
++angIt;
}
}
break;
case ItemBindings::AxisAlignedBounds:
case ItemBindings::AxisAlignedMinMax:
case ItemBindings::AxisAlignedCenterDeltas:
default:
th[0] = th[1] = th[2] = 0.0;
break;
}
if (binding != ItemBindings::Invalid)
{
vtkSMPropertyHelper(widgetProxy, "Position").Set(lo, 3);
vtkSMPropertyHelper(widgetProxy, "Scale").Set(hi, 3);
vtkSMPropertyHelper(widgetProxy, "RotationEnabled").Set(haveRotation);
if (haveRotation)
{
vtkSMPropertyHelper(widgetProxy, "Rotation").Set(th, 3);
}
}
vtkSMPropertyHelper(widgetProxy, "RotationEnabled").Set(false);
widgetProxy->UpdateVTKObjects();
return widget != nullptr;
......@@ -199,21 +282,21 @@ bool pqSMTKBoxItemWidget::fetchBoxItems(ItemBindings& binding, std::vector<smtk:
{
minItemName = "Min";
}
if (!m_itemInfo.component().attribute("Max", minItemName))
if (!m_itemInfo.component().attribute("Max", maxItemName))
{
minItemName = "Max";
maxItemName = "Max";
}
if (!m_itemInfo.component().attribute("Center", minItemName))
if (!m_itemInfo.component().attribute("Center", ctrItemName))
{
minItemName = "Center";
ctrItemName = "Center";
}
if (!m_itemInfo.component().attribute("Deltas", minItemName))
if (!m_itemInfo.component().attribute("Deltas", dltItemName))
{
minItemName = "Deltas";
dltItemName = "Deltas";
}
if (!m_itemInfo.component().attribute("Angles", minItemName))
if (!m_itemInfo.component().attribute("Angles", angItemName))
{
minItemName = "Angles";
angItemName = "Angles";
}
auto minItem = groupItem->findAs<smtk::attribute::DoubleItem>(minItemName);
auto maxItem = groupItem->findAs<smtk::attribute::DoubleItem>(maxItemName);
......