Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/functionviewer.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzQt includes
Toshihiro Shimizu 890ddd
#include "toonzqt/functionselection.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/functionpanel.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/functiontreeviewer.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/functionsheet.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/functionsegmentviewer.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/functiontoolbar.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/swatchviewer.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/dvscrollwidget.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjecttree.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheet.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheethandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tobjecthandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tfxhandle.h"
Campbell Barton d0e335
#include "toonz/tcolumnhandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/fxdag.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshzeraryfxcolumn.h"
Toshihiro Shimizu 890ddd
#include "toonz/tcolumnfx.h"
Toshihiro Shimizu 890ddd
#include "toonz/toonzscene.h"
Toshihiro Shimizu 890ddd
#include "toonz/tproject.h"
Toshihiro Shimizu 890ddd
#include "toonz/tscenehandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/sceneproperties.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzBase includes
Toshihiro Shimizu 890ddd
#include "tparamcontainer.h"
Toshihiro Shimizu 890ddd
#include "tunit.h"
Jeremy Bullock 4ce953
#include "tenv.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tstopwatch.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qpainter></qpainter>
Toshihiro Shimizu 890ddd
#include <qmouseevent></qmouseevent>
Toshihiro Shimizu 890ddd
#include <qwheelevent></qwheelevent>
Toshihiro Shimizu 890ddd
#include <qboxlayout></qboxlayout>
Toshihiro Shimizu 890ddd
#include <qpushbutton></qpushbutton>
Toshihiro Shimizu 890ddd
#include <qstackedwidget></qstackedwidget>
Toshihiro Shimizu 890ddd
#include <qlabel></qlabel>
Campbell Barton d0e335
#include <qtoolbar></qtoolbar>
Toshihiro Shimizu 890ddd
#include <qaction></qaction>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace DVGui;
Toshihiro Shimizu 890ddd
Jeremy Bullock 4ce953
TEnv::IntVar FunctionEditorToggleStatus("FunctionEditorToggleStatus", 0);
Jeremy Bullock 4ce953
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// FunctionPanel
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050500
Toshihiro Shimizu 890ddd
FunctionViewer::FunctionViewer(QWidget *parent, Qt::WindowFlags flags)
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
FunctionViewer::FunctionViewer(QWidget *parent, Qt::WFlags flags)
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
    : QSplitter(parent)
Shinya Kitaoka 120a6e
    , m_xshHandle(0)
Shinya Kitaoka 120a6e
    , m_frameHandle(0)
Shinya Kitaoka 120a6e
    , m_objectHandle(0)
Shinya Kitaoka 120a6e
    , m_fxHandle(0)
Shinya Kitaoka 120a6e
    , m_columnHandle(0)
Shinya Kitaoka 120a6e
    , m_curve(0)
Shinya Kitaoka 120a6e
    , m_selection(new FunctionSelection())
Shinya Kitaoka 120a6e
    , m_sceneHandle(0) {
Shinya Kitaoka 120a6e
  setObjectName("FunctionEditor");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // Prepare local timeline
Shinya Kitaoka 120a6e
  m_localFrame.setFrame(0);
Shinya Kitaoka 120a6e
  setFocusPolicy(Qt::NoFocus);
Jeremy Bullock 4ce953
  m_toggleStart = Preferences::instance()->getFunctionEditorToggle();
Jeremy Bullock 4ce953
  if (m_toggleStart ==
Jeremy Bullock 4ce953
      Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup) {
Jeremy Bullock 4ce953
    m_functionGraph    = new FunctionPanel(this, false);
Jeremy Bullock 4ce953
    m_numericalColumns = new FunctionSheet(this, true);
Jeremy Bullock 4ce953
  } else if (m_toggleStart == Preferences::FunctionEditorToggle::
Jeremy Bullock 4ce953
                                  ToggleBetweenGraphAndSpreadsheet) {
Jeremy Bullock 4ce953
    m_functionGraph    = new FunctionPanel(this, false);
Jeremy Bullock 4ce953
    m_numericalColumns = new FunctionSheet(this, false);
Jeremy Bullock 4ce953
  } else {
Jeremy Bullock 4ce953
    // default values are graph is floating
Jeremy Bullock 4ce953
    // and spreadsheet is not floating
Jeremy Bullock 4ce953
    m_functionGraph    = new FunctionPanel(this);
Jeremy Bullock 4ce953
    m_numericalColumns = new FunctionSheet(this);
Jeremy Bullock 4ce953
  }
Jeremy Bullock 4ce953
  m_treeView = new FunctionTreeView(this);
Shinya Kitaoka 120a6e
Jeremy Bullock 4ce953
  m_toolbar = new FunctionToolbar;
Shinya Kitaoka 120a6e
  m_segmentViewer =
Shinya Kitaoka 120a6e
      new FunctionSegmentViewer(this, m_numericalColumns, m_functionGraph);
Shinya Kitaoka 120a6e
  QWidget *leftPanel  = new QWidget();
Shinya Kitaoka 120a6e
  QWidget *rightPanel = new QWidget();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //----
Shinya Kitaoka 120a6e
  m_treeView->resize(150, m_treeView->size().height());
Shinya Kitaoka 120a6e
  m_treeView->setMinimumWidth(0);
Kite 521c84
  m_treeView->setIconSize(QSize(21, 18));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  FunctionTreeModel *ftModel =
Shinya Kitaoka 120a6e
      dynamic_cast<functiontreemodel *="">(m_treeView->model());</functiontreemodel>
Shinya Kitaoka 120a6e
  m_functionGraph->setModel(ftModel);
Shinya Kitaoka 120a6e
  m_numericalColumns->setModel(ftModel);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_functionGraph->setSelection(getSelection());
Shinya Kitaoka 120a6e
  m_numericalColumns->setSelection(getSelection());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_numericalColumns->setViewer(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_toolbar->setSelection(m_selection);
Shinya Kitaoka 120a6e
  m_toolbar->setFocusPolicy(Qt::NoFocus);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_toolbar->setFrameHandle(
Shinya Kitaoka 120a6e
      &m_localFrame);  // The function editor adopts an internal timeline
Shinya Kitaoka 120a6e
  m_functionGraph->setFrameHandle(
Shinya Kitaoka 120a6e
      &m_localFrame);  // synchronized among its various sub-widgets.
Shinya Kitaoka 120a6e
  m_numericalColumns->setFrameHandle(
Shinya Kitaoka 120a6e
      &m_localFrame);  // In case an external m_frameHandle is specified,
Shinya Kitaoka 120a6e
                       // it synchronizes with that, too.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //---- layout
Shinya Kitaoka 120a6e
Jeremy Bullock 15fcba
  m_leftLayout = new QVBoxLayout();
Jeremy Bullock 15fcba
  m_leftLayout->setMargin(0);
Jeremy Bullock 15fcba
  m_leftLayout->setSpacing(0);
Shinya Kitaoka 120a6e
  {
Jeremy Bullock 15fcba
    m_leftLayout->addWidget(m_toolbar);
Jeremy Bullock 15fcba
    if (Preferences::instance()->isShowXSheetToolbarEnabled() &&
Jeremy Bullock 15fcba
        Preferences::instance()->isExpandFunctionHeaderEnabled()) {
Jeremy Bullock 4ce953
      m_spacing = 65;
Jeremy Bullock 15fcba
    } else
Jeremy Bullock 4ce953
      m_spacing = 35;
manongjohn 399e7d
manongjohn 399e7d
    QString layout = Preferences::instance()->getLoadedXsheetLayout();
Jeremy Bullock 4ce953
    if (layout == QString("Compact")) m_spacing -= 18;
Jeremy Bullock 4ce953
Jeremy Bullock 4ce953
    if (m_toggleStart !=
Jeremy Bullock 4ce953
        Preferences::FunctionEditorToggle::ShowGraphEditorInPopup)
Jeremy Bullock 4ce953
      m_leftLayout->addWidget(m_functionGraph);
Jeremy Bullock 4ce953
    if (m_toggleStart !=
Jeremy Bullock 4ce953
        Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
Jeremy Bullock 4ce953
      m_leftLayout->addWidget(m_numericalColumns);
Shinya Kitaoka 120a6e
  }
Jeremy Bullock 4ce953
Jeremy Bullock 15fcba
  leftPanel->setLayout(m_leftLayout);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  addWidget(leftPanel);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QVBoxLayout *rightLayout = new QVBoxLayout();
Shinya Kitaoka 120a6e
  rightLayout->setMargin(0);
Shinya Kitaoka 120a6e
  rightLayout->setSpacing(5);
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    rightLayout->addWidget(m_segmentViewer, 0);
Shinya Kitaoka 120a6e
    rightLayout->addWidget(m_treeView, 1);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  rightPanel->setLayout(rightLayout);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  addWidget(rightPanel);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //--- set the splitter's default size
Shinya Kitaoka 120a6e
  setSizes(QList<int>() << 500 << 200);</int>
Shinya Kitaoka 120a6e
  setStretchFactor(0, 5);
Shinya Kitaoka 120a6e
  setStretchFactor(1, 2);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //---- signal-slot connections
Shinya Kitaoka 120a6e
  bool ret = true;
Shinya Kitaoka 120a6e
  ret      = ret && connect(m_toolbar, SIGNAL(numericalColumnToggled()), this,
Shinya Kitaoka 120a6e
                       SLOT(toggleMode()));
shun-iwasawa 4a3868
  ret      = ret && connect(ftModel, SIGNAL(activeChannelsChanged()),
Shinya Kitaoka 120a6e
                       m_functionGraph, SLOT(update()));
shun-iwasawa 4a3868
  ret      = ret && connect(ftModel, SIGNAL(activeChannelsChanged()),
Shinya Kitaoka 120a6e
                       m_numericalColumns, SLOT(updateAll()));
shun-iwasawa 4a3868
  ret      = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_treeView,
Shinya Kitaoka 120a6e
                       SLOT(update()));
Shinya Kitaoka 120a6e
  ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_functionGraph,
Shinya Kitaoka 120a6e
                       SLOT(update()));
Shinya Kitaoka 120a6e
  ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_numericalColumns,
Shinya Kitaoka 120a6e
                       SLOT(updateAll()));
Shinya Kitaoka 120a6e
  ret = ret && connect(ftModel, SIGNAL(curveSelected(TDoubleParam *)), this,
Shinya Kitaoka 120a6e
                       SLOT(onCurveSelected(TDoubleParam *)));
Shinya Kitaoka 120a6e
  ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_segmentViewer,
Shinya Kitaoka 120a6e
                       SLOT(onCurveChanged()));
Shinya Kitaoka 120a6e
  ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onCurveChanged(bool)));
Shinya Kitaoka 120a6e
  ret = ret && connect(&m_localFrame, SIGNAL(frameSwitched()), this,
Shinya Kitaoka 120a6e
                       SLOT(onFrameSwitched()));
Shinya Kitaoka 120a6e
  ret = ret && connect(getSelection(), SIGNAL(selectionChanged()), this,
Shinya Kitaoka 120a6e
                       SLOT(onSelectionChanged()));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_functionGraph, SIGNAL(keyframeSelected(double)),
Shinya Kitaoka 120a6e
                       m_toolbar, SLOT(setFrame(double)));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ret = ret && connect(m_treeView, SIGNAL(switchCurrentObject(TStageObject *)),
Shinya Kitaoka 120a6e
                       this, SLOT(doSwitchCurrentObject(TStageObject *)));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_treeView, SIGNAL(switchCurrentFx(TFx *)), this,
Shinya Kitaoka 120a6e
                       SLOT(doSwitchCurrentFx(TFx *)));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ret = ret &&
Shinya Kitaoka 120a6e
        connect(ftModel,
Shinya Kitaoka 120a6e
                SIGNAL(currentChannelChanged(FunctionTreeModel::Channel *)),
Shinya Kitaoka 120a6e
                m_numericalColumns,
Shinya Kitaoka 120a6e
                SLOT(onCurrentChannelChanged(FunctionTreeModel::Channel *)));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  assert(ret);
Jeremy Bullock 4ce953
  if (m_toggleStart ==
Jeremy Bullock 4ce953
      Preferences::FunctionEditorToggle::ShowGraphEditorInPopup) {
Jeremy Bullock 4ce953
    m_functionGraph->hide();
Jeremy Bullock 4ce953
    m_leftLayout->setSpacing(m_spacing);
Jeremy Bullock 4ce953
  }
Jeremy Bullock 4ce953
  if (m_toggleStart ==
Jeremy Bullock 4ce953
      Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
Jeremy Bullock 4ce953
    m_numericalColumns->hide();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
FunctionViewer::~FunctionViewer() {
Shinya Kitaoka 120a6e
  delete m_selection;
Shinya Kitaoka 120a6e
  m_toolbar->setFrameHandle(0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::showEvent(QShowEvent *) {
Shinya Kitaoka 120a6e
  refreshModel();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // Connect handles
Shinya Kitaoka 120a6e
  bool ret = true;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_xshHandle) {
Shinya Kitaoka 120a6e
    ret = connect(m_xshHandle, SIGNAL(xsheetChanged()), this,
Shinya Kitaoka 120a6e
                  SLOT(refreshModel())) &&
Shinya Kitaoka 120a6e
          ret;
Shinya Kitaoka 120a6e
    ret = connect(m_xshHandle, SIGNAL(xsheetSwitched()), this,
Shinya Kitaoka 120a6e
                  SLOT(rebuildModel())) &&
Shinya Kitaoka 120a6e
          ret;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
manongjohn 4be4bb
  if (m_frameHandle) {
Shinya Kitaoka 120a6e
    ret = connect(m_frameHandle, SIGNAL(frameSwitched()), this,
Shinya Kitaoka 120a6e
                  SLOT(propagateExternalSetFrame())) &&
Shinya Kitaoka 120a6e
          ret;
Shinya Kitaoka 120a6e
manongjohn 4be4bb
    ret = connect(m_frameHandle, SIGNAL(triggerNextKeyframe(QWidget *)),
manongjohn 4be4bb
                  m_toolbar, SLOT(onNextKeyframe(QWidget *))) &&
manongjohn 4be4bb
          ret;
manongjohn 4be4bb
    ret = connect(m_frameHandle, SIGNAL(triggerPrevKeyframe(QWidget *)),
manongjohn 4be4bb
                  m_toolbar, SLOT(onPrevKeyframe(QWidget *))) &&
manongjohn 4be4bb
          ret;
manongjohn 4be4bb
  }
manongjohn 4be4bb
Shinya Kitaoka 120a6e
  if (m_objectHandle) {
Shinya Kitaoka 120a6e
    ret = connect(m_objectHandle, SIGNAL(objectSwitched()), this,
Shinya Kitaoka 120a6e
                  SLOT(onStageObjectSwitched())) &&
Shinya Kitaoka 120a6e
          ret;
Shinya Kitaoka 120a6e
    ret = connect(m_objectHandle, SIGNAL(objectChanged(bool)), this,
Shinya Kitaoka 120a6e
                  SLOT(onStageObjectChanged(bool))) &&
Shinya Kitaoka 120a6e
          ret;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_fxHandle)
Shinya Kitaoka 120a6e
    ret =
Shinya Kitaoka 120a6e
        connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched())) &&
Shinya Kitaoka 120a6e
        ret;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // display animated channels when the scene is switched
Shinya Kitaoka 120a6e
  if (m_sceneHandle)
Shinya Kitaoka 120a6e
    ret = connect(m_sceneHandle, SIGNAL(sceneSwitched()), m_treeView,
Shinya Kitaoka 120a6e
                  SLOT(displayAnimatedChannels())) &&
Shinya Kitaoka 120a6e
          ret;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  assert(ret);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_treeView->setExpanded(m_treeView->model()->index(0, 0), true);
Shinya Kitaoka 120a6e
  m_treeView->setExpanded(m_treeView->model()->index(1, 0), true);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  FunctionTreeModel *ftm =
Shinya Kitaoka 120a6e
      static_cast<functiontreemodel *="">(m_treeView->model());</functiontreemodel>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_objectHandle) {
Shinya Kitaoka 120a6e
    assert(m_xshHandle);
Shinya Kitaoka 120a6e
    TXsheet *xsh = m_xshHandle->getXsheet();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    const TStageObjectId &objId = m_objectHandle->getObjectId();
Shinya Kitaoka 120a6e
    ftm->setCurrentStageObject((objId == TStageObjectId::NoneId)
Shinya Kitaoka 120a6e
                                   ? (TStageObject *)0
Shinya Kitaoka 120a6e
                                   : xsh->getStageObject(objId));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_fxHandle) ftm->setCurrentFx(m_fxHandle->getFx());
Jeremy Bullock 4ce953
  if (m_toggleStart ==
Jeremy Bullock 4ce953
      Preferences::FunctionEditorToggle::ToggleBetweenGraphAndSpreadsheet) {
Jeremy Bullock 4ce953
    if (m_toggleStatus == 1) {
Jeremy Bullock 4ce953
      m_numericalColumns->hide();
Jeremy Bullock 4ce953
      m_functionGraph->show();
Jeremy Bullock 4ce953
      m_leftLayout->setSpacing(0);
Jeremy Bullock 4ce953
    } else {
Jeremy Bullock 4ce953
      m_functionGraph->hide();
Jeremy Bullock 4ce953
      m_numericalColumns->show();
Jeremy Bullock 4ce953
      m_leftLayout->setSpacing(m_spacing);
Jeremy Bullock 4ce953
    }
Jeremy Bullock 4ce953
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::hideEvent(QHideEvent *) {
Shinya Kitaoka 120a6e
  if (m_xshHandle) m_xshHandle->disconnect(this);
manongjohn 4be4bb
  if (m_frameHandle) {
manongjohn 4be4bb
    m_frameHandle->disconnect(this);
manongjohn 4be4bb
    m_frameHandle->disconnect(m_toolbar);
manongjohn 4be4bb
  }
Shinya Kitaoka 120a6e
  if (m_objectHandle) m_objectHandle->disconnect(this);
Shinya Kitaoka 120a6e
  if (m_fxHandle) m_fxHandle->disconnect(this);
Shinya Kitaoka 120a6e
  if (m_sceneHandle) m_sceneHandle->disconnect(this);
Jeremy Bullock 4ce953
  if (m_toggleStart ==
Jeremy Bullock 4ce953
      Preferences::FunctionEditorToggle::ShowGraphEditorInPopup) {
Jeremy Bullock 4ce953
    if (m_functionGraph->isVisible()) m_functionGraph->hide();
Jeremy Bullock 4ce953
  }
Jeremy Bullock 4ce953
  if (m_toggleStart ==
Jeremy Bullock 4ce953
      Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup) {
Jeremy Bullock 4ce953
    if (m_numericalColumns->isVisible()) m_numericalColumns->hide();
Jeremy Bullock 4ce953
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::openContextMenu(TreeModel::Item *item,
Shinya Kitaoka 120a6e
                                     const QPoint &globalPos) {
Shinya Kitaoka 120a6e
  m_treeView->openContextMenu(item, globalPos);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::rebuildModel() {
Shinya Kitaoka 120a6e
  getSelection()->selectNone();
Shinya Kitaoka 120a6e
  onCurveSelected(0);
Shinya Kitaoka 120a6e
  m_functionGraph->getModel()->resetAll();
Shinya Kitaoka 120a6e
  refreshModel();
Shinya Kitaoka 120a6e
  m_treeView->displayAnimatedChannels();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::refreshModel() {
Shinya Kitaoka 120a6e
  TXsheet *xsh = m_xshHandle ? m_xshHandle->getXsheet() : 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_functionGraph->getModel()->refreshData(xsh);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (xsh) {
Shinya Kitaoka 120a6e
    int rowCount = xsh->getFrameCount();
Shinya Kitaoka 120a6e
    m_numericalColumns->setRowCount(rowCount);
Shinya Kitaoka 120a6e
    m_numericalColumns->updateAll();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    ToonzScene *scene = xsh->getScene();
Shinya Kitaoka 120a6e
    if (!scene)  // This seems wrong. It should rather be
Shinya Kitaoka 120a6e
      return;    // asserted - though I'm not touching it now...
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    TFilePath scenePath = scene->getScenePath().getParentDir();
Shinya Kitaoka 120a6e
    if (scene->isUntitled())
Shinya Kitaoka 120a6e
      scenePath =
Shinya Kitaoka 120a6e
          TProjectManager::instance()->getCurrentProject()->getScenesPath();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    m_treeView->setCurrentScenePath(scenePath);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    int distance, offset;
Shinya Kitaoka 120a6e
    scene->getProperties()->getMarkers(distance, offset);
Shinya Kitaoka 120a6e
    m_numericalColumns->setMarkRow(distance, offset);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_treeView->updateAll();
Shinya Kitaoka 120a6e
  m_toolbar->setCurve(0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::setXsheetHandle(TXsheetHandle *xshHandle) {
Shinya Kitaoka 120a6e
  if (xshHandle == m_xshHandle) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_xshHandle) m_xshHandle->disconnect(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_xshHandle = xshHandle;
Shinya Kitaoka 120a6e
  m_segmentViewer->setXsheetHandle(xshHandle);
shun-iwasawa 4a3868
  m_treeView->setXsheetHandle(xshHandle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_xshHandle && isVisible()) {
Shinya Kitaoka 120a6e
    TXsheet *xsh = m_xshHandle->getXsheet();
Shinya Kitaoka 120a6e
    m_functionGraph->getModel()->refreshData(xsh);
Toshihiro Shimizu 890ddd
Jeremy Bullock 15fcba
    bool ret = connect(m_xshHandle, SIGNAL(xsheetChanged()), this,
Jeremy Bullock 15fcba
                       SLOT(refreshModel()));
Shinya Kitaoka 120a6e
    assert(ret);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::setFrameHandle(TFrameHandle *frameHandle) {
Shinya Kitaoka 120a6e
  if (m_frameHandle == frameHandle) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_frameHandle) m_frameHandle->disconnect(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_frameHandle = frameHandle;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_frameHandle && isVisible()) {
Shinya Kitaoka 120a6e
    bool ret = connect(m_frameHandle, SIGNAL(frameSwitched()), this,
Shinya Kitaoka 120a6e
                       SLOT(propagateExternalSetFrame()));
Shinya Kitaoka 120a6e
    assert(ret);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::setObjectHandle(TObjectHandle *objectHandle) {
Shinya Kitaoka 120a6e
  if (objectHandle == m_objectHandle) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_objectHandle) m_objectHandle->disconnect(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_objectHandle = objectHandle;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_objectHandle && isVisible()) {
Shinya Kitaoka 120a6e
    m_treeView->updateAll();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bool ret = true;
Shinya Kitaoka 120a6e
    ret      = connect(m_objectHandle, SIGNAL(objectSwitched()), this,
Shinya Kitaoka 120a6e
                  SLOT(onStageObjectSwitched())) &&
Shinya Kitaoka 120a6e
          ret;
Shinya Kitaoka 120a6e
    ret = connect(m_objectHandle, SIGNAL(objectChanged(bool)), this,
Shinya Kitaoka 120a6e
                  SLOT(onStageObjectChanged(bool))) &&
Shinya Kitaoka 120a6e
          ret;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    assert(ret);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  FunctionTreeModel *ftModel =
Shinya Kitaoka 120a6e
      static_cast<functiontreemodel *="">(m_treeView->model());</functiontreemodel>
Shinya Kitaoka 120a6e
  if (ftModel) ftModel->setObjectHandle(objectHandle);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::setFxHandle(TFxHandle *fxHandle) {
Shinya Kitaoka 120a6e
  if (fxHandle == m_fxHandle) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_fxHandle) m_fxHandle->disconnect(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_fxHandle = fxHandle;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (isVisible()) {
Shinya Kitaoka 120a6e
    m_treeView->updateAll();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bool ret =
Shinya Kitaoka 120a6e
        connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched()));
Shinya Kitaoka 120a6e
    assert(ret);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  FunctionTreeModel *ftModel =
Shinya Kitaoka 120a6e
      static_cast<functiontreemodel *="">(m_treeView->model());</functiontreemodel>
Shinya Kitaoka 120a6e
  if (ftModel) ftModel->setFxHandle(fxHandle);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::setColumnHandle(TColumnHandle *columnHandle) {
Shinya Kitaoka 120a6e
  if (columnHandle == m_columnHandle) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_columnHandle = columnHandle;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (isVisible()) m_treeView->updateAll();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onFrameSwitched() {
Shinya Kitaoka 120a6e
  int frame = m_localFrame.getFrame();
Shinya Kitaoka 120a6e
  m_segmentViewer->setSegmentByFrame(m_curve, frame);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_frameHandle) m_frameHandle->setFrame(frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::toggleMode() {
Shinya Kitaoka 120a6e
  if (isHidden()) return;
Jeremy Bullock 4ce953
  if (m_toggleStart ==
Jeremy Bullock 4ce953
      Preferences::FunctionEditorToggle::ShowGraphEditorInPopup) {
Jeremy Bullock 4ce953
    if (m_functionGraph->isVisible()) {
Jeremy Bullock 4ce953
      m_functionGraph->hide();
Jeremy Bullock 4ce953
    } else {
Jeremy Bullock 4ce953
      m_functionGraph->show();
Jeremy Bullock 4ce953
    }
Jeremy Bullock 4ce953
  } else if (m_toggleStart == Preferences::FunctionEditorToggle::
Jeremy Bullock 4ce953
                                  ShowFunctionSpreadsheetInPopup) {
Jeremy Bullock 4ce953
    if (m_numericalColumns->isVisible()) {
Jeremy Bullock 4ce953
      m_numericalColumns->hide();
Jeremy Bullock 4ce953
    } else {
Jeremy Bullock 4ce953
      m_numericalColumns->show();
Jeremy Bullock 4ce953
    }
Jeremy Bullock 4ce953
  } else if (m_toggleStart == Preferences::FunctionEditorToggle::
Jeremy Bullock 4ce953
                                  ToggleBetweenGraphAndSpreadsheet) {
Jeremy Bullock 4ce953
    if (m_functionGraph->isVisible()) {
Jeremy Bullock 4ce953
      m_functionGraph->hide();
Jeremy Bullock 4ce953
      m_numericalColumns->show();
Jeremy Bullock 4ce953
      m_leftLayout->setSpacing(m_spacing);
Jeremy Bullock 4ce953
      m_toggleStatus = 0;
Jeremy Bullock 4ce953
    } else {
Jeremy Bullock 4ce953
      m_functionGraph->show();
Jeremy Bullock 4ce953
      m_numericalColumns->hide();
Jeremy Bullock 4ce953
      m_leftLayout->setSpacing(0);
Jeremy Bullock 4ce953
      m_toggleStatus = 1;
Jeremy Bullock 4ce953
    }
Jeremy Bullock 4ce953
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onCurveChanged(bool isDragging) {
Shinya Kitaoka 120a6e
  if (m_objectHandle) m_objectHandle->notifyObjectIdChanged(isDragging);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // emit signal if the current channel belongs to Fx in order to update the
Shinya Kitaoka 120a6e
  // preview fx
Shinya Kitaoka 120a6e
  if (m_fxHandle) {
Shinya Kitaoka 120a6e
    FunctionTreeModel *ftModel =
Shinya Kitaoka 120a6e
        dynamic_cast<functiontreemodel *="">(m_treeView->model());</functiontreemodel>
Shinya Kitaoka 120a6e
    if (ftModel) {
Shinya Kitaoka 120a6e
      FunctionTreeModel::Channel *currChan = ftModel->getCurrentChannel();
Shinya Kitaoka 120a6e
      if (currChan) {
Shinya Kitaoka 120a6e
        //カレントチャンネルがFxChannelGroupに含まれていたらEmit
Shinya Kitaoka 120a6e
        FxChannelGroup *fxChanGroup =
Shinya Kitaoka 120a6e
            dynamic_cast<fxchannelgroup *="">(currChan->getChannelGroup());</fxchannelgroup>
Shinya Kitaoka 120a6e
        if (fxChanGroup) m_fxHandle->notifyFxChanged();
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onCurveSelected(TDoubleParam *curve) {
Shinya Kitaoka 120a6e
  m_curve = curve;
Shinya Kitaoka 120a6e
  m_toolbar->setCurve(curve);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QPair<tdoubleparam *,="" int=""> selectedSegment =</tdoubleparam>
Shinya Kitaoka 120a6e
      getSelection()->getSelectedSegment();
Shinya Kitaoka 120a6e
  if (selectedSegment.first)
Shinya Kitaoka 120a6e
    m_segmentViewer->setSegment(selectedSegment.first, selectedSegment.second);
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_segmentViewer->setSegment(m_curve, -1);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onValueFieldChanged() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onXsheetChanged() {
Shinya Kitaoka 120a6e
  TXsheet *xsh = m_xshHandle->getXsheet();
Shinya Kitaoka 120a6e
  int rowCount = xsh->getFrameCount();
Shinya Kitaoka 120a6e
  m_numericalColumns->setRowCount(rowCount);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onStageObjectSwitched() {
Shinya Kitaoka 120a6e
  TXsheet *xsh = m_xshHandle->getXsheet();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TStageObjectId &objId = m_objectHandle->getObjectId();
Shinya Kitaoka 120a6e
  TStageObject *obj           = (objId == TStageObjectId::NoneId)
Shinya Kitaoka 120a6e
                          ? (TStageObject *)0
Shinya Kitaoka 120a6e
                          : xsh->getStageObject(objId);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static_cast<functiontreemodel *="">(m_treeView->model())</functiontreemodel>
Shinya Kitaoka 120a6e
      ->setCurrentStageObject(obj);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_treeView->updateAll();
Shinya Kitaoka 120a6e
  m_functionGraph->update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onStageObjectChanged(bool isDragging) {
Shinya Kitaoka 120a6e
  TXsheet *xsh = m_xshHandle->getXsheet();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TStageObjectId &objId = m_objectHandle->getObjectId();
Shinya Kitaoka 120a6e
  TStageObject *obj           = (objId == TStageObjectId::NoneId)
Shinya Kitaoka 120a6e
                          ? (TStageObject *)0
Shinya Kitaoka 120a6e
                          : xsh->getStageObject(objId);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static_cast<functiontreemodel *="">(m_treeView->model())</functiontreemodel>
Shinya Kitaoka 120a6e
      ->setCurrentStageObject(obj);
Toshihiro Shimizu 890ddd
shun_iwasawa 768e20
  if (!isDragging) {
shun_iwasawa 768e20
    m_treeView->updateAll();
shun_iwasawa 768e20
    m_numericalColumns->updateAll();
shun_iwasawa 768e20
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_functionGraph->update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onFxSwitched() {
Shinya Kitaoka 120a6e
  TFx *fx              = m_fxHandle->getFx();
Shinya Kitaoka 120a6e
  TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
shun-iwasawa 4a3868
  if (zfx) fx = zfx->getZeraryFx();
Shinya Kitaoka 120a6e
  static_cast<functiontreemodel *="">(m_treeView->model())->setCurrentFx(fx);</functiontreemodel>
Shinya Kitaoka 120a6e
  m_treeView->updateAll();
Shinya Kitaoka 120a6e
  m_functionGraph->update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::onSelectionChanged() {
Shinya Kitaoka 120a6e
  QPair<tdoubleparam *,="" int=""> selectedSegment =</tdoubleparam>
Shinya Kitaoka 120a6e
      getSelection()->getSelectedSegment();
Shinya Kitaoka 120a6e
  if (selectedSegment.first) {
Shinya Kitaoka 120a6e
    if (selectedSegment.first != m_curve) {
Shinya Kitaoka 120a6e
      m_curve = selectedSegment.first;
Shinya Kitaoka 120a6e
      m_toolbar->setCurve(selectedSegment.first);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_segmentViewer->setSegment(selectedSegment.first, selectedSegment.second);
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    m_segmentViewer->setSegment(m_curve, -1);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  // update curves
Shinya Kitaoka 120a6e
  if (m_functionGraph->isVisible() && !m_functionGraph->hasFocus())
Shinya Kitaoka 120a6e
    m_functionGraph->update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::doSwitchCurrentObject(TStageObject *obj) {
Shinya Kitaoka 120a6e
  TStageObjectId id = obj->getId();
Shinya Kitaoka 120a6e
  if (id.isColumn())
Shinya Kitaoka 120a6e
    m_columnHandle->setColumnIndex(id.getIndex());
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_objectHandle->setObjectId(id);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::doSwitchCurrentFx(TFx *fx) {
Shinya Kitaoka 120a6e
  if (!fx) {
Shinya Kitaoka 120a6e
    m_fxHandle->setFx(0);
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (fx->isZerary()) {
Shinya Kitaoka 120a6e
    TXsheet *xsh = m_xshHandle->getXsheet();
Shinya Kitaoka 120a6e
    int i, columnCount = xsh->getColumnCount();
Shinya Kitaoka 120a6e
    for (i = 0; i < columnCount; i++) {
Shinya Kitaoka 120a6e
      TXshColumn *column = xsh->getColumn(i);
Shinya Kitaoka 120a6e
      TXshZeraryFxColumn *zfx =
Shinya Kitaoka 120a6e
          dynamic_cast<txshzeraryfxcolumn *="">(xsh->getColumn(i));</txshzeraryfxcolumn>
Shinya Kitaoka 120a6e
      if (!zfx) continue;
Shinya Kitaoka 120a6e
      if (zfx->getZeraryColumnFx()->getZeraryFx() == fx) {
Shinya Kitaoka 120a6e
        fx = zfx->getZeraryColumnFx();
Shinya Kitaoka 120a6e
        m_columnHandle->setColumnIndex(i);
Shinya Kitaoka 120a6e
        break;
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  // Forbid update of the swatch upon column switch. This would generate
Shinya Kitaoka 120a6e
  // a useless render...
Shinya Kitaoka 120a6e
  SwatchViewer::suspendRendering(true, false);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int columnIndex = fx->getReferenceColumnIndex();
Shinya Kitaoka 120a6e
  if (columnIndex >= 0) m_columnHandle->setColumnIndex(columnIndex);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  SwatchViewer::suspendRendering(false);
Shinya Kitaoka 120a6e
  m_fxHandle->setFx(fx);
Shinya Kitaoka 120a6e
  emit editObject();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::propagateExternalSetFrame() {
Shinya Kitaoka 120a6e
  assert(m_frameHandle);
Shinya Kitaoka 120a6e
  m_localFrame.setFrame(m_frameHandle->getFrame());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::addParameter(TParam *parameter, const TFilePath &folder) {
Shinya Kitaoka 120a6e
  static_cast<functiontreemodel *="">(m_treeView->model())</functiontreemodel>
Shinya Kitaoka 120a6e
      ->addParameter(parameter, folder);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::setFocusColumnsOrGraph() {
Shinya Kitaoka 120a6e
  m_numericalColumns->setFocus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::clearFocusColumnsAndGraph() {
Shinya Kitaoka 120a6e
  m_functionGraph->clearFocus();
Shinya Kitaoka 120a6e
  m_numericalColumns->clearFocus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool FunctionViewer::columnsOrGraphHasFocus() {
Shinya Kitaoka 120a6e
  return m_functionGraph->hasFocus() ||
Shinya Kitaoka 120a6e
         m_numericalColumns->anyWidgetHasFocus() ||
Shinya Kitaoka 120a6e
         m_toolbar->anyWidgetHasFocus() || m_segmentViewer->anyWidgetHasFocus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FunctionViewer::setSceneHandle(TSceneHandle *sceneHandle) {
Shinya Kitaoka 120a6e
  m_sceneHandle = sceneHandle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool FunctionViewer::isExpressionPageActive() {
Shinya Kitaoka 120a6e
  return m_segmentViewer->isExpressionPageActive();
Toshihiro Shimizu 890ddd
}
Jeremy Bullock 4ce953
Jeremy Bullock 4ce953
//----------------------------------------------------------------------------
Jeremy Bullock 4ce953
Jeremy Bullock 4ce953
void FunctionViewer::save(QSettings &settings) const {
Jeremy Bullock 4ce953
  settings.setValue("toggleStatus", m_toggleStatus);
shun-iwasawa 260cd7
  settings.setValue("showIbtwnValuesInSheet",
shun-iwasawa 260cd7
                    m_numericalColumns->isIbtwnValueVisible());
Jeremy Bullock 4ce953
}
Jeremy Bullock 4ce953
Jeremy Bullock 4ce953
//----------------------------------------------------------------------------
Jeremy Bullock 4ce953
Jeremy Bullock 4ce953
void FunctionViewer::load(QSettings &settings) {
Jeremy Bullock 4ce953
  QVariant toggleStatus = settings.value("toggleStatus");
Jeremy Bullock 4ce953
  if (toggleStatus.canConvert(QVariant::Int)) {
Jeremy Bullock 4ce953
    m_toggleStatus = toggleStatus.toInt();
Jeremy Bullock 4ce953
  }
shun-iwasawa 260cd7
shun-iwasawa 260cd7
  bool ibtwnVisible = settings
shun-iwasawa 260cd7
                          .value("showIbtwnValuesInSheet",
shun-iwasawa 260cd7
                                 m_numericalColumns->isIbtwnValueVisible())
shun-iwasawa 260cd7
                          .toBool();
shun-iwasawa 260cd7
  m_numericalColumns->setIbtwnValueVisible(ibtwnVisible);
Jeremy Bullock 4ce953
}
shun-iwasawa 2ce475
shun-iwasawa 2ce475
//-----------------------------------------------------------------------------
shun-iwasawa 2ce475
shun-iwasawa 2ce475
QColor FunctionViewer::getCurrentTextColor() const {
shun-iwasawa 2ce475
  // get colors
shun-iwasawa 2ce475
  TPixel currentColumnPixel;
shun-iwasawa 2ce475
  Preferences::instance()->getCurrentColumnData(currentColumnPixel);
shun-iwasawa 2ce475
  QColor currentColumnColor((int)currentColumnPixel.r,
shun-iwasawa 2ce475
                            (int)currentColumnPixel.g,
shun-iwasawa 2ce475
                            (int)currentColumnPixel.b, 255);
shun-iwasawa 2ce475
  return currentColumnColor;
shun-iwasawa 2ce475
}