Commit b849d95d authored by Ken Martin's avatar Ken Martin

update text representation to also support flagpoles

add vtkFlagpoleLabel as a possible rep for text sources
uses the same vtkTable input but with a different actor

Added test to verify it works
parent 8a2a58b5
9657eaa5476c3a34607b084261476e8663017413985af75565bced426a210467bed6be0a6c1f4e09e3e7ce90bf492d71766867f39aceb600b86204cf224d1645
......@@ -702,6 +702,7 @@ list(APPEND TESTS_WITH_BASELINES
FeatureEdges.xml
FFTOverTime.xml
FieldDataBlocks.xml
Flagpole.xml
Flow.xml
Flow2.xml
FollowHiddenData.xml
......
This diff is collapsed.
......@@ -19,6 +19,7 @@
#include "vtkAbstractWidget.h"
#include "vtkAlgorithmOutput.h"
#include "vtkDataSetAttributes.h"
#include "vtkFlagpoleLabel.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
......@@ -26,6 +27,7 @@
#include "vtkPVRenderView.h"
#include "vtkPointSource.h"
#include "vtkPolyData.h"
#include "vtkRenderer.h"
#include "vtkTable.h"
#include "vtkTextRepresentation.h"
#include "vtkVariant.h"
......@@ -48,10 +50,15 @@ std::string vtkExtractString(vtkDataObject* data)
vtkStandardNewMacro(vtkTextSourceRepresentation);
vtkCxxSetObjectMacro(
vtkTextSourceRepresentation, TextWidgetRepresentation, vtk3DWidgetRepresentation);
vtkCxxSetObjectMacro(vtkTextSourceRepresentation, FlagpoleLabel, vtkFlagpoleLabel);
//----------------------------------------------------------------------------
vtkTextSourceRepresentation::vtkTextSourceRepresentation()
{
this->TextWidgetRepresentation = 0;
this->TextPropMode = 0;
this->TextWidgetRepresentation = nullptr;
// this->FlagpoleLabel = vtkFlagpoleLabel::New();
this->FlagpoleLabel = nullptr;
this->CacheKeeper = vtkPVCacheKeeper::New();
......@@ -68,7 +75,8 @@ vtkTextSourceRepresentation::vtkTextSourceRepresentation()
//----------------------------------------------------------------------------
vtkTextSourceRepresentation::~vtkTextSourceRepresentation()
{
this->SetTextWidgetRepresentation(0);
this->SetFlagpoleLabel(nullptr);
this->SetTextWidgetRepresentation(nullptr);
this->DummyPolyData->Delete();
this->CacheKeeper->Delete();
}
......@@ -82,6 +90,11 @@ void vtkTextSourceRepresentation::SetVisibility(bool val)
this->TextWidgetRepresentation->GetRepresentation()->SetVisibility(val);
this->TextWidgetRepresentation->SetEnabled(val);
}
if (this->FlagpoleLabel && this->TextPropMode == 1)
{
this->FlagpoleLabel->SetVisibility(val);
}
}
//----------------------------------------------------------------------------
......@@ -104,10 +117,19 @@ int vtkTextSourceRepresentation::FillInputPortInformation(int, vtkInformation* i
//----------------------------------------------------------------------------
bool vtkTextSourceRepresentation::AddToView(vtkView* view)
{
if (this->TextWidgetRepresentation)
if (this->TextWidgetRepresentation /*&& this->TextPropMode == 0*/)
{
view->AddRepresentation(this->TextWidgetRepresentation);
}
if (this->FlagpoleLabel /*&& this->TextPropMode == 1*/)
{
vtkPVRenderView* pvview = vtkPVRenderView::SafeDownCast(view);
if (pvview)
{
vtkRenderer* activeRenderer = pvview->GetRenderer();
activeRenderer->AddActor(this->FlagpoleLabel);
}
}
return this->Superclass::AddToView(view);
}
......@@ -118,6 +140,15 @@ bool vtkTextSourceRepresentation::RemoveFromView(vtkView* view)
{
view->RemoveRepresentation(this->TextWidgetRepresentation);
}
if (this->FlagpoleLabel)
{
vtkPVRenderView* pvview = vtkPVRenderView::SafeDownCast(view);
if (pvview)
{
vtkRenderer* activeRenderer = pvview->GetRenderer();
activeRenderer->RemoveActor(this->FlagpoleLabel);
}
}
return this->Superclass::RemoveFromView(view);
}
......@@ -190,18 +221,36 @@ int vtkTextSourceRepresentation::ProcessViewRequest(
std::string text =
vtkExtractString(producerPort->GetProducer()->GetOutputDataObject(producerPort->GetIndex()));
vtkTextRepresentation* repr = vtkTextRepresentation::SafeDownCast(
this->TextWidgetRepresentation ? this->TextWidgetRepresentation->GetRepresentation() : NULL);
vtkTextRepresentation* repr = vtkTextRepresentation::SafeDownCast(this->TextWidgetRepresentation
? this->TextWidgetRepresentation->GetRepresentation()
: nullptr);
if (repr)
{
repr->SetText(text.c_str());
repr->SetVisibility(text.empty() ? 0 : 1);
repr->SetVisibility(text.empty() ? 0 : this->TextPropMode == 0);
}
if (this->FlagpoleLabel)
{
this->FlagpoleLabel->SetInput(text.c_str());
this->FlagpoleLabel->SetVisibility(text.empty() ? 0 : this->TextPropMode == 1);
}
}
return 1;
}
//----------------------------------------------------------------------------
void vtkTextSourceRepresentation::SetTextPropMode(int val)
{
if (this->TextPropMode == val)
{
return;
}
this->TextPropMode = val;
this->Modified();
}
//----------------------------------------------------------------------------
void vtkTextSourceRepresentation::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -28,6 +28,7 @@
#include "vtkPVDataRepresentation.h"
class vtk3DWidgetRepresentation;
class vtkFlagpoleLabel;
class vtkPolyData;
class vtkPVCacheKeeper;
......@@ -59,6 +60,21 @@ public:
*/
void SetInteractivity(bool);
/**
* Control how the text is rendered. Possible values include
* 0: render as a 3DWidgetRepresentation
* 1: Render as a FlagpoleLabel
*/
void SetTextPropMode(int);
//@{
/**
* Set the FlagpoleLabel
*/
void SetFlagpoleLabel(vtkFlagpoleLabel* val);
vtkGetObjectMacro(FlagpoleLabel, vtkFlagpoleLabel);
//@}
/**
* vtkAlgorithm::ProcessRequest() equivalent for rendering passes. This is
* typically called by the vtkView to request meta-data from the
......@@ -104,6 +120,8 @@ protected:
vtkPVCacheKeeper* CacheKeeper;
vtkPolyData* DummyPolyData;
vtk3DWidgetRepresentation* TextWidgetRepresentation;
vtkFlagpoleLabel* FlagpoleLabel;
int TextPropMode;
private:
vtkTextSourceRepresentation(const vtkTextSourceRepresentation&) = delete;
......
......@@ -1288,6 +1288,67 @@
</SubProxy>
</Proxy>
<Proxy class="vtkFlagpoleLabel"
name="FlagpoleLabel"
processes="client|dataserver|renderserver"
>
<Documentation>FlagpoleLabel is a 3D representation for a text
source.</Documentation>
<DoubleVectorProperty name="BasePosition"
command="SetBasePosition"
number_of_elements="3"
default_values="0.0 0.0 0.0"
>
<DoubleRangeDomain name="range" />
<Documentation>
The world coordinate position of the base of the flagpole.
</Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty name="TopPosition"
command="SetTopPosition"
number_of_elements="3"
default_values="0.0 1.0 0.0"
>
<DoubleRangeDomain name="range" />
<Documentation>
The world coordinate position of the top of the flagpole.
</Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty name="FlagSize"
command="SetFlagSize"
number_of_elements="1"
default_values="1.0"
>
<DoubleRangeDomain min="0.001" name="range" />
<Documentation>
The size of the flag. 1.0 is the default size which corresponds to
a preset texels/window value. Adjust this to increase or decrease
the default size.The world coordinate position of the top of the
flagpole.
</Documentation>
</DoubleVectorProperty>
<SubProxy command="SetTextProperty">
<Proxy name="TextProperty"
proxygroup="properties"
proxyname="TextProperty"></Proxy>
<ExposedProperties>
<Property name="Color"/>
<Property name="Opacity"/>
<Property name="FontFamily"/>
<Property name="FontFile"/>
<Property name="Bold"/>
<Property name="Italic"/>
<Property name="Shadow"/>
<Property name="FontSize"/>
<Property name="Justification"/>
</ExposedProperties>
</SubProxy>
<!-- End of FlagpoleLabel -->
</Proxy>
<!-- ================================================================== -->
<Proxy name="GridAxes3DActor"
class="vtkPVGridAxes3DActor"
......
......@@ -8149,6 +8149,20 @@
<DataType value="vtkTable" />
</DataTypeDomain>
</InputProperty>
<IntVectorProperty command="SetTextPropMode"
default_values="0"
name="TextPropMode"
number_of_elements="1">
<EnumerationDomain name="enum">
<Entry text="2D Text Widget" value="0" />
<Entry text="Flagpole Actor" value="1" />
</EnumerationDomain>
<Documentation>
Select how you want the text to be represented in the view.
</Documentation>
</IntVectorProperty>
<IntVectorProperty command="SetVisibility"
default_values="1"
name="Visibility"
......@@ -8190,7 +8204,14 @@
<Documentation>
Set whether user should be able to interactively place the text in the view.
</Documentation>
<Hints>
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="TextPropMode"
value="0" />
</Hints>
</IntVectorProperty>
<SubProxy command="SetTextWidgetRepresentation">
<Proxy name="TextWidgetRepresentation"
proxygroup="representations"
......@@ -8216,11 +8237,47 @@
<Property name="Position2" panel_visibility="never"/>
<Property name="PositionInfo" />
<Property name="Position2Info" />
<Hints>
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="TextPropMode"
value="0" />
</Hints>
</PropertyGroup>
<Property name="TextScaleMode" panel_visibility="never"/>
<Property name="Resizable" panel_visibility="never"/>
</ExposedProperties>
</SubProxy>
<SubProxy command="SetFlagpoleLabel">
<Proxy name="FlagpoleLabel"
proxygroup="annotations"
proxyname="FlagpoleLabel"></Proxy>
<ShareProperties subproxy="TextWidgetRepresentation">
<Exception name="Orientation" />
<Exception name="WindowLocation" />
<Exception name="Position" />
<Exception name="Position2" />
<Exception name="PositionInfo" />
<Exception name="Position2Info" />
<Exception name="TextScaleMode" />
<Exception name="Resizable" />
</ShareProperties>
<ExposedProperties>
<!-- properties for Text -->
<PropertyGroup label="Flagpole Properties">
<Property name="BasePosition" />
<Property name="TopPosition" />
<Property name="FlagSize" />
<Hints>
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="TextPropMode"
value="1" />
</Hints>
</PropertyGroup>
</ExposedProperties>
</SubProxy>
<!-- End of TextSourceRepresentation -->
</RepresentationProxy>
<!-- =================================================================== -->
......
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