Back to index

salome-paravis  6.5.0
Classes | Public Slots | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pqCustomPlotSettingsModel Class Reference

#include <pqCustomPlotSettingsModel.h>

Collaboration diagram for pqCustomPlotSettingsModel:
Collaboration graph
[legend]

List of all members.

Classes

class  pqImplementation

Public Slots

void setSeriesEnabled (int row, bool enabled)

Public Member Functions

 pqCustomPlotSettingsModel (QObject *parent=0)
 ~pqCustomPlotSettingsModel ()
void setRepresentation (pqDataRepresentation *rep)
pqDataRepresentation * representation () const
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Sets the data for the given model index.
void SetIgnoreUnitsModeOn (bool enabled)
void SetAutoSelectModeOn (bool enabled)

Private Types

typedef pqPlotSettingsModel Superclass

Private Member Functions

QString getUnit (const QString &seriesName)

Private Attributes

pqImplementationImplementation
bool IgnoreUnitsModeOn
bool AutoSelectModeOn

Detailed Description

Definition at line 27 of file pqCustomPlotSettingsModel.h.


Member Typedef Documentation

typedef pqPlotSettingsModel pqCustomPlotSettingsModel::Superclass [private]

Definition at line 29 of file pqCustomPlotSettingsModel.h.


Constructor & Destructor Documentation

Definition at line 41 of file pqCustomPlotSettingsModel.cxx.

                                                                          :
  Superclass(parentObject), Implementation(new pqImplementation())
{
}

Definition at line 46 of file pqCustomPlotSettingsModel.cxx.

{
  delete this->Implementation;
}

Member Function Documentation

QString pqCustomPlotSettingsModel::getUnit ( const QString &  seriesName) [private]

Definition at line 202 of file pqCustomPlotSettingsModel.cxx.

{
  QString unit("");
  
  int index1 = seriesName.lastIndexOf("]");
  if (index1 == seriesName.size() - 1)
    {
      int index2 = seriesName.lastIndexOf(" [");
      if (index2 > 0)
       {
         int start = index2 + 2;
         unit = seriesName.mid(index2 + 2, index1 - start);
       }
    }

  return unit;
}

Here is the caller graph for this function:

pqDataRepresentation * pqCustomPlotSettingsModel::representation ( ) const

Definition at line 72 of file pqCustomPlotSettingsModel.cxx.

{
  return this->Implementation->Representation;
}

Definition at line 185 of file pqCustomPlotSettingsModel.cxx.

{
  this->AutoSelectModeOn = enabled;
  if (enabled && !this->IgnoreUnitsModeOn)
    {
      for (int i = 0; i < rowCount(QModelIndex()); i++)
       {
         if (getSeriesEnabled(i))
           {
             setSeriesEnabled(i, true);
             break;
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool pqCustomPlotSettingsModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
) [virtual]

Sets the data for the given model index.

Parameters:
indexThe model index.
valueThe new data for the given role.
roleThe role to set data for.
Returns:
True if the data was changed successfully.

Definition at line 78 of file pqCustomPlotSettingsModel.cxx.

{
  bool result = false;
  if (idx.isValid() && idx.model() == this)
    {
    if (idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole))
      {
      QString name = value.toString();
      if (!name.isEmpty())
        {
        this->setSeriesLabel(idx.row(), name);
        }
      }
    else if(idx.column() == 0 && role == Qt::CheckStateRole)
      {
      result = true;
      int checkstate = value.toInt();
      this->setSeriesEnabled(idx.row(), checkstate == Qt::Checked);
      }
    }
  return result;
}

Here is the call graph for this function:

Definition at line 168 of file pqCustomPlotSettingsModel.cxx.

{
  this->IgnoreUnitsModeOn = enabled;

  if (this->IgnoreUnitsModeOn)
    {
      this->setCheckable(0, Qt::Horizontal, true);
      this->setCheckState(0, Qt::Horizontal, Qt::Unchecked);
    }
  else
    {
      this->setCheckState(0, Qt::Horizontal, Qt::Unchecked);
      this->setCheckable(0, Qt::Horizontal, false);
    }
}

Here is the caller graph for this function:

void pqCustomPlotSettingsModel::setRepresentation ( pqDataRepresentation *  rep)

Definition at line 52 of file pqCustomPlotSettingsModel.cxx.

{
  Superclass::setRepresentation(rep);

  if (!rep || rep == this->Implementation->Representation)
    {
    return;
    }

  if (this->Implementation->Representation)
    {
    QObject::disconnect(this->Implementation->Representation, 0, this, 0);
    }

  this->Implementation->RepresentationProxy =
    vtkSMChartRepresentationProxy::SafeDownCast(rep->getProxy());
  this->Implementation->Representation = rep;
}

Here is the caller graph for this function:

void pqCustomPlotSettingsModel::setSeriesEnabled ( int  row,
bool  enabled 
) [slot]

Definition at line 103 of file pqCustomPlotSettingsModel.cxx.

{
  if (row >= 0 && row < this->rowCount(QModelIndex()))
    {
      int minRow = row;
      int maxRow = row;
      
      if (enabled && !(this->IgnoreUnitsModeOn)) 
       {
         QString unit = getUnit(QString(this->getSeriesName(row)));

         for (int i = 0; i < rowCount(QModelIndex()); i++)
           {
             if (i == row)
              {
                continue;
              }

             bool rowChanged = false;
             QString seriesName = QString(this->getSeriesName(i));
             QString seriesUnit = getUnit(seriesName);

             if ((seriesUnit != unit) && getSeriesEnabled(i))
              {
                vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
                "SeriesVisibility").SetStatus(this->getSeriesName(i), 0);
                rowChanged = true;
              }
             
             if (!seriesUnit.isEmpty() && this->AutoSelectModeOn &&
                (seriesUnit == unit) && !getSeriesEnabled(i))
              {
                vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
                "SeriesVisibility").SetStatus(this->getSeriesName(i), 1);
                rowChanged = true;
              }
             
             if (rowChanged)
              {
                if (i < minRow)
                  {
                    minRow = i;
                  }
                else if (i > maxRow)
                  {
                    maxRow = i;
                  }
              }
           }
       }
      
      vtkSMPropertyHelper(this->Implementation->RepresentationProxy,
      "SeriesVisibility").SetStatus(this->getSeriesName(row), enabled ? 1 : 0);
      this->Implementation->RepresentationProxy->UpdateVTKObjects();
    
      this->setSeriesColor(row, this->getSeriesColor(row));
      QModelIndex topLeft = this->createIndex(minRow, 0);
      QModelIndex bottomRight = this->createIndex(maxRow, 0);
      emit this->dataChanged(topLeft, bottomRight);
      emit this->redrawChart();
      this->updateCheckState(0, Qt::Horizontal);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 65 of file pqCustomPlotSettingsModel.h.

Definition at line 64 of file pqCustomPlotSettingsModel.h.

Definition at line 61 of file pqCustomPlotSettingsModel.h.


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