2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
|
|
|
|
#include "toonzqt/functionviewer.h"
|
|
|
|
|
|
|
|
// TnzQt includes
|
|
|
|
#include "toonzqt/functionselection.h"
|
|
|
|
#include "toonzqt/functionpanel.h"
|
|
|
|
#include "toonzqt/functiontreeviewer.h"
|
|
|
|
#include "toonzqt/functionsheet.h"
|
|
|
|
#include "toonzqt/functionsegmentviewer.h"
|
|
|
|
#include "toonzqt/functiontoolbar.h"
|
|
|
|
#include "toonzqt/swatchviewer.h"
|
|
|
|
#include "toonzqt/dvscrollwidget.h"
|
|
|
|
|
|
|
|
// TnzLib includes
|
|
|
|
#include "toonz/tstageobjecttree.h"
|
|
|
|
#include "toonz/txsheet.h"
|
|
|
|
#include "toonz/txsheethandle.h"
|
|
|
|
#include "toonz/tobjecthandle.h"
|
|
|
|
#include "toonz/tfxhandle.h"
|
2016-03-27 13:30:32 +13:00
|
|
|
#include "toonz/tcolumnhandle.h"
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "toonz/fxdag.h"
|
|
|
|
#include "toonz/txshzeraryfxcolumn.h"
|
|
|
|
#include "toonz/tcolumnfx.h"
|
|
|
|
#include "toonz/toonzscene.h"
|
|
|
|
#include "toonz/tproject.h"
|
|
|
|
#include "toonz/tscenehandle.h"
|
|
|
|
#include "toonz/sceneproperties.h"
|
|
|
|
|
|
|
|
// TnzBase includes
|
|
|
|
#include "tparamcontainer.h"
|
|
|
|
#include "tunit.h"
|
2018-03-22 20:32:19 +13:00
|
|
|
#include "tenv.h"
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
// TnzCore includes
|
|
|
|
#include "tstopwatch.h"
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QWheelEvent>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QStackedWidget>
|
|
|
|
#include <QLabel>
|
2016-03-27 13:30:32 +13:00
|
|
|
#include <QToolBar>
|
2016-03-19 06:57:51 +13:00
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
using namespace DVGui;
|
|
|
|
|
2020-05-23 09:31:30 +12:00
|
|
|
TEnv::IntVar FunctionEditorToggleStatus("FunctionEditorToggleStatus", 1);
|
2018-03-22 20:32:19 +13:00
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// FunctionPanel
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if QT_VERSION >= 0x050500
|
|
|
|
FunctionViewer::FunctionViewer(QWidget *parent, Qt::WindowFlags flags)
|
|
|
|
#else
|
|
|
|
FunctionViewer::FunctionViewer(QWidget *parent, Qt::WFlags flags)
|
|
|
|
#endif
|
2016-06-15 18:43:10 +12:00
|
|
|
: QSplitter(parent)
|
|
|
|
, m_xshHandle(0)
|
|
|
|
, m_frameHandle(0)
|
|
|
|
, m_objectHandle(0)
|
|
|
|
, m_fxHandle(0)
|
|
|
|
, m_columnHandle(0)
|
|
|
|
, m_curve(0)
|
|
|
|
, m_selection(new FunctionSelection())
|
|
|
|
, m_sceneHandle(0) {
|
|
|
|
setObjectName("FunctionEditor");
|
|
|
|
|
|
|
|
// Prepare local timeline
|
|
|
|
m_localFrame.setFrame(0);
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
2018-03-22 20:32:19 +13:00
|
|
|
m_toggleStart = Preferences::instance()->getFunctionEditorToggle();
|
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup) {
|
|
|
|
m_functionGraph = new FunctionPanel(this, false);
|
|
|
|
m_numericalColumns = new FunctionSheet(this, true);
|
|
|
|
} else if (m_toggleStart == Preferences::FunctionEditorToggle::
|
|
|
|
ToggleBetweenGraphAndSpreadsheet) {
|
|
|
|
m_functionGraph = new FunctionPanel(this, false);
|
|
|
|
m_numericalColumns = new FunctionSheet(this, false);
|
|
|
|
} else {
|
|
|
|
// default values are graph is floating
|
|
|
|
// and spreadsheet is not floating
|
|
|
|
m_functionGraph = new FunctionPanel(this);
|
|
|
|
m_numericalColumns = new FunctionSheet(this);
|
|
|
|
}
|
|
|
|
m_treeView = new FunctionTreeView(this);
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2018-03-22 20:32:19 +13:00
|
|
|
m_toolbar = new FunctionToolbar;
|
2016-06-15 18:43:10 +12:00
|
|
|
m_segmentViewer =
|
|
|
|
new FunctionSegmentViewer(this, m_numericalColumns, m_functionGraph);
|
|
|
|
QWidget *leftPanel = new QWidget();
|
|
|
|
QWidget *rightPanel = new QWidget();
|
|
|
|
|
|
|
|
//----
|
|
|
|
m_treeView->resize(150, m_treeView->size().height());
|
|
|
|
m_treeView->setMinimumWidth(0);
|
UI update and Icons from Konero (#126)
* add multi arc mockup
* implement mutli arc
* add join and smooth option
* reset multiarc and arc when deactivated
* create self loop if the last point is the same as the first
* make join option in multiarc consistent with tape tool
* fix a bug where thickness don't affect mutliarc in vector level
* remove join option in geometric tool
* stop mutliarc after closing shape
* double click can also end multi arc
* fix a bug where multiArc will produce buggy stroke
* fix a bug where geometric tools is not deactivated
* add multiArc shortcut
* rewrite multiArc
* revert changes to tvectorimage
* add undo data for multiArc
* Paste as Copy Command for XSheet
* Remove unneeded code
* Bug fix
* prevent guide lines from jumping around in MultiArc
* make stroke color consistent in MultiArc
* remove color in MultiArc's undo data
* make color consistent in MultiArc with previous version
* Fix single image raster levels
* fix compilation error
* fix a bug where multiArc might generate bugged stroke
* Remove ICONV dep (#3304)
* fix crash on saving studio palette
* Move to Paste Special Menu
* Don't Set Fixed Width if Docking a Floating Panel
* Update how_to_build_win.md
New draft of pr for requested changes to windows build instructions.
* fix geometric tool multiarc smooth option
* fix level saving failure
* fix wrong warning after saving palette
* fix a bug where moving a control point while holding alt has unintended result
* fix travis-install (#3389)
* Fix assert debug crash in flipconsole.cpp
Fix crash when using the viewer controls in the console (debug)
* Redraw Audio Waveform
Fills the waveform rather than outlines it.
* Update .gitignore
* fix undo data when drawing arc and mutliarc
* fix overwriting raster drawing palette (#3387)
* mode sensitive fx settings
* Create New Style Command Button (#3394)
* Create New Style Command Button
This PR creates a new button in the pallette editor that creates a new style. Button is large and easy access for a faster and easier workflow. Original code developed by Turtletooth for Tahoma. Given permission to develop within Openoonz.
Co-Authored-By: Jeremy Bullock <turtletooth@users.noreply.github.com>
* Update paletteviewergui.cpp
Made changes to the PR per request by Shun.
* Fixed a space within the code that wasn't suppose to be there.
Co-authored-by: Jeremy Bullock <turtletooth@users.noreply.github.com>
* tahoma license (#3396)
* new style button optional
* fix loading pegbars (removing updateKeyframes)
* periodic random expression
* add fx in linear color space
this commit is based on source for the ComposeAdd plugin fx by DWANGO Co., Ltd.
in dwango_opentoonz_plugins and opentoonz_plugin_utility repositories.
* fractal noise iwa fx
* skip unnecessary icon invalidation
* fix frame range fill with tablet
* stop function editor to open by dbl clicking key
* Expanding the radius of the rotation handle.
This just changes when the cursor transforms into the rotation tool.
(cherry picked from commit 7722ae989bbdc6aa5cb48df7a4c08bae1fe6ea39)
* fix vector img patern stroke style
* Update Stylesheets
- Support the new icon sizes
- XSheet and Timeline significantly redesigned
- Lots of margin fixes and refactoring
- Remove deprecated icons, as some icons are moved into binary
- New Light theme
* New Icons
- Redesigns almost every icon as symbolic
- Adds icons for most commands
* Add Option for Icon Themes
- Adds option for icon themes
- Removes useless label from Preferences category list
* Update Icon Functions
- Adds themePath() boolean
- Adds function for recoloring black pixels in pixmaps to any color
- Rebuilds createQIcon to use fromTheme() and recolorPixmap()
- Removes createQIconOnOff as it seemed to be a rarely used duplicate of createQIcon
- Removes a grey horizontal line drawn above the console play bar in the viewer
* Set Default Icon Theme and Paths
- Sets search paths for icons for use with QIcon::fromTheme()
- Sets default start icon theme on first install
- Sets flag for displaying icons in menus, so we can selectively hide them
* Set Icons for Commands
- Sets icons for the commands
- Hides icons being displayed in menus as most icons are 20x20, they will look blurry when shrunk to 16x16
- Selectively allows icons to display for Tools in menus
* Change Icon Sizes, General Fixes and Stylesheet Additions
- Change icon sizes to new size
- Remove margin around FX Editor window
- Remove white line under color sliders in Style Editor
- Make keyframe icons uniform and color stylable in the stylesheets
- Removes deprecated stylesheet strings
- Redesign GUI for palette list view
- Make tree list header sort row stylable
- Remove black lines from scrollbars in New Project window
- Remove margin around combobox in Level Strip
- Alter how some lines are drawn in the Timeline to fix some alpha issues
- Make conditional fixed onion skin and normal onion skin dots contrast more against a light background area to make sure they have good visibility
- Make text always viewable in the FPS field in console bar
- Increase size of radio buttons in Cleanup Settings
- Increase size of switches in motion path nodes
- Remove unessesary "Layer" label in Timeline and other rects
- Various colors made stylable in the stylesheets; palette numpad and selection frame, cleanup settings border, scene cast folder path, schematic lines, ruler, xsheet lines, keyframes, cell input box and more
- Moves some external stylesheet icons into binary
* Make TPanelTitleBar Icon States Stylable
- Makes icon states for TPanelTitleBar buttons stylable in stylesheets
* Travis Fixes
* Swap Startup Popup Logos
They were in the wrong folders
* Revert "Swap Startup Popup Logos"
This reverts commit 815908a9f3e725f48507dab8a2270bdfa045649d.
* Fix Startup Popup Logo
It wasn't switching
* Feedback Changes
- Change render visualization to clapboard
- Fix text contrast on levels in XSheet
* Make Cell Selection More Clear
* Darken Light Theme and Tint Empty Cell Selection
* Fix missing icons
* Fix memo button
* Bring back colors
* Hide Motion Tab
* Fix Play Range Area (Light)
Make play range area more visible
* Vector Column Color
Co-authored-by: pojienie <pojienie@gmail.com>
Co-authored-by: rim <11380091+rozhuk-im@users.noreply.github.com>
Co-authored-by: shun-iwasawa <shun.iwasawa@ghibli.jp>
Co-authored-by: Rodney <rodney.baker@gmail.com>
Co-authored-by: DoctorRyan <65507211+DoctorRyan@users.noreply.github.com>
Co-authored-by: shun-iwasawa <shun-iwasawa@users.noreply.github.com>
Co-authored-by: Kite <konero@users.noreply.github.com>
Co-authored-by: Jeremy Bullock <turtletooth@users.noreply.github.com>
Co-authored-by: DoctorRyan <doctorryan1969.gmail.com>
2020-09-01 06:51:22 +12:00
|
|
|
m_treeView->setIconSize(QSize(21, 18));
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
FunctionTreeModel *ftModel =
|
|
|
|
dynamic_cast<FunctionTreeModel *>(m_treeView->model());
|
|
|
|
m_functionGraph->setModel(ftModel);
|
|
|
|
m_numericalColumns->setModel(ftModel);
|
|
|
|
|
|
|
|
m_functionGraph->setSelection(getSelection());
|
|
|
|
m_numericalColumns->setSelection(getSelection());
|
|
|
|
|
|
|
|
m_numericalColumns->setViewer(this);
|
|
|
|
|
|
|
|
m_toolbar->setSelection(m_selection);
|
|
|
|
m_toolbar->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
|
|
|
m_toolbar->setFrameHandle(
|
|
|
|
&m_localFrame); // The function editor adopts an internal timeline
|
|
|
|
m_functionGraph->setFrameHandle(
|
|
|
|
&m_localFrame); // synchronized among its various sub-widgets.
|
|
|
|
m_numericalColumns->setFrameHandle(
|
|
|
|
&m_localFrame); // In case an external m_frameHandle is specified,
|
|
|
|
// it synchronizes with that, too.
|
|
|
|
|
|
|
|
//---- layout
|
|
|
|
|
2021-08-23 21:01:37 +12:00
|
|
|
QString layout = Preferences::instance()->getLoadedXsheetLayout();
|
|
|
|
bool toolBarOnBottom =
|
|
|
|
layout == QString("Minimum") &&
|
|
|
|
Preferences::instance()->isExpandFunctionHeaderEnabled() &&
|
|
|
|
m_toggleStart !=
|
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup;
|
|
|
|
|
2017-06-02 19:18:05 +12:00
|
|
|
m_leftLayout = new QVBoxLayout();
|
|
|
|
m_leftLayout->setMargin(0);
|
|
|
|
m_leftLayout->setSpacing(0);
|
2016-06-15 18:43:10 +12:00
|
|
|
{
|
2021-08-23 21:01:37 +12:00
|
|
|
if (!toolBarOnBottom) m_leftLayout->addWidget(m_toolbar);
|
|
|
|
m_spacing = 35;
|
|
|
|
if (layout == QString("Compact"))
|
|
|
|
m_spacing -= 18;
|
|
|
|
else if (toolBarOnBottom) {
|
|
|
|
m_spacing = 3; // m_spacing is used for the height of spacer widget
|
|
|
|
m_leftLayout->addSpacing(m_spacing);
|
|
|
|
}
|
2018-03-22 20:32:19 +13:00
|
|
|
|
|
|
|
if (m_toggleStart !=
|
|
|
|
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup)
|
|
|
|
m_leftLayout->addWidget(m_functionGraph);
|
|
|
|
if (m_toggleStart !=
|
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
|
|
|
|
m_leftLayout->addWidget(m_numericalColumns);
|
2021-08-23 21:01:37 +12:00
|
|
|
// display the toolbar on the bottom in Minimum layout
|
|
|
|
if (toolBarOnBottom) m_leftLayout->addWidget(m_toolbar);
|
2016-06-15 18:43:10 +12:00
|
|
|
}
|
2018-03-22 20:32:19 +13:00
|
|
|
|
2017-06-02 19:18:05 +12:00
|
|
|
leftPanel->setLayout(m_leftLayout);
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
QVBoxLayout *rightLayout = new QVBoxLayout();
|
|
|
|
rightLayout->setMargin(0);
|
|
|
|
rightLayout->setSpacing(5);
|
|
|
|
{
|
|
|
|
rightLayout->addWidget(m_treeView, 1);
|
2020-05-23 09:31:30 +12:00
|
|
|
rightLayout->addWidget(m_segmentViewer, 0);
|
2016-06-15 18:43:10 +12:00
|
|
|
}
|
|
|
|
rightPanel->setLayout(rightLayout);
|
|
|
|
|
|
|
|
addWidget(rightPanel);
|
2020-05-23 09:31:30 +12:00
|
|
|
addWidget(leftPanel);
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
//--- set the splitter's default size
|
2020-05-23 09:31:30 +12:00
|
|
|
setSizes(QList<int>() << 200 << 500);
|
|
|
|
setStretchFactor(1, 5);
|
|
|
|
setStretchFactor(0, 2);
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
//---- signal-slot connections
|
|
|
|
bool ret = true;
|
|
|
|
ret = ret && connect(m_toolbar, SIGNAL(numericalColumnToggled()), this,
|
|
|
|
SLOT(toggleMode()));
|
2020-04-17 19:02:53 +12:00
|
|
|
ret = ret && connect(ftModel, SIGNAL(activeChannelsChanged()),
|
2016-06-15 18:43:10 +12:00
|
|
|
m_functionGraph, SLOT(update()));
|
2020-04-17 19:02:53 +12:00
|
|
|
ret = ret && connect(ftModel, SIGNAL(activeChannelsChanged()),
|
2016-06-15 18:43:10 +12:00
|
|
|
m_numericalColumns, SLOT(updateAll()));
|
2020-04-17 19:02:53 +12:00
|
|
|
ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_treeView,
|
2016-06-15 18:43:10 +12:00
|
|
|
SLOT(update()));
|
|
|
|
ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_functionGraph,
|
|
|
|
SLOT(update()));
|
|
|
|
ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_numericalColumns,
|
|
|
|
SLOT(updateAll()));
|
|
|
|
ret = ret && connect(ftModel, SIGNAL(curveSelected(TDoubleParam *)), this,
|
|
|
|
SLOT(onCurveSelected(TDoubleParam *)));
|
|
|
|
ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), m_segmentViewer,
|
|
|
|
SLOT(onCurveChanged()));
|
|
|
|
ret = ret && connect(ftModel, SIGNAL(curveChanged(bool)), this,
|
|
|
|
SLOT(onCurveChanged(bool)));
|
|
|
|
ret = ret && connect(&m_localFrame, SIGNAL(frameSwitched()), this,
|
|
|
|
SLOT(onFrameSwitched()));
|
|
|
|
ret = ret && connect(getSelection(), SIGNAL(selectionChanged()), this,
|
|
|
|
SLOT(onSelectionChanged()));
|
|
|
|
ret = ret && connect(m_functionGraph, SIGNAL(keyframeSelected(double)),
|
|
|
|
m_toolbar, SLOT(setFrame(double)));
|
|
|
|
|
|
|
|
ret = ret && connect(m_treeView, SIGNAL(switchCurrentObject(TStageObject *)),
|
|
|
|
this, SLOT(doSwitchCurrentObject(TStageObject *)));
|
|
|
|
ret = ret && connect(m_treeView, SIGNAL(switchCurrentFx(TFx *)), this,
|
|
|
|
SLOT(doSwitchCurrentFx(TFx *)));
|
2020-05-23 09:31:30 +12:00
|
|
|
ret = ret && connect(m_treeView, SIGNAL(fit()), m_functionGraph,
|
|
|
|
SLOT(onFitCalled()));
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
ret = ret &&
|
|
|
|
connect(ftModel,
|
|
|
|
SIGNAL(currentChannelChanged(FunctionTreeModel::Channel *)),
|
|
|
|
m_numericalColumns,
|
|
|
|
SLOT(onCurrentChannelChanged(FunctionTreeModel::Channel *)));
|
|
|
|
|
|
|
|
assert(ret);
|
2018-03-22 20:32:19 +13:00
|
|
|
if (m_toggleStart ==
|
2021-08-23 21:01:37 +12:00
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup) {
|
2018-03-22 20:32:19 +13:00
|
|
|
m_numericalColumns->hide();
|
2021-08-23 21:01:37 +12:00
|
|
|
if (QSpacerItem *spacer = m_leftLayout->itemAt(0)->spacerItem())
|
|
|
|
spacer->changeSize(0, 0);
|
|
|
|
} else {
|
|
|
|
bool toolBarVisible =
|
|
|
|
Preferences::instance()->isShowQuickToolbarEnabled() &&
|
|
|
|
Preferences::instance()->isExpandFunctionHeaderEnabled();
|
|
|
|
if (QSpacerItem *spacer = m_leftLayout->itemAt(0)->spacerItem()) {
|
|
|
|
spacer->changeSize(1, m_spacing + ((toolBarVisible) ? 10 : 0),
|
|
|
|
QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
spacer->invalidate();
|
|
|
|
} else
|
|
|
|
m_leftLayout->setSpacing(m_spacing + ((toolBarVisible) ? 30 : 0));
|
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup) {
|
|
|
|
m_functionGraph->hide();
|
|
|
|
}
|
|
|
|
}
|
2020-05-23 09:31:30 +12:00
|
|
|
m_toggleStatus = FunctionEditorToggleStatus;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionViewer::~FunctionViewer() {
|
|
|
|
delete m_selection;
|
|
|
|
m_toolbar->setFrameHandle(0);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::showEvent(QShowEvent *) {
|
|
|
|
refreshModel();
|
|
|
|
|
|
|
|
// Connect handles
|
|
|
|
bool ret = true;
|
|
|
|
|
|
|
|
if (m_xshHandle) {
|
2021-08-23 21:01:37 +12:00
|
|
|
ret = ret && connect(m_xshHandle, SIGNAL(xsheetChanged()), this,
|
|
|
|
SLOT(refreshModel()));
|
|
|
|
ret = ret && connect(m_xshHandle, SIGNAL(xsheetSwitched()), this,
|
|
|
|
SLOT(rebuildModel()));
|
2016-06-15 18:43:10 +12:00
|
|
|
}
|
|
|
|
|
2019-08-27 15:55:22 +12:00
|
|
|
if (m_frameHandle) {
|
2021-08-23 21:01:37 +12:00
|
|
|
ret = ret && connect(m_frameHandle, SIGNAL(frameSwitched()), this,
|
|
|
|
SLOT(propagateExternalSetFrame()));
|
|
|
|
ret = ret && connect(m_frameHandle, SIGNAL(triggerNextKeyframe(QWidget *)),
|
|
|
|
m_toolbar, SLOT(onNextKeyframe(QWidget *)));
|
|
|
|
ret = ret && connect(m_frameHandle, SIGNAL(triggerPrevKeyframe(QWidget *)),
|
|
|
|
m_toolbar, SLOT(onPrevKeyframe(QWidget *)));
|
2019-08-27 15:55:22 +12:00
|
|
|
}
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_objectHandle) {
|
2021-08-23 21:01:37 +12:00
|
|
|
ret = ret && connect(m_objectHandle, SIGNAL(objectSwitched()), this,
|
|
|
|
SLOT(onStageObjectSwitched()));
|
|
|
|
ret = ret && connect(m_objectHandle, SIGNAL(objectChanged(bool)), this,
|
|
|
|
SLOT(onStageObjectChanged(bool)));
|
2016-06-15 18:43:10 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_fxHandle)
|
2021-08-23 21:01:37 +12:00
|
|
|
ret = ret &&
|
|
|
|
connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched()));
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
// display animated channels when the scene is switched
|
2021-08-23 21:01:37 +12:00
|
|
|
if (m_sceneHandle) {
|
|
|
|
ret = ret && connect(m_sceneHandle, SIGNAL(sceneSwitched()), m_treeView,
|
|
|
|
SLOT(displayAnimatedChannels()));
|
|
|
|
ret = ret &&
|
|
|
|
connect(m_sceneHandle, SIGNAL(preferenceChanged(const QString &)),
|
|
|
|
this, SLOT(onPreferenceChanged(const QString &)));
|
|
|
|
}
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
assert(ret);
|
|
|
|
|
|
|
|
m_treeView->setExpanded(m_treeView->model()->index(0, 0), true);
|
|
|
|
m_treeView->setExpanded(m_treeView->model()->index(1, 0), true);
|
|
|
|
|
|
|
|
FunctionTreeModel *ftm =
|
|
|
|
static_cast<FunctionTreeModel *>(m_treeView->model());
|
|
|
|
|
|
|
|
if (m_objectHandle) {
|
|
|
|
assert(m_xshHandle);
|
|
|
|
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
|
|
|
|
|
|
const TStageObjectId &objId = m_objectHandle->getObjectId();
|
|
|
|
ftm->setCurrentStageObject((objId == TStageObjectId::NoneId)
|
|
|
|
? (TStageObject *)0
|
|
|
|
: xsh->getStageObject(objId));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_fxHandle) ftm->setCurrentFx(m_fxHandle->getFx());
|
2021-08-23 21:01:37 +12:00
|
|
|
onPreferenceChanged("");
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::hideEvent(QHideEvent *) {
|
|
|
|
if (m_xshHandle) m_xshHandle->disconnect(this);
|
2019-08-27 15:55:22 +12:00
|
|
|
if (m_frameHandle) {
|
|
|
|
m_frameHandle->disconnect(this);
|
|
|
|
m_frameHandle->disconnect(m_toolbar);
|
|
|
|
}
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_objectHandle) m_objectHandle->disconnect(this);
|
|
|
|
if (m_fxHandle) m_fxHandle->disconnect(this);
|
|
|
|
if (m_sceneHandle) m_sceneHandle->disconnect(this);
|
2018-03-22 20:32:19 +13:00
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup) {
|
|
|
|
if (m_functionGraph->isVisible()) m_functionGraph->hide();
|
|
|
|
}
|
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup) {
|
|
|
|
if (m_numericalColumns->isVisible()) m_numericalColumns->hide();
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::openContextMenu(TreeModel::Item *item,
|
|
|
|
const QPoint &globalPos) {
|
|
|
|
m_treeView->openContextMenu(item, globalPos);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::rebuildModel() {
|
|
|
|
getSelection()->selectNone();
|
|
|
|
onCurveSelected(0);
|
|
|
|
m_functionGraph->getModel()->resetAll();
|
|
|
|
refreshModel();
|
|
|
|
m_treeView->displayAnimatedChannels();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::refreshModel() {
|
|
|
|
TXsheet *xsh = m_xshHandle ? m_xshHandle->getXsheet() : 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_functionGraph->getModel()->refreshData(xsh);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (xsh) {
|
|
|
|
int rowCount = xsh->getFrameCount();
|
|
|
|
m_numericalColumns->setRowCount(rowCount);
|
|
|
|
m_numericalColumns->updateAll();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
ToonzScene *scene = xsh->getScene();
|
|
|
|
if (!scene) // This seems wrong. It should rather be
|
|
|
|
return; // asserted - though I'm not touching it now...
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TFilePath scenePath = scene->getScenePath().getParentDir();
|
|
|
|
if (scene->isUntitled())
|
|
|
|
scenePath =
|
|
|
|
TProjectManager::instance()->getCurrentProject()->getScenesPath();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_treeView->setCurrentScenePath(scenePath);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int distance, offset;
|
|
|
|
scene->getProperties()->getMarkers(distance, offset);
|
|
|
|
m_numericalColumns->setMarkRow(distance, offset);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_treeView->updateAll();
|
|
|
|
m_toolbar->setCurve(0);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::setXsheetHandle(TXsheetHandle *xshHandle) {
|
|
|
|
if (xshHandle == m_xshHandle) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_xshHandle) m_xshHandle->disconnect(this);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_xshHandle = xshHandle;
|
|
|
|
m_segmentViewer->setXsheetHandle(xshHandle);
|
2020-04-17 19:02:53 +12:00
|
|
|
m_treeView->setXsheetHandle(xshHandle);
|
2021-04-28 14:02:23 +12:00
|
|
|
m_numericalColumns->setXsheetHandle(xshHandle);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_xshHandle && isVisible()) {
|
|
|
|
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
|
|
m_functionGraph->getModel()->refreshData(xsh);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2017-06-02 19:18:05 +12:00
|
|
|
bool ret = connect(m_xshHandle, SIGNAL(xsheetChanged()), this,
|
|
|
|
SLOT(refreshModel()));
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(ret);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::setFrameHandle(TFrameHandle *frameHandle) {
|
|
|
|
if (m_frameHandle == frameHandle) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_frameHandle) m_frameHandle->disconnect(this);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_frameHandle = frameHandle;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_frameHandle && isVisible()) {
|
|
|
|
bool ret = connect(m_frameHandle, SIGNAL(frameSwitched()), this,
|
|
|
|
SLOT(propagateExternalSetFrame()));
|
|
|
|
assert(ret);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::setObjectHandle(TObjectHandle *objectHandle) {
|
|
|
|
if (objectHandle == m_objectHandle) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_objectHandle) m_objectHandle->disconnect(this);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_objectHandle = objectHandle;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_objectHandle && isVisible()) {
|
|
|
|
m_treeView->updateAll();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool ret = true;
|
|
|
|
ret = connect(m_objectHandle, SIGNAL(objectSwitched()), this,
|
|
|
|
SLOT(onStageObjectSwitched())) &&
|
|
|
|
ret;
|
|
|
|
ret = connect(m_objectHandle, SIGNAL(objectChanged(bool)), this,
|
|
|
|
SLOT(onStageObjectChanged(bool))) &&
|
|
|
|
ret;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(ret);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel *ftModel =
|
|
|
|
static_cast<FunctionTreeModel *>(m_treeView->model());
|
|
|
|
if (ftModel) ftModel->setObjectHandle(objectHandle);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::setFxHandle(TFxHandle *fxHandle) {
|
|
|
|
if (fxHandle == m_fxHandle) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_fxHandle) m_fxHandle->disconnect(this);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_fxHandle = fxHandle;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (isVisible()) {
|
|
|
|
m_treeView->updateAll();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool ret =
|
|
|
|
connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched()));
|
|
|
|
assert(ret);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel *ftModel =
|
|
|
|
static_cast<FunctionTreeModel *>(m_treeView->model());
|
|
|
|
if (ftModel) ftModel->setFxHandle(fxHandle);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::setColumnHandle(TColumnHandle *columnHandle) {
|
|
|
|
if (columnHandle == m_columnHandle) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_columnHandle = columnHandle;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (isVisible()) m_treeView->updateAll();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onFrameSwitched() {
|
|
|
|
int frame = m_localFrame.getFrame();
|
|
|
|
m_segmentViewer->setSegmentByFrame(m_curve, frame);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_frameHandle) m_frameHandle->setFrame(frame);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::toggleMode() {
|
|
|
|
if (isHidden()) return;
|
2018-03-22 20:32:19 +13:00
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup) {
|
|
|
|
if (m_functionGraph->isVisible()) {
|
|
|
|
m_functionGraph->hide();
|
|
|
|
} else {
|
|
|
|
m_functionGraph->show();
|
|
|
|
}
|
|
|
|
} else if (m_toggleStart == Preferences::FunctionEditorToggle::
|
|
|
|
ShowFunctionSpreadsheetInPopup) {
|
|
|
|
if (m_numericalColumns->isVisible()) {
|
|
|
|
m_numericalColumns->hide();
|
|
|
|
} else {
|
|
|
|
m_numericalColumns->show();
|
|
|
|
}
|
|
|
|
} else if (m_toggleStart == Preferences::FunctionEditorToggle::
|
|
|
|
ToggleBetweenGraphAndSpreadsheet) {
|
|
|
|
if (m_functionGraph->isVisible()) {
|
|
|
|
m_functionGraph->hide();
|
|
|
|
m_numericalColumns->show();
|
2021-03-06 17:23:08 +13:00
|
|
|
m_numericalColumns->setFocus();
|
2021-08-23 21:01:37 +12:00
|
|
|
bool toolBarVisible =
|
|
|
|
Preferences::instance()->isShowQuickToolbarEnabled() &&
|
|
|
|
Preferences::instance()->isExpandFunctionHeaderEnabled();
|
|
|
|
if (QSpacerItem *spacer = m_leftLayout->itemAt(0)->spacerItem()) {
|
|
|
|
spacer->changeSize(1, m_spacing + ((toolBarVisible) ? 10 : 0),
|
|
|
|
QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
spacer->invalidate();
|
|
|
|
m_numericalColumns->updateHeaderHeight();
|
|
|
|
m_leftLayout->setSpacing(0);
|
|
|
|
} else
|
|
|
|
m_leftLayout->setSpacing(m_spacing + ((toolBarVisible) ? 30 : 0));
|
|
|
|
updateGeometry();
|
2018-03-22 20:32:19 +13:00
|
|
|
m_toggleStatus = 0;
|
|
|
|
} else {
|
|
|
|
m_functionGraph->show();
|
2021-03-06 17:23:08 +13:00
|
|
|
m_functionGraph->setFocus();
|
2018-03-22 20:32:19 +13:00
|
|
|
m_numericalColumns->hide();
|
|
|
|
m_leftLayout->setSpacing(0);
|
2021-08-23 21:01:37 +12:00
|
|
|
if (QSpacerItem *spacer = m_leftLayout->itemAt(0)->spacerItem()) {
|
|
|
|
spacer->changeSize(0, 0);
|
|
|
|
spacer->invalidate();
|
|
|
|
}
|
2018-03-22 20:32:19 +13:00
|
|
|
m_toggleStatus = 1;
|
|
|
|
}
|
|
|
|
}
|
2020-05-23 09:31:30 +12:00
|
|
|
FunctionEditorToggleStatus = m_toggleStatus;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onCurveChanged(bool isDragging) {
|
|
|
|
if (m_objectHandle) m_objectHandle->notifyObjectIdChanged(isDragging);
|
|
|
|
|
|
|
|
// emit signal if the current channel belongs to Fx in order to update the
|
|
|
|
// preview fx
|
|
|
|
if (m_fxHandle) {
|
|
|
|
FunctionTreeModel *ftModel =
|
|
|
|
dynamic_cast<FunctionTreeModel *>(m_treeView->model());
|
|
|
|
if (ftModel) {
|
|
|
|
FunctionTreeModel::Channel *currChan = ftModel->getCurrentChannel();
|
|
|
|
if (currChan) {
|
|
|
|
//カレントチャンネルがFxChannelGroupに含まれていたらEmit
|
|
|
|
FxChannelGroup *fxChanGroup =
|
|
|
|
dynamic_cast<FxChannelGroup *>(currChan->getChannelGroup());
|
|
|
|
if (fxChanGroup) m_fxHandle->notifyFxChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-23 09:31:30 +12:00
|
|
|
m_toolbar->setCurve(m_curve);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onCurveSelected(TDoubleParam *curve) {
|
|
|
|
m_curve = curve;
|
|
|
|
m_toolbar->setCurve(curve);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QPair<TDoubleParam *, int> selectedSegment =
|
|
|
|
getSelection()->getSelectedSegment();
|
|
|
|
if (selectedSegment.first)
|
|
|
|
m_segmentViewer->setSegment(selectedSegment.first, selectedSegment.second);
|
|
|
|
else
|
|
|
|
m_segmentViewer->setSegment(m_curve, -1);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onValueFieldChanged() {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onXsheetChanged() {
|
|
|
|
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
|
|
int rowCount = xsh->getFrameCount();
|
|
|
|
m_numericalColumns->setRowCount(rowCount);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onStageObjectSwitched() {
|
|
|
|
TXsheet *xsh = m_xshHandle->getXsheet();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
const TStageObjectId &objId = m_objectHandle->getObjectId();
|
|
|
|
TStageObject *obj = (objId == TStageObjectId::NoneId)
|
|
|
|
? (TStageObject *)0
|
|
|
|
: xsh->getStageObject(objId);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static_cast<FunctionTreeModel *>(m_treeView->model())
|
|
|
|
->setCurrentStageObject(obj);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_treeView->updateAll();
|
|
|
|
m_functionGraph->update();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onStageObjectChanged(bool isDragging) {
|
|
|
|
TXsheet *xsh = m_xshHandle->getXsheet();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
const TStageObjectId &objId = m_objectHandle->getObjectId();
|
|
|
|
TStageObject *obj = (objId == TStageObjectId::NoneId)
|
|
|
|
? (TStageObject *)0
|
|
|
|
: xsh->getStageObject(objId);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static_cast<FunctionTreeModel *>(m_treeView->model())
|
|
|
|
->setCurrentStageObject(obj);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2019-07-01 19:42:08 +12:00
|
|
|
if (!isDragging) {
|
|
|
|
m_treeView->updateAll();
|
|
|
|
m_numericalColumns->updateAll();
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_functionGraph->update();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onFxSwitched() {
|
|
|
|
TFx *fx = m_fxHandle->getFx();
|
|
|
|
TZeraryColumnFx *zfx = dynamic_cast<TZeraryColumnFx *>(fx);
|
2020-04-17 19:02:53 +12:00
|
|
|
if (zfx) fx = zfx->getZeraryFx();
|
2016-06-15 18:43:10 +12:00
|
|
|
static_cast<FunctionTreeModel *>(m_treeView->model())->setCurrentFx(fx);
|
|
|
|
m_treeView->updateAll();
|
|
|
|
m_functionGraph->update();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::onSelectionChanged() {
|
|
|
|
QPair<TDoubleParam *, int> selectedSegment =
|
|
|
|
getSelection()->getSelectedSegment();
|
|
|
|
if (selectedSegment.first) {
|
|
|
|
if (selectedSegment.first != m_curve) {
|
|
|
|
m_curve = selectedSegment.first;
|
|
|
|
m_toolbar->setCurve(selectedSegment.first);
|
|
|
|
}
|
|
|
|
m_segmentViewer->setSegment(selectedSegment.first, selectedSegment.second);
|
|
|
|
} else {
|
|
|
|
m_segmentViewer->setSegment(m_curve, -1);
|
|
|
|
}
|
|
|
|
// update curves
|
|
|
|
if (m_functionGraph->isVisible() && !m_functionGraph->hasFocus())
|
|
|
|
m_functionGraph->update();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::doSwitchCurrentObject(TStageObject *obj) {
|
|
|
|
TStageObjectId id = obj->getId();
|
|
|
|
if (id.isColumn())
|
|
|
|
m_columnHandle->setColumnIndex(id.getIndex());
|
|
|
|
else
|
|
|
|
m_objectHandle->setObjectId(id);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2021-08-23 21:01:37 +12:00
|
|
|
void FunctionViewer::onPreferenceChanged(const QString &prefName) {
|
|
|
|
if (prefName != "XSheetToolbar" && !prefName.isEmpty()) return;
|
|
|
|
if (!Preferences::instance()->isExpandFunctionHeaderEnabled()) return;
|
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ToggleBetweenGraphAndSpreadsheet &&
|
|
|
|
m_toggleStatus == 1) {
|
|
|
|
m_numericalColumns->hide();
|
|
|
|
m_functionGraph->show();
|
|
|
|
m_leftLayout->setSpacing(0);
|
|
|
|
if (QSpacerItem *spacer = m_leftLayout->itemAt(0)->spacerItem()) {
|
|
|
|
spacer->changeSize(0, 0);
|
|
|
|
spacer->invalidate();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// spreadsheet is shown
|
|
|
|
bool toolBarVisible =
|
|
|
|
Preferences::instance()->isShowQuickToolbarEnabled() &&
|
|
|
|
Preferences::instance()->isExpandFunctionHeaderEnabled();
|
|
|
|
m_functionGraph->hide();
|
|
|
|
m_numericalColumns->show();
|
|
|
|
if (QSpacerItem *spacer = m_leftLayout->itemAt(0)->spacerItem()) {
|
|
|
|
spacer->changeSize(1, m_spacing + ((toolBarVisible) ? 10 : 0),
|
|
|
|
QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
spacer->invalidate();
|
|
|
|
m_numericalColumns->updateHeaderHeight();
|
|
|
|
m_leftLayout->setSpacing(0);
|
|
|
|
} else
|
|
|
|
m_leftLayout->setSpacing(m_spacing + ((toolBarVisible) ? 30 : 0));
|
|
|
|
updateGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::doSwitchCurrentFx(TFx *fx) {
|
|
|
|
if (!fx) {
|
|
|
|
m_fxHandle->setFx(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fx->isZerary()) {
|
|
|
|
TXsheet *xsh = m_xshHandle->getXsheet();
|
|
|
|
int i, columnCount = xsh->getColumnCount();
|
|
|
|
for (i = 0; i < columnCount; i++) {
|
|
|
|
TXshColumn *column = xsh->getColumn(i);
|
|
|
|
TXshZeraryFxColumn *zfx =
|
|
|
|
dynamic_cast<TXshZeraryFxColumn *>(xsh->getColumn(i));
|
|
|
|
if (!zfx) continue;
|
|
|
|
if (zfx->getZeraryColumnFx()->getZeraryFx() == fx) {
|
|
|
|
fx = zfx->getZeraryColumnFx();
|
|
|
|
m_columnHandle->setColumnIndex(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Forbid update of the swatch upon column switch. This would generate
|
|
|
|
// a useless render...
|
|
|
|
SwatchViewer::suspendRendering(true, false);
|
|
|
|
|
|
|
|
int columnIndex = fx->getReferenceColumnIndex();
|
|
|
|
if (columnIndex >= 0) m_columnHandle->setColumnIndex(columnIndex);
|
|
|
|
|
|
|
|
SwatchViewer::suspendRendering(false);
|
|
|
|
m_fxHandle->setFx(fx);
|
|
|
|
emit editObject();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::propagateExternalSetFrame() {
|
|
|
|
assert(m_frameHandle);
|
|
|
|
m_localFrame.setFrame(m_frameHandle->getFrame());
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::addParameter(TParam *parameter, const TFilePath &folder) {
|
|
|
|
static_cast<FunctionTreeModel *>(m_treeView->model())
|
|
|
|
->addParameter(parameter, folder);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::setFocusColumnsOrGraph() {
|
2021-03-06 17:23:08 +13:00
|
|
|
if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ToggleBetweenGraphAndSpreadsheet) {
|
|
|
|
if (m_toggleStatus ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
|
|
|
|
m_functionGraph->setFocus();
|
|
|
|
else if (m_toggleStatus ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup)
|
|
|
|
m_numericalColumns->setFocus();
|
|
|
|
|
|
|
|
} else if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup)
|
|
|
|
m_numericalColumns->setFocus();
|
|
|
|
else if (m_toggleStart ==
|
|
|
|
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
|
|
|
|
m_functionGraph->setFocus();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::clearFocusColumnsAndGraph() {
|
|
|
|
m_functionGraph->clearFocus();
|
|
|
|
m_numericalColumns->clearFocus();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool FunctionViewer::columnsOrGraphHasFocus() {
|
|
|
|
return m_functionGraph->hasFocus() ||
|
|
|
|
m_numericalColumns->anyWidgetHasFocus() ||
|
|
|
|
m_toolbar->anyWidgetHasFocus() || m_segmentViewer->anyWidgetHasFocus();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionViewer::setSceneHandle(TSceneHandle *sceneHandle) {
|
|
|
|
m_sceneHandle = sceneHandle;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool FunctionViewer::isExpressionPageActive() {
|
|
|
|
return m_segmentViewer->isExpressionPageActive();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
2018-03-22 20:32:19 +13:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionViewer::save(QSettings &settings) const {
|
2020-05-23 09:31:30 +12:00
|
|
|
FunctionEditorToggleStatus = m_toggleStatus;
|
2018-03-22 20:32:19 +13:00
|
|
|
settings.setValue("toggleStatus", m_toggleStatus);
|
2019-08-21 20:28:46 +12:00
|
|
|
settings.setValue("showIbtwnValuesInSheet",
|
|
|
|
m_numericalColumns->isIbtwnValueVisible());
|
2021-04-28 14:02:23 +12:00
|
|
|
settings.setValue("syncSize", m_numericalColumns->isSyncSize());
|
2018-03-22 20:32:19 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionViewer::load(QSettings &settings) {
|
|
|
|
QVariant toggleStatus = settings.value("toggleStatus");
|
|
|
|
if (toggleStatus.canConvert(QVariant::Int)) {
|
|
|
|
m_toggleStatus = toggleStatus.toInt();
|
|
|
|
}
|
2020-05-23 09:31:30 +12:00
|
|
|
m_toggleStatus = FunctionEditorToggleStatus;
|
2019-08-21 20:28:46 +12:00
|
|
|
bool ibtwnVisible = settings
|
|
|
|
.value("showIbtwnValuesInSheet",
|
|
|
|
m_numericalColumns->isIbtwnValueVisible())
|
|
|
|
.toBool();
|
|
|
|
m_numericalColumns->setIbtwnValueVisible(ibtwnVisible);
|
2021-04-28 14:02:23 +12:00
|
|
|
|
|
|
|
bool syncSize =
|
|
|
|
settings.value("syncSize", m_numericalColumns->isSyncSize()).toBool();
|
|
|
|
m_numericalColumns->setSyncSize(syncSize);
|
2018-03-22 20:32:19 +13:00
|
|
|
}
|
2020-05-21 19:46:42 +12:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
QColor FunctionViewer::getCurrentTextColor() const {
|
|
|
|
// get colors
|
|
|
|
TPixel currentColumnPixel;
|
|
|
|
Preferences::instance()->getCurrentColumnData(currentColumnPixel);
|
|
|
|
QColor currentColumnColor((int)currentColumnPixel.r,
|
|
|
|
(int)currentColumnPixel.g,
|
|
|
|
(int)currentColumnPixel.b, 255);
|
|
|
|
return currentColumnColor;
|
|
|
|
}
|