9 #ifndef vtkXYChartRepresentationInternals_h 10 #define vtkXYChartRepresentationInternals_h 45 class PlotsMap :
public std::map<std::string, PlotsMapItem>
47 bool Contains(
const std::string&
key,
const std::string& role)
const 49 PlotsMap::const_iterator iter1 = this->find(key);
50 if (iter1 != this->end())
52 PlotsMapItem::const_iterator iter2 = iter1->second.find(role);
53 return (iter2 != iter1->second.end());
60 const std::string& columnName,
const std::string& role = std::string())
const 62 const std::string key =
self->GetDefaultSeriesLabel(tableName, columnName);
63 PlotsMap::const_iterator iter1 = this->find(key);
64 if (iter1 != this->end())
66 PlotsMapItem::const_iterator iter2 = iter1->second.find(role);
67 if (iter2 != iter1->second.end())
69 return iter2->second.Plot;
76 const std::string& columnName,
const std::string& role = std::string())
78 const std::string key =
self->GetDefaultSeriesLabel(tableName, columnName);
79 PlotsMap::iterator iter1 = this->find(key);
80 if (iter1 != this->end())
82 PlotsMapItem::iterator iter2 = iter1->second.find(role);
83 if (iter2 != iter1->second.end())
85 iter1->second.erase(iter2);
93 const std::string& columnName,
const std::string& role,
vtkPlot* plot)
95 const std::string key =
self->GetDefaultSeriesLabel(tableName, columnName);
104 for (PlotsMap::const_iterator iter1 = this->begin(); iter1 != this->end(); ++iter1)
106 for (PlotsMapItem::const_iterator iter2 = iter1->second.begin();
107 iter2 != iter1->second.end(); ++iter2)
109 iter2->second.Plot->SetVisible(val);
116 for (PlotsMap::const_iterator iter1 = this->begin(); iter1 != this->end(); ++iter1)
118 for (PlotsMapItem::const_iterator iter2 = iter1->second.begin();
119 iter2 != iter1->second.end(); ++iter2)
129 for (PlotsMap::iterator iter1 = this->begin(); iter1 != this->end(); ++iter1)
131 for (PlotsMapItem::iterator iter2 = iter1->second.begin(); iter2 != iter1->second.end();)
133 if (other.Contains(iter1->first, iter2->first) ==
false)
136 PlotsMapItem::iterator iter2old = iter2;
138 iter1->second.erase(iter2old);
162 const std::string& columnName,
const std::string& vtkNotUsed(role),
163 const std::map<std::string, T>& parameter_map,
const T default_value = T())
const 165 typename std::map<std::string, T>::const_iterator iter;
172 std::string key =
self->GetDefaultSeriesLabel(tableName, columnName);
173 iter = parameter_map.find(key);
174 if (iter != parameter_map.end())
180 key =
self->GetDefaultSeriesLabel(std::string(), columnName);
181 iter = parameter_map.find(key);
182 if (iter != parameter_map.end())
186 return default_value;
198 std::map<std::string, vtkColor3d>
Colors;
203 std::map<std::string, std::string>
Labels;
205 std::map<std::string, vtkScalarsToColors*>
Lut;
214 : PreviousUseIndexForXAxis(false)
239 const std::string& vtkNotUsed(tableName),
const std::string& vtkNotUsed(columnName))
241 return { std::string() };
249 const std::string& columnName,
const std::string& role,
unsigned int block = 0)
259 return chartXY->
AddPlot(self->GetChartType(), block);
264 const std::string& vtkNotUsed(columnName),
const std::string& vtkNotUsed(role))
276 assert(
self !=
nullptr);
279 std::multimap<int, std::pair<vtkTable*, TableInfo>> orderMap;
280 for (MapOfTables::const_iterator tablesIter = tables.begin(); tablesIter != tables.end();
283 const std::string& tableName = tablesIter->first;
284 vtkTable* table = tablesIter->second.first.GetPointer();
286 for (
vtkIdType cc = 0; cc < numCols; ++cc)
291 for (
const auto& role : roles)
302 info.
Block = tablesIter->second.second;
303 orderMap.insert(std::make_pair(order, std::make_pair(tablesIter->second.first, info)));
309 for (
auto it = orderMap.begin(); it != orderMap.end(); ++it)
335 this->SeriesPlots.
Intersect(newPlots, chartXY);
345 vtkPlot* lastFunctionalBagPlot =
nullptr;
346 for (PlotsMap::iterator iter1 = this->SeriesPlots.begin(); iter1 != this->SeriesPlots.end();
349 for (PlotsMapItem::const_iterator iter2 = iter1->second.begin(); iter2 != iter1->second.end();
352 const PlotInfo& plotInfo = iter2->second;
353 const std::string& tableName = plotInfo.
TableName;
354 const std::string& columnName = plotInfo.
ColumnName;
356 const std::string& role = iter2->first;
365 if (columnName ==
"QMedianLine")
369 if (plotBag->
IsBag())
371 if (!lastFunctionalBagPlot)
379 lastFunctionalBagPlot = plotBag;
393 for (PlotsMap::iterator iter1 = this->SeriesPlots.begin(); iter1 != this->SeriesPlots.end();
396 for (PlotsMapItem::const_iterator iter2 = iter1->second.begin(); iter2 != iter1->second.end();
399 const PlotInfo& plotInfo = iter2->second;
405 const std::string& columnName = plotInfo.
ColumnName;
411 if (yarray !=
nullptr)
413 const std::string plotName = plot->
GetLabel();
414 exporter->
AddColumn(yarray, plotName.c_str(), xarray);
415 exporter->
AddStyle(plot, plotName.c_str());
431 const std::string& tableName,
const std::string& columnName,
const std::string& role,
436 this->
GetSeriesParameter(
self, tableName, columnName, role, this->SeriesVisibilities,
false);
443 std::string default_label =
self->GetDefaultSeriesLabel(tableName, columnName);
445 this->
GetSeriesParameter(
self, tableName, columnName, role, this->Labels, default_label);
446 if (self->GetSeriesLabelPrefix())
448 label = std::string(self->GetSeriesLabelPrefix()) + label;
453 self, tableName, columnName, role, this->Colors,
vtkColor3d(0, 0, 0));
460 this->
GetSeriesParameter(
self, tableName, columnName, role, this->LineThicknesses, 2));
462 self, tableName, columnName, role, this->LineStyles, static_cast<int>(
vtkPen::SOLID_LINE)));
466 plotPoints->SetMarkerStyle(this->
GetSeriesParameter(
self, tableName, columnName, role,
468 plotPoints->SetMarkerSize(
473 plotPoints->SetValidPointMaskName(
"vtkValidPointMask");
477 plot, this->
GetSeriesParameter(
self, tableName, columnName, role, this->AxisCorners, 0));
481 if (plotBar && columnName ==
"bin_values")
484 this->
GetSeriesParameter(
self, tableName, columnName, role, this->UseColorMapping,
false);
488 self, tableName, columnName, role, this->Lut, static_cast<vtkScalarsToColors*>(
nullptr));
virtual void SetGlobalStyle(vtkChart *chart)=0
Set Global style elements like graph and axis titles.
std::map< std::string, vtkScalarsToColors * > Lut
virtual bool Export(vtkXYChartRepresentation *self, vtkAbstractChartExporter *exporter)
Export visible plots to a CSV file.
bool RemovePlot(vtkChartRepresentation *self, const std::string &tableName, const std::string &columnName, const std::string &role=std::string())
std::map< std::string, PlotInfo > PlotsMapItem
virtual ~vtkInternals()=default
bool PreviousUseIndexForXAxis
static vtkDataArray * SafeDownCast(vtkObjectBase *o)
T GetSeriesParameter(vtkXYChartRepresentation *self, const std::string &tableName, const std::string &columnName, const std::string &vtkNotUsed(role), const std::map< std::string, T > ¶meter_map, const T default_value=T()) const
Makes is easy to obtain a value for a series parameter, is set, else the default. ...
virtual void SetWidth(float width)
const double & GetBlue() const
vtkXYChartRepresentation is representation that is used to add vtkPlot subclasses to a vtkChartXY ins...
std::map< std::string, std::string > Labels
void AddPlot(vtkChartRepresentation *self, const std::string &tableName, const std::string &columnName, const std::string &role, vtkPlot *plot)
vtkXYChartRepresentation::MapOfTables MapOfTables
static vtkPlotFunctionalBag * SafeDownCast(vtkObjectBase *o)
vtkSmartPointer< vtkPlot > Plot
std::map< std::string, int > AxisCorners
virtual std::vector< std::string > GetSeriesRoles(const std::string &vtkNotUsed(tableName), const std::string &vtkNotUsed(columnName))
Subclasses can override this method to assign a role for a specific data array in the input dataset...
std::map< std::string, int > LineStyles
void SetPlotCorner(vtkPlot *plot, int corner)
virtual int GetInputArrayIndex(const std::string &vtkNotUsed(tableName), const std::string &vtkNotUsed(columnName), const std::string &vtkNotUsed(role))
const double & GetRed() const
std::map< std::string, int > MarkerStyles
virtual bool UpdateSinglePlotProperties(vtkXYChartRepresentation *self, const std::string &tableName, const std::string &columnName, const std::string &role, vtkPlot *plot)
Returns false for in-visible plots.
std::map< std::string, double > MarkerSizes
vtkSmartPointer< vtkPlot > GetPlot(vtkChartRepresentation *self, const std::string &tableName, const std::string &columnName, const std::string &role=std::string()) const
virtual void SetLookupTable(vtkScalarsToColors *lut)
std::map< std::string, std::pair< vtkSmartPointer< vtkTable >, unsigned int > > MapOfTables
vtkAbstractArray * GetColumnByName(const char *name)
std::map< std::string, bool > UseColorMapping
virtual void AddStyle(vtkPlot *plot, const char *plotName)=0
Attach information about the style of the plot (color,line type, marker type etc. ...
virtual vtkPlot * AddPlot(int type)
void RemoveAllPlots(vtkChartXY *chartXY)
Destroy all vtkPlot instances.
static vtkPlotPoints * SafeDownCast(vtkObjectBase *o)
const char * GetColumnName(vtkIdType col)
void RemoveAllPlots(vtkChartXY *chartXY)
virtual bool RemovePlotInstance(vtkPlot *plot)
std::map< std::string, double > Opacities
virtual void UpdatePlotProperties(vtkXYChartRepresentation *self)
Update properties for plots in the chart.
virtual vtkTable * GetInput()
virtual void SetInputArray(int index, const vtkStdString &name)
vtkIdType LowerPlot(vtkPlot *plot)
std::map< std::string, bool > SeriesVisibilities
virtual void SetScalarVisibility(bool)
virtual void SetInputData(vtkTable *table)
virtual vtkIdType StackPlotAbove(vtkPlot *plot, vtkPlot *under)
std::map< std::string, int > LineThicknesses
virtual vtkStdString GetLabel()
std::string PreviousXAxisSeriesName
virtual void UpdatePlots(vtkXYChartRepresentation *self, const MapOfTables &tables)
Update i.e.
void SelectColorArray(vtkIdType arrayNum)
vtkChartRepresentation is the base representation for charting representations.
void SetColorF(double color[3])
virtual void SetUseIndexForXSeries(bool)
static vtkPlotBar * SafeDownCast(vtkObjectBase *o)
void HideAllPlots()
Hide all plots.
vtkPen * GetSelectionPen()
std::map< std::string, int > SeriesOrder
void SetPlotVisibility(bool val) const
vtkIdType GetNumberOfColumns()
virtual void SetVisible(bool)
virtual void SetLabel(const vtkStdString &label)
virtual vtkPlot * NewPlot(vtkXYChartRepresentation *self, const std::string &tableName, const std::string &columnName, const std::string &role, unsigned int block=0)
Add new plot.
void SetLineType(int type)
exporter used by certain views to export data into a file or stream.
virtual bool GetVisible()
void Intersect(const PlotsMap &other, vtkChartXY *chartXY)
const double & GetGreen() const
virtual void AddColumn(vtkAbstractArray *yarray, const char *yarrayname=nullptr, vtkDataArray *xarray=nullptr)=0
In STREAM_COLUMNS mode, use this method to add a column (yarray).
virtual void SelectableOff()
std::map< std::string, vtkColor3d > Colors