Commit b7fb11b9 authored by David Thompson's avatar David Thompson
Browse files

Initial annotation support.

Change-Id: I5eedc146d160a6e791cb13ecb7a56e18aaab7bb9
parent 9a8f17c7
......@@ -26,6 +26,8 @@ set(_vtk_modules
# time dependency on
vtkRenderingVolume
vtkRenderingLabel
vtkRenderingMathText
vtkRenderingMatplotlib
vtkRenderingFreeType
vtkRenderingFreeTypeOpenGL
vtkRenderingVolumeOpenGL
......
......@@ -23,6 +23,7 @@ vtk_module(vtkPVVTKExtensionsRendering
vtkIOExport
vtkPVVTKExtensionsCore
vtkRenderingAnnotation
vtkRenderingMathText
vtkRenderingMatplotlib
vtkRenderingFreeTypeOpenGL
vtkRenderingOpenGL
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>635</width>
<height>655</height>
<width>625</width>
<height>627</height>
</rect>
</property>
<property name="windowTitle">
......@@ -55,7 +55,7 @@
<item>
<widget class="QTabWidget" name="ColorTabs">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="ScalePage">
<attribute name="title">
......@@ -432,43 +432,6 @@
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QHBoxLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="SaveButton">
<property name="whatsThis">
<string>Click this button to save the current color map as a preset.</string>
</property>
<property name="text">
<string>&amp;Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="PresetButton">
<property name="whatsThis">
<string>Click this button to change the color map to a preset.</string>
</property>
<property name="text">
<string>Choose &amp;Preset</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="EnableOpacityFunction">
<property name="text">
......@@ -796,7 +759,7 @@
</sizepolicy>
</property>
<property name="title">
<string>Labels</string>
<string>Annotations and Tick Marks</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
......@@ -967,14 +930,14 @@
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="AutomaticLabelFormat">
<property name="text">
<string>Automatic Label Format</string>
<string>Automatic Tick Mark Format</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLabel" name="LabelFormatLabel">
<property name="text">
<string>Label Format</string>
<string>Tick Format</string>
</property>
</widget>
</item>
......@@ -993,7 +956,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Max Number of Labels</string>
<string>Max Number of Ticks</string>
</property>
</widget>
</item>
......@@ -1076,16 +1039,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="UseAutoRescaleSimple">
<property name="text">
<string>Automatic Color Scaling</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -1096,24 +1049,14 @@
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="PresetButtonSimple">
<widget class="QCheckBox" name="UseAutoRescaleSimple">
<property name="text">
<string>Choose Preset</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<string>Automatic Color Scaling</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="checked">
<bool>true</bool>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
......@@ -1199,6 +1142,39 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="PresetButton">
<property name="whatsThis">
<string>Click this button to change the color map to a preset.</string>
</property>
<property name="text">
<string>Choose &amp;Preset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="SaveButton">
<property name="whatsThis">
<string>Click this button to save the current color map as a preset.</string>
</property>
<property name="text">
<string>&amp;Save</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonApply">
<property name="text">
......@@ -1244,8 +1220,6 @@
<tabstop>CategoricalValues</tabstop>
<tabstop>ColorTabs</tabstop>
<tabstop>checkBoxImmediateRender</tabstop>
<tabstop>SaveButton</tabstop>
<tabstop>PresetButton</tabstop>
<tabstop>pushButtonScalarColor</tabstop>
<tabstop>ScalarValue</tabstop>
<tabstop>ScalarColor</tabstop>
......@@ -1264,10 +1238,8 @@
<tabstop>TableSize</tabstop>
<tabstop>TableSizeText</tabstop>
<tabstop>UseLogScaleSimple</tabstop>
<tabstop>UseAutoRescaleSimple</tabstop>
<tabstop>SimpleMin</tabstop>
<tabstop>SimpleMax</tabstop>
<tabstop>PresetButtonSimple</tabstop>
<tabstop>SwitchToAdvanced</tabstop>
<tabstop>pushButtonApply</tabstop>
<tabstop>MakeDefaultButton</tabstop>
......
......@@ -66,7 +66,24 @@ public:
};
class pqColorMapModelInternal : public QList<pqColorMapModelItem *> {};
class pqColorMapModelInternalPts : public QList<pqColorMapModelItem*> {};
//=============================================================================
class pqColorMapModelNote
{
public:
pqColorMapModelNote() { }
pqColorMapModelNote( const QString& value, const QString& note )
: Value( value ), Note( note ) { }
~pqColorMapModelNote() { }
QString Value;
QString Note;
};
class pqColorMapModelInternalTxt : public QList<pqColorMapModelNote*>
{
};
//=============================================================================
......@@ -132,7 +149,8 @@ pqColorMapModelItem::pqColorMapModelItem(const pqChartValue &value,
pqColorMapModel::pqColorMapModel(QObject *parentObject)
: QObject(parentObject)
{
this->Internal = new pqColorMapModelInternal();
this->InternalPts = new pqColorMapModelInternalPts();
this->InternalTxt = new pqColorMapModelInternalTxt();
this->Space = pqColorMapModel::HsvSpace;
this->NanColor = QColor(127, 0, 0);
this->IndexedLookup = false;
......@@ -142,18 +160,26 @@ pqColorMapModel::pqColorMapModel(QObject *parentObject)
pqColorMapModel::pqColorMapModel(const pqColorMapModel &other)
: QObject(0)
{
this->Internal = new pqColorMapModelInternal();
this->InternalPts = new pqColorMapModelInternalPts();
this->InternalTxt = new pqColorMapModelInternalTxt();
this->Space = other.Space;
this->NanColor = other.NanColor;
this->IndexedLookup = false;
this->InModify = false;
// Copy the list of points.
QList<pqColorMapModelItem *>::ConstIterator iter = other.Internal->begin();
for( ; iter != other.Internal->end(); ++iter)
QList<pqColorMapModelItem *>::ConstIterator pit = other.InternalPts->begin();
for( ; pit != other.InternalPts->end(); ++pit)
{
this->Internal->append(new pqColorMapModelItem(
(*iter)->Value, (*iter)->Color, (*iter)->Opacity));
this->InternalPts->append(new pqColorMapModelItem(
(*pit)->Value, (*pit)->Color, (*pit)->Opacity));
}
// Copy the list of annotations.
QList<pqColorMapModelNote *>::ConstIterator nit = other.InternalTxt->begin();
for ( ; nit != other.InternalTxt->end(); ++ nit )
{
this->InternalTxt->append( new pqColorMapModelNote( (*nit)->Value, (*nit)->Note ) );
}
}
......@@ -161,7 +187,9 @@ pqColorMapModel::~pqColorMapModel()
{
this->InModify = true;
this->removeAllPoints();
delete this->Internal;
delete this->InternalPts;
this->removeAllAnnotations();
delete this->InternalTxt;
}
void pqColorMapModel::setColorSpace(pqColorMapModel::ColorSpace space)
......@@ -228,7 +256,7 @@ void pqColorMapModel::setColorSpaceFromInt(int space)
int pqColorMapModel::getNumberOfPoints() const
{
return this->Internal->size();
return this->InternalPts->size();
}
void pqColorMapModel::addPoint(const pqChartValue &value, const QColor &color)
......@@ -241,8 +269,8 @@ void pqColorMapModel::addPoint(const pqChartValue &value, const QColor &color,
{
// The list of points should be in ascending value order. Add the
// new point according to its value.
QList<pqColorMapModelItem *>::Iterator iter = this->Internal->begin();
for( ; iter != this->Internal->end(); ++iter)
QList<pqColorMapModelItem *>::Iterator iter = this->InternalPts->begin();
for( ; iter != this->InternalPts->end(); ++iter)
{
if(value == (*iter)->Value)
{
......@@ -255,33 +283,33 @@ void pqColorMapModel::addPoint(const pqChartValue &value, const QColor &color,
}
pqColorMapModelItem *item = new pqColorMapModelItem(value, color, opacity);
if(iter == this->Internal->end())
if(iter == this->InternalPts->end())
{
// Add the point to the end of the list if it is greater than all
// the current points.
this->Internal->append(item);
this->InternalPts->append(item);
}
else
{
this->Internal->insert(iter, item);
this->InternalPts->insert(iter, item);
}
if(!this->InModify)
{
emit this->pointAdded(this->Internal->indexOf(item));
emit this->pointAdded(this->InternalPts->indexOf(item));
}
}
void pqColorMapModel::removePoint(int index)
{
if(index >= 0 && index < this->Internal->size())
if(index >= 0 && index < this->InternalPts->size())
{
if(!this->InModify)
{
emit this->removingPoint(index);
}
pqColorMapModelItem *item = this->Internal->takeAt(index);
pqColorMapModelItem *item = this->InternalPts->takeAt(index);
delete item;
if(!this->InModify)
{
......@@ -292,15 +320,15 @@ void pqColorMapModel::removePoint(int index)
void pqColorMapModel::removeAllPoints()
{
if(this->Internal->size() > 0)
if(this->InternalPts->size() > 0)
{
QList<pqColorMapModelItem *>::Iterator iter = this->Internal->begin();
for( ; iter != this->Internal->end(); ++ iter)
QList<pqColorMapModelItem *>::Iterator iter = this->InternalPts->begin();
for( ; iter != this->InternalPts->end(); ++ iter)
{
delete (*iter);
}
this->Internal->clear();
this->InternalPts->clear();
if(!this->InModify)
{
emit this->pointsReset();
......@@ -324,18 +352,18 @@ void pqColorMapModel::finishModifyingData()
void pqColorMapModel::getPointValue(int index, pqChartValue &value) const
{
if(index >= 0 && index < this->Internal->size())
if(index >= 0 && index < this->InternalPts->size())
{
value = (*this->Internal)[index]->Value;
value = (*this->InternalPts)[index]->Value;
}
}
void pqColorMapModel::setPointValue(int index, const pqChartValue &value)
{
if(index >= 0 && index < this->Internal->size() &&
(*this->Internal)[index]->Value != value)
if(index >= 0 && index < this->InternalPts->size() &&
(*this->InternalPts)[index]->Value != value)
{
(*this->Internal)[index]->Value = value;
(*this->InternalPts)[index]->Value = value;
if(!this->InModify)
{
emit this->valueChanged(index, value);
......@@ -345,18 +373,18 @@ void pqColorMapModel::setPointValue(int index, const pqChartValue &value)
void pqColorMapModel::getPointColor(int index, QColor &color) const
{
if(index >= 0 && index < this->Internal->size())
if(index >= 0 && index < this->InternalPts->size())
{
color = (*this->Internal)[index]->Color;
color = (*this->InternalPts)[index]->Color;
}
}
void pqColorMapModel::setPointColor(int index, const QColor &color)
{
if(index >= 0 && index < this->Internal->size() &&
(*this->Internal)[index]->Color != color)
if(index >= 0 && index < this->InternalPts->size() &&
(*this->InternalPts)[index]->Color != color)
{
(*this->Internal)[index]->Color = color;
(*this->InternalPts)[index]->Color = color;
if(!this->InModify)
{
emit this->colorChanged(index, color);
......@@ -366,18 +394,18 @@ void pqColorMapModel::setPointColor(int index, const QColor &color)
void pqColorMapModel::getPointOpacity(int index, pqChartValue &opacity) const
{
if(index >= 0 && index < this->Internal->size())
if(index >= 0 && index < this->InternalPts->size())
{
opacity = (*this->Internal)[index]->Opacity;
opacity = (*this->InternalPts)[index]->Opacity;
}
}
void pqColorMapModel::setPointOpacity(int index, const pqChartValue &opacity)
{
if(index >= 0 && index < this->Internal->size() &&
(*this->Internal)[index]->Opacity != opacity)
if(index >= 0 && index < this->InternalPts->size() &&
(*this->InternalPts)[index]->Opacity != opacity)
{
(*this->Internal)[index]->Opacity = opacity;
(*this->InternalPts)[index]->Opacity = opacity;
if(!this->InModify)
{
emit this->opacityChanged(index, opacity);
......@@ -387,10 +415,10 @@ void pqColorMapModel::setPointOpacity(int index, const pqChartValue &opacity)
bool pqColorMapModel::isRangeNormalized() const
{
if(this->Internal->size() > 1)
if(this->InternalPts->size() > 1)
{
return this->Internal->first()->Value == (float)0.0 &&
this->Internal->last()->Value == (float)1.0;
return this->InternalPts->first()->Value == (float)0.0 &&
this->InternalPts->last()->Value == (float)1.0;
}
return false;
......@@ -398,10 +426,10 @@ bool pqColorMapModel::isRangeNormalized() const
void pqColorMapModel::getValueRange(pqChartValue &min, pqChartValue &max) const
{
if(this->Internal->size() > 0)
if(this->InternalPts->size() > 0)
{
min = this->Internal->first()->Value;
max = this->Internal->last()->Value;
min = this->InternalPts->first()->Value;
max = this->InternalPts->last()->Value;
}
}
......@@ -439,24 +467,136 @@ void pqColorMapModel::setIndexedLookup( bool indexedLookup )
}
}
int pqColorMapModel::getNumberOfAnnotations() const
{
return this->InternalTxt->size();
}
QString pqColorMapModel::getAnnotatedValue( int index ) const
{
QString retval;
if ( index < 0 || index > this->InternalTxt->size() )
return retval;
retval = this->InternalTxt->at( index )->Value;
return retval;
}
QString pqColorMapModel::getAnnotation( int index ) const
{
QString retval;
if ( index < 0 || index > this->InternalTxt->size() )
return retval;
retval = this->InternalTxt->at( index )->Note;
return retval;
}
QList<QVariant> pqColorMapModel::getAnnotations() const
{
QList<QVariant> annotations;
for ( pqColorMapModelInternalTxt::const_iterator it = this->InternalTxt->begin(); it != this->InternalTxt->end(); ++ it )
{
annotations << QVariant( (*it)->Value ) << QVariant( (*it)->Note );
}
return annotations;
}
int pqColorMapModel::addAnnotation( const QString& value, const QString& note )
{
return this->insertAnnotation( this->getNumberOfAnnotations(), value, note );
}
int pqColorMapModel::insertAnnotation( int index, const QString& value, const QString& text )
{
QList<pqColorMapModelNote*>::iterator it;
int actualIndex;
pqColorMapModelNote* note = 0;
for ( actualIndex = 0, it = this->InternalTxt->begin(); it != this->InternalTxt->end(); ++ actualIndex, ++ it )
{
if ( (*it)->Value == value )
{
break;
}
}
if ( index < 0 || index > actualIndex )
{
index = actualIndex;
}
if ( ! note )
{
note = new pqColorMapModelNote( value, text );
this->InternalTxt->insert( it, note );
if ( ! this->InModify )
{
emit annotationAdded( actualIndex );
}
}
else
{
note->Note = text;
if ( ! this->InModify )
{
emit this->annotationChanged( actualIndex, text );
}
}
return actualIndex;
}
void pqColorMapModel::removeAnnotation( int index )
{
if ( index >= 0 && index < this->InternalTxt->size() )
{
if ( ! this->InModify )
{
emit this->removingAnnotation( index );
}
pqColorMapModelNote* note = this->InternalTxt->takeAt( index );
delete note;
if ( ! this->InModify )
{
emit this->annotationRemoved( index );
}
}
}
void pqColorMapModel::removeAllAnnotations()
{
if ( this->InternalTxt->size() > 0 )
{
QList<pqColorMapModelNote*>::iterator it = this->InternalTxt->begin();
for ( ; it != this->InternalTxt->end(); ++ it )
{
delete (*it);
}
this->InternalTxt->clear();
if ( ! this->InModify )
{
emit this->annotationsReset();
}
}
}
void pqColorMapModel::setValueRange(const pqChartValue &min,
const pqChartValue &max)
{
if(this->Internal->size() == 0)
if(this->InternalPts->size() == 0)
{
return;
}
// Scale the current points to fit the given range.
if(this->Internal->size() == 1)
if(this->InternalPts->size() == 1)
{
this->Internal->first()->Value = min;
this->InternalPts->first()->Value = min;
}
else
{
pqChartValue newMin, newRange;