Back to index

salome-paravis  6.5.0
Classes | Public Slots | Public Member Functions | Protected Slots | Private Member Functions | Private Attributes
pqCustomXYChartDisplayPanel Class Reference

Editor widget for XY chart displays. More...

#include <pqCustomXYChartDisplayPanel.h>

Collaboration diagram for pqCustomXYChartDisplayPanel:
Collaboration graph
[legend]

List of all members.

Classes

class  pqInternal

Public Slots

void reloadSeries ()
 Reloads the series list from the display.

Public Member Functions

 pqCustomXYChartDisplayPanel (pqRepresentation *display, QWidget *parent=0)
virtual ~pqCustomXYChartDisplayPanel ()

Protected Slots

void activateItem (const QModelIndex &index)
 Slot to listen to clicks for changing color.
void updateOptionsWidgets ()
void setCurrentSeriesColor (const QColor &color)
void setCurrentSeriesThickness (int thickness)
void setCurrentSeriesStyle (int listIndex)
void setCurrentSeriesAxes (int listIndex)
void setCurrentSeriesMarkerStyle (int listIndex)
void useArrayIndexToggled (bool)
void useDataArrayToggled (bool)
void autoSelectToggled (bool checked)
 Unit controls.
void ignoreUnitsToggled (bool checked)
void resetUnitsControls ()
 Reset state of the controls relative to units.
void updateViewOptions ()
 Update view options.

Private Member Functions

 pqCustomXYChartDisplayPanel (const pqCustomXYChartDisplayPanel &)
void operator= (const pqCustomXYChartDisplayPanel &)
void setDisplay (pqRepresentation *display)
 Set the display whose properties this editor is editing. This call will raise an error if the display is not an XYChartRepresentation proxy.
void changeDialog (pqRepresentation *display)
 Disable/enable elements of the dialog based on the chart type.
Qt::CheckState getEnabledState () const

Private Attributes

pqInternalInternal
pqDataInformationModel * Model

Detailed Description

Editor widget for XY chart displays.

Definition at line 30 of file pqCustomXYChartDisplayPanel.h.


Constructor & Destructor Documentation

pqCustomXYChartDisplayPanel::pqCustomXYChartDisplayPanel ( pqRepresentation *  display,
QWidget *  parent = 0 
)

Definition at line 88 of file pqCustomXYChartDisplayPanel.cxx.

: pqDisplayPanel(display, p)
{
  this->Internal = new pqCustomXYChartDisplayPanel::pqInternal();
  this->Internal->setupUi(this);

  this->Internal->SettingsModel = new pqCustomPlotSettingsModel(this);
  this->Internal->SeriesList->setModel(this->Internal->SettingsModel);

  this->Internal->XAxisArrayAdaptor = new pqSignalAdaptorComboBox(
    this->Internal->XAxisArray);

  QObject::connect(
    this->Internal->SeriesList, SIGNAL(activated(const QModelIndex &)),
    this, SLOT(activateItem(const QModelIndex &)));
  QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
  QObject::connect(model,
    SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
    this, SLOT(updateOptionsWidgets()));
  QObject::connect(model,
    SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
    this, SLOT(updateOptionsWidgets()));
  QObject::connect(this->Internal->SettingsModel, SIGNAL(modelReset()),
    this, SLOT(updateOptionsWidgets()));
  QObject::connect(this->Internal->SettingsModel, SIGNAL(redrawChart()),
    this, SLOT(updateAllViews()));
  QObject::connect(this->Internal->XAxisArray, SIGNAL(currentIndexChanged(int)),
    this, SLOT(updateAllViews()));

  QObject::connect(this->Internal->UseArrayIndex, SIGNAL(toggled(bool)),
    this, SLOT(useArrayIndexToggled(bool)));
  QObject::connect(this->Internal->UseDataArray, SIGNAL(toggled(bool)),
    this, SLOT(useDataArrayToggled(bool)));

  QObject::connect(
    this->Internal->ColorButton, SIGNAL(chosenColorChanged(const QColor &)),
    this, SLOT(setCurrentSeriesColor(const QColor &)));
  QObject::connect(this->Internal->Thickness, SIGNAL(valueChanged(int)),
    this, SLOT(setCurrentSeriesThickness(int)));
  QObject::connect(this->Internal->StyleList, SIGNAL(currentIndexChanged(int)),
    this, SLOT(setCurrentSeriesStyle(int)));
  QObject::connect(this->Internal->AxisList, SIGNAL(currentIndexChanged(int)),
    this, SLOT(setCurrentSeriesAxes(int)));
  QObject::connect(this->Internal->MarkerStyleList, SIGNAL(currentIndexChanged(int)),
    this, SLOT(setCurrentSeriesMarkerStyle(int)));

  QObject::connect(
    this->Internal->AutoSelect, SIGNAL(toggled(bool)),
    this, SLOT(autoSelectToggled(bool)));

  QObject::connect(
    this->Internal->IgnoreUnits, SIGNAL(toggled(bool)),
    this, SLOT(ignoreUnitsToggled(bool)));

  QObject::connect(
    this->Internal->GenerateAxesTitles, SIGNAL(toggled(bool)),
    this, SLOT(updateViewOptions()));
  QObject::connect(this->Internal->SettingsModel, SIGNAL(redrawChart()),
    this, SLOT(updateViewOptions()));

  resetUnitsControls();

  this->setDisplay(display);

  QObject::connect(&this->Internal->Links, SIGNAL(qtWidgetChanged()),
                   this, SLOT(reloadSeries()), Qt::QueuedConnection);
  QObject::connect(&this->Internal->Links, SIGNAL(qtWidgetChanged()),
                   this->Internal->SettingsModel, SLOT(reload()));
}

Here is the call graph for this function:

Definition at line 160 of file pqCustomXYChartDisplayPanel.cxx.

{
  delete this->Internal;
}

Member Function Documentation

void pqCustomXYChartDisplayPanel::activateItem ( const QModelIndex &  index) [protected, slot]

Slot to listen to clicks for changing color.

Definition at line 244 of file pqCustomXYChartDisplayPanel.cxx.

{
  if(!this->Internal->ChartRepresentation
      || !index.isValid() || index.column() != 1)
    {
    // We are interested in clicks on the color swab alone.
    return;
    }

  // Get current color
  QColor color = this->Internal->SettingsModel->getSeriesColor(index.row());

  // Show color selector dialog to get a new color
  color = QColorDialog::getColor(color, this);
  if (color.isValid())
    {
    // Set the new color
    this->Internal->SettingsModel->setSeriesColor(index.row(), color);
    this->Internal->ColorButton->blockSignals(true);
    this->Internal->ColorButton->setChosenColor(color);
    this->Internal->ColorButton->blockSignals(false);
    this->updateAllViews();
    }
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::autoSelectToggled ( bool  checked) [protected, slot]

Unit controls.

Definition at line 424 of file pqCustomXYChartDisplayPanel.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::changeDialog ( pqRepresentation *  display) [private]

Disable/enable elements of the dialog based on the chart type.

Definition at line 223 of file pqCustomXYChartDisplayPanel.cxx.

{
  vtkSMChartRepresentationProxy* proxy =
    vtkSMChartRepresentationProxy::SafeDownCast(disp->getProxy());
  bool visible = true;
  if (QString("Bar") == vtkSMPropertyHelper(proxy,"ChartType").GetAsString())
    {
      visible = false;
    }
  
  this->Internal->Thickness->setVisible(visible);
  this->Internal->ThicknessLabel->setVisible(visible);
  this->Internal->StyleList->setVisible(visible);
  this->Internal->StyleListLabel->setVisible(visible);
  this->Internal->MarkerStyleList->setVisible(visible);
  this->Internal->MarkerStyleListLabel->setVisible(visible);
  this->Internal->AxisList->setVisible(false);
  this->Internal->AxisListLabel->setVisible(false);
}

Here is the caller graph for this function:

Qt::CheckState pqCustomXYChartDisplayPanel::getEnabledState ( ) const [private]

Definition at line 403 of file pqCustomXYChartDisplayPanel.cxx.

{
  Qt::CheckState enabledState = Qt::Unchecked;

  return enabledState;
}
void pqCustomXYChartDisplayPanel::ignoreUnitsToggled ( bool  checked) [protected, slot]

Definition at line 430 of file pqCustomXYChartDisplayPanel.cxx.

{
  this->Internal->AutoSelect->setEnabled(!checked);
  this->Internal->SettingsModel->SetIgnoreUnitsModeOn(checked);
  this->Internal->SettingsModel->SetAutoSelectModeOn(!checked && 
                                               this->Internal->AutoSelect->isChecked());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::operator= ( const pqCustomXYChartDisplayPanel ) [private]

Reloads the series list from the display.

Definition at line 166 of file pqCustomXYChartDisplayPanel.cxx.

{
  updateViewOptions();
  
  this->updateAllViews();
  this->updateOptionsWidgets();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reset state of the controls relative to units.

Definition at line 439 of file pqCustomXYChartDisplayPanel.cxx.

{
  this->Internal->IgnoreUnits->setCheckState(Qt::Checked);
  this->Internal->AutoSelect->setCheckState(Qt::Unchecked);
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::setCurrentSeriesAxes ( int  listIndex) [protected, slot]

Definition at line 397 of file pqCustomXYChartDisplayPanel.cxx.

{

}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::setCurrentSeriesColor ( const QColor &  color) [protected, slot]

Definition at line 329 of file pqCustomXYChartDisplayPanel.cxx.

{
  QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
  if(model)
    {
    this->Internal->InChange = true;
    QModelIndexList indexes = model->selectedIndexes();
    QModelIndexList::Iterator iter = indexes.begin();
    for( ; iter != indexes.end(); ++iter)
      {
      this->Internal->SettingsModel->setSeriesColor(iter->row(), color);
      }
    this->Internal->InChange = false;
    }
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::setCurrentSeriesMarkerStyle ( int  listIndex) [protected, slot]

Definition at line 380 of file pqCustomXYChartDisplayPanel.cxx.

{
  QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
  if (model)
    {
    this->Internal->InChange = true;
    QModelIndexList indexes = model->selectedIndexes();
    QModelIndexList::Iterator iter = indexes.begin();
    for( ; iter != indexes.end(); ++iter)
      {
      this->Internal->SettingsModel->setSeriesMarkerStyle(iter->row(), style);
      }
    this->Internal->InChange = false;
    }
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::setCurrentSeriesStyle ( int  listIndex) [protected, slot]

Definition at line 363 of file pqCustomXYChartDisplayPanel.cxx.

{
  QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
  if (model)
    {
    this->Internal->InChange = true;
    QModelIndexList indexes = model->selectedIndexes();
    QModelIndexList::Iterator iter = indexes.begin();
    for( ; iter != indexes.end(); ++iter)
      {
      this->Internal->SettingsModel->setSeriesStyle(iter->row(), style);
      }
    this->Internal->InChange = false;
    }
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::setCurrentSeriesThickness ( int  thickness) [protected, slot]

Definition at line 346 of file pqCustomXYChartDisplayPanel.cxx.

{
  QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
  if (model)
    {
    this->Internal->InChange = true;
    QModelIndexList indexes = model->selectedIndexes();
    QModelIndexList::Iterator iter = indexes.begin();
    for( ; iter != indexes.end(); ++iter)
      {
      this->Internal->SettingsModel->setSeriesThickness(iter->row(), thickness);
      }
    this->Internal->InChange = false;
    }
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::setDisplay ( pqRepresentation *  display) [private]

Set the display whose properties this editor is editing. This call will raise an error if the display is not an XYChartRepresentation proxy.

Definition at line 175 of file pqCustomXYChartDisplayPanel.cxx.

{
  this->setEnabled(false);

  vtkSMChartRepresentationProxy* proxy =
    vtkSMChartRepresentationProxy::SafeDownCast(disp->getProxy());
  this->Internal->ChartRepresentation = proxy;
  if (!this->Internal->ChartRepresentation)
    {
    qWarning() << "pqCustomXYChartDisplayPanel given a representation proxy "
                  "that is not an XYChartRepresentation. Cannot edit.";
    return;
    }

  // this is essential to ensure that when you undo-redo, the representation is
  // indeed update-to-date, thus ensuring correct domains etc.
  proxy->UpdatePipeline();

  // The model for the plot settings
  this->Internal->SettingsModel->setRepresentation(
      qobject_cast<pqDataRepresentation*>(disp));

  // Connect to the new properties.pqComboBoxDomain will ensure that
  // when ever the domain changes the widget is updated as well.
  this->Internal->XAxisArrayDomain = new pqComboBoxDomain(
      this->Internal->XAxisArray, proxy->GetProperty("XArrayName"));
  this->Internal->Links.addPropertyLink(this->Internal->XAxisArrayAdaptor,
      "currentText", SIGNAL(currentTextChanged(const QString&)),
      proxy, proxy->GetProperty("XArrayName"));

  // Link to set whether the index is used for the x axis
  this->Internal->Links.addPropertyLink(
    this->Internal->UseArrayIndex, "checked",
    SIGNAL(toggled(bool)),
    proxy, proxy->GetProperty("UseIndexForXAxis"));

  // Proxy changed
  this->Internal->VTKConnect->Connect(proxy->GetProperty("SeriesNamesInfo"),
       vtkCommand::PropertyModifiedEvent, this, SLOT(resetUnitsControls()));

  this->changeDialog(disp);

  this->setEnabled(true);

  this->reloadSeries();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 270 of file pqCustomXYChartDisplayPanel.cxx.

{
  QItemSelectionModel *model = this->Internal->SeriesList->selectionModel();
  if(model)
    {
    // Show the options for the current item.
    QModelIndex current = model->currentIndex();
    QModelIndexList indexes = model->selectedIndexes();
    if((!current.isValid() || !model->isSelected(current)) &&
        indexes.size() > 0)
      {
      current = indexes.last();
      }

    this->Internal->ColorButton->blockSignals(true);
    this->Internal->Thickness->blockSignals(true);
    this->Internal->StyleList->blockSignals(true);
    this->Internal->MarkerStyleList->blockSignals(true);
    this->Internal->AxisList->blockSignals(true);
    if (current.isValid())
      {
      int seriesIndex = current.row();
      QColor color = this->Internal->SettingsModel->getSeriesColor(seriesIndex);
      this->Internal->ColorButton->setChosenColor(color);
      this->Internal->Thickness->setValue(
        this->Internal->SettingsModel->getSeriesThickness(seriesIndex));
      this->Internal->StyleList->setCurrentIndex(
        this->Internal->SettingsModel->getSeriesStyle(seriesIndex));
      this->Internal->MarkerStyleList->setCurrentIndex(
        this->Internal->SettingsModel->getSeriesMarkerStyle(seriesIndex));
      this->Internal->AxisList->setCurrentIndex(
        this->Internal->SettingsModel->getSeriesAxisCorner(seriesIndex));
      }
    else
      {
      this->Internal->ColorButton->setChosenColor(Qt::white);
      this->Internal->Thickness->setValue(1);
      this->Internal->StyleList->setCurrentIndex(0);
      this->Internal->MarkerStyleList->setCurrentIndex(0);
      this->Internal->AxisList->setCurrentIndex(0);
      }

    this->Internal->ColorButton->blockSignals(false);
    this->Internal->Thickness->blockSignals(false);
    this->Internal->StyleList->blockSignals(false);
    this->Internal->MarkerStyleList->blockSignals(false);
    this->Internal->AxisList->blockSignals(false);

    // Disable the widgets if nothing is selected or current.
    bool hasItems = indexes.size() > 0;
    this->Internal->ColorButton->setEnabled(hasItems);
    this->Internal->Thickness->setEnabled(hasItems);
    this->Internal->StyleList->setEnabled(hasItems);
    this->Internal->MarkerStyleList->setEnabled(hasItems);
    this->Internal->AxisList->setEnabled(hasItems);
    }
}

Here is the caller graph for this function:

Update view options.

Definition at line 446 of file pqCustomXYChartDisplayPanel.cxx.

{
  pqRepresentation* disp = this->getRepresentation();
  if (!disp || !this->Internal->ChartRepresentation)
    {
      return;
    }

  pqXYChartView* view = qobject_cast<pqXYChartView*>(disp->getView());
  if (view && view->getProxy())
    {
      vtkSMProxy* proxy = view->getProxy();
      
      QList<QVariant> values = 
       pqSMAdaptor::getMultipleElementProperty(proxy->GetProperty("AxisTitle"));
      if (values.size() < 2)
       {
         return;
       }
      
      if (!this->Internal->GenerateAxesTitles->isChecked())
       {
         values.insert(0, QVariant(""));
         values.insert(1, QVariant(""));
       }
      else
       {
         // Set X axis title
         int useIndexForXAxis = vtkSMPropertyHelper(
              this->Internal->ChartRepresentation, "UseIndexForXAxis").GetAsInt();
         
         QString xTitle("");
         if (!useIndexForXAxis) 
           {
             xTitle = vtkSMPropertyHelper(this->Internal->ChartRepresentation, "XArrayName")
              .GetAsString();
           }
      
         // Set Y axis title
         int nbRows = this->Internal->SettingsModel->rowCount(QModelIndex());
         int nbEnabled = 0;
         int row = 0;
         for (int i = 0; i < nbRows && nbEnabled < 2; i++)
           {
             if (this->Internal->SettingsModel->getSeriesEnabled(i))
              {
                nbEnabled++;
                row = i;
              }
           }
         
         QString yTitle("");
         if (nbEnabled == 1)
           {
             yTitle = this->Internal->SettingsModel->getSeriesName(row);
           }
         values.insert(0, QVariant(yTitle));
         values.insert(1, QVariant(xTitle));
       }

      pqSMAdaptor::setMultipleElementProperty(proxy->GetProperty("AxisTitle"), values);

      view->getProxy()->UpdateVTKObjects();
      view->render();
    }
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::useArrayIndexToggled ( bool  toggle) [protected, slot]

Definition at line 411 of file pqCustomXYChartDisplayPanel.cxx.

{
  this->Internal->UseDataArray->setChecked(!toggle);
}

Here is the caller graph for this function:

void pqCustomXYChartDisplayPanel::useDataArrayToggled ( bool  toggle) [protected, slot]

Definition at line 417 of file pqCustomXYChartDisplayPanel.cxx.

{
  this->Internal->UseArrayIndex->setChecked(!toggle);
  this->updateAllViews();
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 85 of file pqCustomXYChartDisplayPanel.h.

pqDataInformationModel* pqCustomXYChartDisplayPanel::Model [private]

Definition at line 88 of file pqCustomXYChartDisplayPanel.h.


The documentation for this class was generated from the following files: