2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
|
|
|
|
// TnzCore includes
|
|
|
|
#include "tsystem.h"
|
|
|
|
#include "tstream.h"
|
|
|
|
#include "tfilepath_io.h"
|
|
|
|
#include "tfunctorinvoker.h"
|
|
|
|
|
2021-07-08 13:39:28 +12:00
|
|
|
// TnzBase includes
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "tunit.h"
|
|
|
|
#include "tparamcontainer.h"
|
|
|
|
#include "tparamset.h"
|
|
|
|
#include "tmacrofx.h"
|
|
|
|
#include "tparamchange.h"
|
|
|
|
|
|
|
|
// TnzExt includes
|
|
|
|
#include "ext/plasticskeleton.h"
|
|
|
|
|
|
|
|
// TnzLib includes
|
|
|
|
#include "toonz/tstageobjecttree.h"
|
|
|
|
#include "toonz/txsheet.h"
|
|
|
|
#include "toonz/txsheethandle.h"
|
|
|
|
#include "toonz/fxdag.h"
|
|
|
|
#include "toonz/txshzeraryfxcolumn.h"
|
|
|
|
#include "toonz/tcolumnfx.h"
|
|
|
|
#include "toonz/tfxhandle.h"
|
|
|
|
#include "toonz/tobjecthandle.h"
|
|
|
|
|
|
|
|
// TnzQt includes
|
|
|
|
#include "toonzqt/functionviewer.h"
|
|
|
|
#include "toonzqt/dvdialog.h"
|
|
|
|
#include "toonzqt/gutil.h"
|
|
|
|
#include "toonzqt/plasticvertexselection.h"
|
|
|
|
#include "tw/stringtable.h"
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QColor>
|
2016-06-15 18:43:10 +12:00
|
|
|
#include <QApplication> // for drag&drop
|
2016-03-19 06:57:51 +13:00
|
|
|
#include <QDrag>
|
|
|
|
#include <QMimeData>
|
2020-05-23 09:31:30 +12:00
|
|
|
#include <QBitmap>
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#include "toonzqt/functiontreeviewer.h"
|
|
|
|
|
|
|
|
//*************************************************************************************
|
|
|
|
// ChannelGroup specialization definition
|
|
|
|
//*************************************************************************************
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace {
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class ParamChannelGroup final : public FunctionTreeModel::ParamWrapper,
|
|
|
|
public FunctionTreeModel::ChannelGroup {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
ParamChannelGroup(TParam *param, const std::wstring &fxId,
|
|
|
|
std::string ¶mName);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void refresh() override;
|
|
|
|
void *getInternalPointer() const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class SkVDChannelGroup final : public FunctionTreeModel::ChannelGroup {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
StageObjectChannelGroup *m_stageObjectGroup; //!< Parent stage object group
|
|
|
|
const QString *m_vxName; //!< The associated vertex name
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
SkVDChannelGroup(const QString *vxName, StageObjectChannelGroup *stageGroup)
|
|
|
|
: ChannelGroup(*vxName)
|
|
|
|
, m_stageObjectGroup(stageGroup)
|
|
|
|
, m_vxName(vxName) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-20 14:23:05 +12:00
|
|
|
QString getShortName() const override {
|
|
|
|
return m_stageObjectGroup->getShortName();
|
|
|
|
}
|
2016-06-19 20:06:29 +12:00
|
|
|
QString getLongName() const override { return *m_vxName; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void *getInternalPointer() const override { return (void *)m_vxName; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static inline bool compareStr(const TreeModel::Item *item,
|
|
|
|
const QString &str) {
|
|
|
|
const QString &thisStr =
|
|
|
|
static_cast<const SkVDChannelGroup *>(item)->getLongName();
|
|
|
|
return (QString::localeAwareCompare(thisStr, str) < 0);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
QVariant data(int role) const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
} // namespace
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// ChannelGroup
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FunctionTreeModel::ChannelGroup::ChannelGroup(const QString &name)
|
2016-06-15 18:43:10 +12:00
|
|
|
: m_name(name), m_showFilter(ShowAllChannels) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::ChannelGroup::~ChannelGroup() {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool FunctionTreeModel::ChannelGroup::isActive() const {
|
|
|
|
// Analyze children. If one is active, this is active too.
|
|
|
|
int c, childCount = getChildCount();
|
|
|
|
for (c = 0; c != childCount; ++c)
|
|
|
|
if (static_cast<Item *>(getChild(c))->isActive()) return true;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
return false;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool FunctionTreeModel::ChannelGroup::isAnimated() const {
|
|
|
|
// Same for the animated feature, this is animate if any of its children is.
|
|
|
|
int c, childCount = getChildCount();
|
|
|
|
for (c = 0; c != childCount; ++c)
|
|
|
|
if (static_cast<Item *>(getChild(c))->isAnimated()) return true;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
return false;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2020-04-17 19:02:53 +12:00
|
|
|
bool FunctionTreeModel::ChannelGroup::isIgnored() const {
|
|
|
|
// Same for the ignored ones, show warning icon if any of its children is.
|
|
|
|
int c, childCount = getChildCount();
|
|
|
|
for (c = 0; c != childCount; ++c)
|
|
|
|
if (static_cast<Item *>(getChild(c))->isIgnored()) return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QVariant FunctionTreeModel::ChannelGroup::data(int role) const {
|
|
|
|
if (role == Qt::DisplayRole)
|
|
|
|
return getLongName();
|
|
|
|
else if (role == Qt::DecorationRole) {
|
|
|
|
bool animated = isAnimated();
|
|
|
|
bool active = isActive();
|
2020-04-17 19:02:53 +12:00
|
|
|
bool ignored = (animated) ? isIgnored() : false;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (active) {
|
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
|
|
|
static QIcon folderAnimOpen(createQIcon("folder_anim_on", true));
|
|
|
|
static QIcon folderAnimClose(createQIcon("folder_anim", true));
|
|
|
|
static QIcon folderOpen(createQIcon("folder_on", true));
|
|
|
|
static QIcon folderClose(createQIcon("folder", true));
|
2020-04-17 19:02:53 +12:00
|
|
|
static QIcon ignoredOn(":Resources/paramignored_on.svg");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2020-04-17 19:02:53 +12:00
|
|
|
return animated ? (isOpen() ? folderAnimOpen
|
|
|
|
: (ignored ? ignoredOn : folderAnimClose))
|
|
|
|
: (isOpen() ? folderOpen : folderClose);
|
2016-06-15 18:43:10 +12:00
|
|
|
} else {
|
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
|
|
|
static QIcon folderAnimOpen(createQIcon("folder_anim_inactive_on", true));
|
|
|
|
static QIcon folderAnimClose(createQIcon("folder_anim_inactive", true));
|
|
|
|
static QIcon folderOpen(createQIcon("folder_inactive_on", true));
|
|
|
|
static QIcon folderClose(createQIcon("folder_inactive", true));
|
2020-04-17 19:02:53 +12:00
|
|
|
static QIcon ignoredOff(":Resources/paramignored_off.svg");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2020-04-17 19:02:53 +12:00
|
|
|
return animated ? (isOpen() ? folderAnimOpen
|
|
|
|
: (ignored ? ignoredOff : folderAnimClose))
|
|
|
|
: (isOpen() ? folderOpen : folderClose);
|
2016-06-15 18:43:10 +12:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
return Item::data(role);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//! \todo This is \a not recursive - I guess it should be...?
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::ChannelGroup::applyShowFilter() {
|
|
|
|
int i, itemCount = getChildCount();
|
|
|
|
for (i = 0; i < itemCount; i++) {
|
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(getChild(i));
|
|
|
|
/*--- ChannelGroupの内部も同じフィルタで更新する ---*/
|
|
|
|
if (!channel) {
|
|
|
|
FunctionTreeModel::ChannelGroup *channelGroup =
|
|
|
|
dynamic_cast<FunctionTreeModel::ChannelGroup *>(getChild(i));
|
|
|
|
if (!channelGroup) continue;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
channelGroup->setShowFilter(m_showFilter);
|
|
|
|
continue;
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool showItem = (m_showFilter == ShowAllChannels) ||
|
|
|
|
channel->getParam()->hasKeyframes();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QModelIndex modelIndex = createIndex();
|
|
|
|
getModel()->setRowHidden(i, modelIndex, !showItem);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (!showItem) channel->setIsActive(false);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::ChannelGroup::setShowFilter(ShowFilter showFilter) {
|
|
|
|
m_showFilter = showFilter;
|
|
|
|
applyShowFilter();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString FunctionTreeModel::ChannelGroup::getIdName() const {
|
|
|
|
QString tmpName = QString(m_name);
|
|
|
|
tmpName.remove(QChar(' '), Qt::CaseInsensitive);
|
|
|
|
tmpName = tmpName.toLower();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::ChannelGroup *parentGroup =
|
|
|
|
dynamic_cast<FunctionTreeModel::ChannelGroup *>(getParent());
|
|
|
|
if (parentGroup) {
|
|
|
|
return parentGroup->getIdName() + QString(".") + tmpName;
|
|
|
|
}
|
|
|
|
return tmpName;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::ChannelGroup::setChildrenAllActive(bool active) {
|
|
|
|
for (int i = 0; i < getChildCount(); i++) {
|
|
|
|
// for Channel
|
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(getChild(i));
|
|
|
|
if (channel) {
|
|
|
|
channel->setIsActive(active);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// for ChannelGroup
|
|
|
|
else {
|
|
|
|
FunctionTreeModel::ChannelGroup *channelGroup =
|
|
|
|
dynamic_cast<FunctionTreeModel::ChannelGroup *>(getChild(i));
|
|
|
|
if (channelGroup) {
|
|
|
|
channelGroup->setChildrenAllActive(active);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// StageObjectChannelGroup
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
StageObjectChannelGroup::StageObjectChannelGroup(TStageObject *stageObject)
|
2016-06-15 18:43:10 +12:00
|
|
|
: m_stageObject(stageObject), m_plasticGroup() {
|
|
|
|
m_stageObject->addRef();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
StageObjectChannelGroup::~StageObjectChannelGroup() {
|
|
|
|
m_stageObject->release();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QVariant StageObjectChannelGroup::data(int role) const {
|
|
|
|
if (role == Qt::DisplayRole) {
|
2018-06-04 15:18:43 +12:00
|
|
|
std::string name = (m_stageObject->getId().isTable())
|
|
|
|
? FunctionTreeView::tr("Table").toStdString()
|
|
|
|
: m_stageObject->getName();
|
|
|
|
std::string id = m_stageObject->getId().toString();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
return (name == id) ? QString::fromStdString(name)
|
|
|
|
: QString::fromStdString(id + " (" + name + ")");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
} else if (role == Qt::ForegroundRole) {
|
|
|
|
FunctionTreeModel *model = dynamic_cast<FunctionTreeModel *>(getModel());
|
|
|
|
if (!model)
|
2016-03-19 06:57:51 +13:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
return QColor(Qt::black);
|
2016-03-19 06:57:51 +13:00
|
|
|
#else
|
2016-06-15 18:43:10 +12:00
|
|
|
return Qt::black;
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeView *view = dynamic_cast<FunctionTreeView *>(model->getView());
|
|
|
|
if (!view || !model->getCurrentStageObject())
|
2016-03-19 06:57:51 +13:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
return QColor(Qt::black);
|
2016-03-19 06:57:51 +13:00
|
|
|
#else
|
2016-06-15 18:43:10 +12:00
|
|
|
return Qt::black;
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
2016-06-15 18:43:10 +12:00
|
|
|
TStageObjectId currentId = model->getCurrentStageObject()->getId();
|
2020-05-21 19:46:42 +12:00
|
|
|
return m_stageObject->getId() == currentId
|
|
|
|
? view->getViewer()->getCurrentTextColor()
|
|
|
|
: view->getTextColor();
|
2016-06-15 18:43:10 +12:00
|
|
|
} else
|
|
|
|
return ChannelGroup::data(role);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString StageObjectChannelGroup::getShortName() const {
|
|
|
|
return QString::fromStdString(m_stageObject->getName());
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString StageObjectChannelGroup::getLongName() const {
|
|
|
|
return QString::fromStdString(m_stageObject->getFullName());
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString StageObjectChannelGroup::getIdName() const {
|
|
|
|
return QString::fromStdString(m_stageObject->getId().toString()).toLower();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// FxChannelGroup
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FxChannelGroup::FxChannelGroup(TFx *fx) : m_fx(fx) {
|
|
|
|
if (m_fx) m_fx->addRef();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FxChannelGroup::~FxChannelGroup() {
|
|
|
|
if (m_fx) m_fx->release();
|
|
|
|
m_fx = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString FxChannelGroup::getShortName() const {
|
|
|
|
return QString::fromStdWString(m_fx->getFxId());
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString FxChannelGroup::getLongName() const {
|
|
|
|
return QString::fromStdWString(m_fx->getFxId());
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QVariant FxChannelGroup::data(int role) const {
|
|
|
|
if (role == Qt::DecorationRole) {
|
|
|
|
bool isAnimated = false;
|
|
|
|
TParamContainer *paramContainer = m_fx->getParams();
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < paramContainer->getParamCount(); i++) {
|
|
|
|
if (!paramContainer->getParam(i)->hasKeyframes()) continue;
|
|
|
|
isAnimated = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bool isOneChildActive = false;
|
|
|
|
for (i = 0; i < getChildCount(); i++) {
|
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(getChild(i));
|
|
|
|
if (!channel || !channel->isActive()) continue;
|
|
|
|
isOneChildActive = true;
|
|
|
|
break;
|
|
|
|
}
|
2020-04-17 19:02:53 +12:00
|
|
|
bool ignored = (isAnimated) ? isIgnored() : false;
|
2016-06-15 18:43:10 +12:00
|
|
|
if (isOneChildActive) {
|
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
|
|
|
static QIcon folderAnimOpen(createQIcon("folder_anim_on", true));
|
|
|
|
static QIcon folderAnimClose(createQIcon("folder_anim", true));
|
|
|
|
static QIcon folderOpen(createQIcon("folder_on", true));
|
|
|
|
static QIcon folderClose(createQIcon("folder", true));
|
2020-04-17 19:02:53 +12:00
|
|
|
static QIcon ignoredOn(":Resources/paramignored_on.svg");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2020-04-17 19:02:53 +12:00
|
|
|
return isAnimated ? (isOpen() ? folderAnimOpen
|
|
|
|
: (ignored ? ignoredOn : folderAnimClose))
|
|
|
|
: (isOpen() ? folderOpen : folderClose);
|
2016-06-15 18:43:10 +12:00
|
|
|
} else {
|
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
|
|
|
static QIcon folderAnimOpen(createQIcon("folder_anim_inactive_on", true));
|
|
|
|
static QIcon folderAnimClose(createQIcon("folder_anim_inactive", true));
|
|
|
|
static QIcon folderOpen(createQIcon("folder_inactive_on", true));
|
|
|
|
static QIcon folderClose(createQIcon("folder_inactive", true));
|
2020-04-17 19:02:53 +12:00
|
|
|
static QIcon ignoredOff(":Resources/paramignored_off.svg");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2020-04-17 19:02:53 +12:00
|
|
|
return isAnimated ? (isOpen() ? folderAnimOpen
|
|
|
|
: (ignored ? ignoredOff : folderAnimClose))
|
|
|
|
: (isOpen() ? folderOpen : folderClose);
|
2016-06-15 18:43:10 +12:00
|
|
|
}
|
|
|
|
} else if (role == Qt::DisplayRole) {
|
|
|
|
std::wstring name = m_fx->getName();
|
|
|
|
std::wstring id = m_fx->getFxId();
|
|
|
|
if (name == id)
|
|
|
|
return QString::fromStdWString(name);
|
|
|
|
else
|
|
|
|
return QString::fromStdWString(id + L" (" + name + L")");
|
|
|
|
} else if (role == Qt::ForegroundRole) {
|
|
|
|
FunctionTreeModel *model = dynamic_cast<FunctionTreeModel *>(getModel());
|
|
|
|
if (!model)
|
2016-03-19 06:57:51 +13:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
return QColor(Qt::black);
|
2016-03-19 06:57:51 +13:00
|
|
|
#else
|
2016-06-15 18:43:10 +12:00
|
|
|
return Qt::black;
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeView *view = dynamic_cast<FunctionTreeView *>(model->getView());
|
|
|
|
if (!view)
|
2016-03-19 06:57:51 +13:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
return QColor(Qt::black);
|
2016-03-19 06:57:51 +13:00
|
|
|
#else
|
2016-06-15 18:43:10 +12:00
|
|
|
return Qt::black;
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
2016-06-15 18:43:10 +12:00
|
|
|
TFx *currentFx = model->getCurrentFx();
|
2020-05-21 19:46:42 +12:00
|
|
|
return m_fx == currentFx ? view->getViewer()->getCurrentTextColor()
|
2016-06-15 18:43:10 +12:00
|
|
|
: view->getTextColor();
|
|
|
|
} else
|
|
|
|
return Item::data(role);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString FxChannelGroup::getIdName() const {
|
|
|
|
return QString::fromStdWString(m_fx->getFxId()).toLower();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FxChannelGroup::refresh() {
|
|
|
|
TMacroFx *macroFx = dynamic_cast<TMacroFx *>(m_fx);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int i, childrenCount = getChildCount();
|
|
|
|
for (i = 0; i < childrenCount; ++i) {
|
|
|
|
FunctionTreeModel::ParamWrapper *wrap =
|
|
|
|
dynamic_cast<FunctionTreeModel::ParamWrapper *>(getChild(i));
|
|
|
|
assert(wrap);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TParam *param = 0;
|
|
|
|
{
|
|
|
|
TParamContainer *paramContainer = 0;
|
|
|
|
if (macroFx) {
|
|
|
|
const std::wstring &fxId = wrap->getFxId();
|
|
|
|
TFx *subFx = macroFx->getFxById(fxId);
|
|
|
|
if (!subFx) continue;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
paramContainer = subFx->getParams();
|
|
|
|
} else
|
|
|
|
paramContainer = m_fx->getParams();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
param = paramContainer->getParam(wrap->getParam()->getName());
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(param);
|
|
|
|
wrap->setParam(param);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
ParamChannelGroup *paramGroup = dynamic_cast<ParamChannelGroup *>(wrap);
|
|
|
|
if (paramGroup) paramGroup->refresh();
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// ParamChannelGroup
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
ParamChannelGroup::ParamChannelGroup(TParam *param, const std::wstring &fxId,
|
|
|
|
std::string ¶mName)
|
|
|
|
: ParamWrapper(param, fxId)
|
|
|
|
, ChannelGroup(
|
|
|
|
param->hasUILabel()
|
|
|
|
? QString::fromStdString(param->getUILabel())
|
|
|
|
: QString::fromStdWString(TStringTable::translate(paramName))) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void *ParamChannelGroup::getInternalPointer() const {
|
|
|
|
return this->m_param.getPointer();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void ParamChannelGroup::refresh() {
|
|
|
|
TParamSet *paramSet = dynamic_cast<TParamSet *>(m_param.getPointer());
|
|
|
|
if (!paramSet) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int c, childrenCount = getChildCount();
|
|
|
|
for (c = 0; c < childrenCount; ++c) {
|
|
|
|
FunctionTreeModel::ParamWrapper *wrap =
|
|
|
|
dynamic_cast<FunctionTreeModel::ParamWrapper *>(getChild(c));
|
|
|
|
assert(wrap);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TParamP currentParam = wrap->getParam();
|
|
|
|
assert(currentParam);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int p = paramSet->getParamIdx(wrap->getParam()->getName());
|
|
|
|
assert(p < paramSet->getParamCount());
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TParamP param = paramSet->getParam(p);
|
|
|
|
wrap->setParam(param);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// SkVDChannelGroup
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QVariant SkVDChannelGroup::data(int role) const {
|
|
|
|
if (role == Qt::ForegroundRole) {
|
|
|
|
// Check whether current selection is a PlasticVertex one - in case, paint
|
2020-01-15 22:26:05 +13:00
|
|
|
// it selection color
|
2016-06-15 18:43:10 +12:00
|
|
|
// if this group refers to current vertex
|
2020-01-15 22:26:05 +13:00
|
|
|
FunctionTreeModel *model = dynamic_cast<FunctionTreeModel *>(getModel());
|
|
|
|
if (!model)
|
|
|
|
#if QT_VERSION >= 0x050000
|
|
|
|
return QColor(Qt::black);
|
|
|
|
#else
|
|
|
|
return Qt::black;
|
|
|
|
#endif
|
|
|
|
FunctionTreeView *view = dynamic_cast<FunctionTreeView *>(model->getView());
|
|
|
|
if (!view || !model->getCurrentStageObject())
|
|
|
|
#if QT_VERSION >= 0x050000
|
|
|
|
return QColor(Qt::black);
|
|
|
|
#else
|
|
|
|
return Qt::black;
|
|
|
|
#endif
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (PlasticVertexSelection *vxSel =
|
|
|
|
dynamic_cast<PlasticVertexSelection *>(TSelection::getCurrent()))
|
2020-01-15 22:26:05 +13:00
|
|
|
if (TStageObject *obj = model->getCurrentStageObject())
|
2016-06-15 18:43:10 +12:00
|
|
|
if (obj == m_stageObjectGroup->m_stageObject)
|
|
|
|
if (const SkDP &sd = obj->getPlasticSkeletonDeformation()) {
|
|
|
|
int vIdx = *vxSel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (vIdx >= 0 &&
|
|
|
|
sd->skeleton(vxSel->skeletonId())->vertex(vIdx).name() ==
|
|
|
|
getLongName())
|
2020-05-21 19:46:42 +12:00
|
|
|
return view->getViewer()->getCurrentTextColor();
|
2016-06-15 18:43:10 +12:00
|
|
|
}
|
2020-01-15 22:26:05 +13:00
|
|
|
return view->getTextColor();
|
2016-06-15 18:43:10 +12:00
|
|
|
} else
|
|
|
|
return ChannelGroup::data(role);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// Channel
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::Channel::Channel(FunctionTreeModel *model,
|
|
|
|
TDoubleParam *param,
|
|
|
|
std::string paramNamePref,
|
|
|
|
std::wstring fxId)
|
|
|
|
: ParamWrapper(param, fxId)
|
|
|
|
, m_model(model)
|
|
|
|
, m_group(0)
|
|
|
|
, m_isActive(false)
|
|
|
|
, m_paramNamePref(paramNamePref) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::Channel::~Channel() {
|
|
|
|
m_model->onChannelDestroyed(this);
|
|
|
|
if (m_isActive) getParam()->removeObserver(this);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void *FunctionTreeModel::Channel::getInternalPointer() const {
|
|
|
|
return this->m_param.getPointer();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool FunctionTreeModel::Channel::isAnimated() const {
|
|
|
|
return m_param->hasKeyframes();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2020-04-17 19:02:53 +12:00
|
|
|
bool FunctionTreeModel::Channel::isIgnored() const {
|
|
|
|
if (!isAnimated()) return false;
|
|
|
|
TDoubleParam *dp = dynamic_cast<TDoubleParam *>(m_param.getPointer());
|
|
|
|
if (!dp) return false;
|
|
|
|
FunctionTreeView *view = dynamic_cast<FunctionTreeView *>(m_model->m_view);
|
|
|
|
if (!view) return false;
|
|
|
|
return view->getXsheetHandle()->getXsheet()->isReferenceManagementIgnored(dp);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QVariant FunctionTreeModel::Channel::data(int role) const {
|
|
|
|
if (role == Qt::DecorationRole) {
|
2020-04-17 19:02:53 +12:00
|
|
|
static QIcon paramIgnoredOn(":Resources/paramignored_on.svg");
|
|
|
|
static QIcon paramIgnoredOff(":Resources/paramignored_off.svg");
|
|
|
|
|
|
|
|
if (isIgnored()) return isActive() ? paramIgnoredOn : paramIgnoredOff;
|
|
|
|
|
2020-05-23 09:31:30 +12:00
|
|
|
QPixmap pixmap(10, 10);
|
|
|
|
QColor color;
|
|
|
|
QString name = getShortName();
|
|
|
|
std::string strName = name.toStdString();
|
|
|
|
if (name == "X")
|
|
|
|
color = QColor("firebrick");
|
|
|
|
else if (name == "Y")
|
|
|
|
color = QColor("limegreen");
|
|
|
|
else if (name == "Z")
|
|
|
|
color = QColor("deepskyblue");
|
|
|
|
else if (name == "SO")
|
|
|
|
color = QColor("hotpink");
|
|
|
|
else if (name == "Rotation")
|
|
|
|
color = QColor("darkorchid");
|
|
|
|
else if (name == "Scale")
|
|
|
|
color = QColor("gold");
|
|
|
|
else if (name == "Scale H")
|
|
|
|
color = QColor("gold");
|
|
|
|
else if (name == "Scale V")
|
|
|
|
color = QColor("gold");
|
|
|
|
else if (name == "Shear H")
|
|
|
|
color = QColor("darkorange");
|
|
|
|
else if (name == "Shear V")
|
|
|
|
color = QColor("darkorange");
|
|
|
|
else if (name == "posPath")
|
|
|
|
color = QColor("darksalmon");
|
|
|
|
else
|
|
|
|
color = QColor("darkcyan");
|
|
|
|
if (!isActive())
|
|
|
|
color = QColor("dimgray");
|
|
|
|
else if (!m_param->hasKeyframes())
|
|
|
|
color.setAlpha(100);
|
|
|
|
pixmap.fill(color);
|
|
|
|
|
|
|
|
QIcon param(pixmap);
|
|
|
|
return param;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
} else if (role == Qt::DisplayRole) {
|
|
|
|
if (m_param->hasUILabel()) {
|
|
|
|
return QString::fromStdString(m_param->getUILabel());
|
|
|
|
}
|
|
|
|
std::string name = m_paramNamePref + m_param->getName();
|
|
|
|
std::wstring translatedName = TStringTable::translate(name);
|
|
|
|
if (m_fxId.size() > 0)
|
|
|
|
return QString::fromStdWString(translatedName + L" (" + m_fxId + L")");
|
|
|
|
return QString::fromStdWString(translatedName);
|
|
|
|
} else if (role == Qt::ForegroundRole) {
|
|
|
|
// 130221 iwasawa
|
|
|
|
FunctionTreeView *view = dynamic_cast<FunctionTreeView *>(m_model->m_view);
|
|
|
|
if (!view)
|
2016-03-19 06:57:51 +13:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
return QColor(Qt::black);
|
2016-03-19 06:57:51 +13:00
|
|
|
#else
|
2016-06-15 18:43:10 +12:00
|
|
|
return Qt::black;
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
2020-05-21 19:46:42 +12:00
|
|
|
return (isCurrent()) ? view->getViewer()->getCurrentTextColor()
|
|
|
|
: view->getTextColor();
|
2020-04-17 19:02:53 +12:00
|
|
|
} else if (role == Qt::ToolTipRole) {
|
|
|
|
if (m_param->hasKeyframes()) {
|
|
|
|
TDoubleParam *dp = dynamic_cast<TDoubleParam *>(m_param.getPointer());
|
|
|
|
FunctionTreeView *view =
|
|
|
|
dynamic_cast<FunctionTreeView *>(m_model->m_view);
|
|
|
|
if (dp && view &&
|
|
|
|
view->getXsheetHandle()->getXsheet()->isReferenceManagementIgnored(
|
|
|
|
dp))
|
|
|
|
return tr(
|
|
|
|
"Some key(s) in this parameter loses original reference in "
|
|
|
|
"expression.\nManually changing any keyframe will clear the "
|
|
|
|
"warning.");
|
|
|
|
}
|
|
|
|
return TreeModel::Item::data(role);
|
2016-06-15 18:43:10 +12:00
|
|
|
} else
|
|
|
|
return TreeModel::Item::data(role);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString FunctionTreeModel::Channel::getShortName() const {
|
|
|
|
if (m_param->hasUILabel()) {
|
|
|
|
return QString::fromStdString(m_param->getUILabel());
|
|
|
|
}
|
|
|
|
std::string name = m_paramNamePref + m_param->getName();
|
|
|
|
std::wstring translatedName = TStringTable::translate(name);
|
|
|
|
return QString::fromStdWString(translatedName);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString FunctionTreeModel::Channel::getLongName() const {
|
2020-04-17 19:02:53 +12:00
|
|
|
QString name = getShortName();
|
2016-06-15 18:43:10 +12:00
|
|
|
if (getChannelGroup()) name = getChannelGroup()->getLongName() + " " + name;
|
|
|
|
return name;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::Channel::setParam(const TParamP ¶m) {
|
|
|
|
if (param.getPointer() == m_param.getPointer()) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TParamP oldParam = m_param;
|
|
|
|
m_param = param;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_isActive) {
|
|
|
|
oldParam->removeObserver(this);
|
|
|
|
param->addObserver(this);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/*! in order to show the expression name in the tooltip
|
2020-01-15 22:26:05 +13:00
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
QString FunctionTreeModel::Channel::getExprRefName() const {
|
2021-09-02 20:36:37 +12:00
|
|
|
QString tmpName;
|
|
|
|
if (m_param->hasUILabel())
|
|
|
|
tmpName = QString::fromStdString(m_param->getUILabel());
|
|
|
|
else
|
|
|
|
tmpName = QString::fromStdWString(
|
|
|
|
TStringTable::translate(m_paramNamePref + m_param->getName()));
|
2016-06-15 18:43:10 +12:00
|
|
|
/*--- stage
|
|
|
|
* objectパラメータの場合、TableにあわせてtmpNameを代表的なExpression名にする---*/
|
|
|
|
StageObjectChannelGroup *stageGroup =
|
|
|
|
dynamic_cast<StageObjectChannelGroup *>(m_group);
|
|
|
|
if (stageGroup) {
|
2020-06-12 20:33:50 +12:00
|
|
|
if (tmpName == "Y")
|
|
|
|
tmpName = "y";
|
|
|
|
else if (tmpName == "X")
|
|
|
|
tmpName = "x";
|
2016-06-15 18:43:10 +12:00
|
|
|
else if (tmpName == "Z")
|
|
|
|
tmpName = "z";
|
|
|
|
else if (tmpName == "Rotation")
|
|
|
|
tmpName = "rot";
|
|
|
|
else if (tmpName == "Scale H")
|
|
|
|
tmpName = "sx";
|
|
|
|
else if (tmpName == "Scale V")
|
|
|
|
tmpName = "sy";
|
|
|
|
else if (tmpName == "Shear H")
|
|
|
|
tmpName = "shx";
|
|
|
|
else if (tmpName == "Shear V")
|
|
|
|
tmpName = "shy";
|
|
|
|
else if (tmpName == "posPath")
|
|
|
|
tmpName = "path";
|
|
|
|
else if (tmpName == "Scale")
|
|
|
|
tmpName = "sc";
|
|
|
|
else
|
|
|
|
tmpName = tmpName.toLower();
|
|
|
|
|
|
|
|
return stageGroup->getIdName() + QString(".") + tmpName;
|
|
|
|
}
|
|
|
|
|
2017-11-28 16:36:26 +13:00
|
|
|
// expression for fx parameters
|
|
|
|
// see txsheetexpr.cpp for generation of actual tokens
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
tmpName.remove(QChar(' '), Qt::CaseInsensitive);
|
|
|
|
tmpName.remove(QChar('/'));
|
2017-11-28 16:36:26 +13:00
|
|
|
tmpName.remove(QChar('-'));
|
2016-06-15 18:43:10 +12:00
|
|
|
tmpName = tmpName.toLower();
|
|
|
|
|
|
|
|
FunctionTreeModel::ChannelGroup *parentGroup =
|
|
|
|
dynamic_cast<FunctionTreeModel::ChannelGroup *>(getParent());
|
|
|
|
if (parentGroup) {
|
|
|
|
return QString("fx.") + parentGroup->getIdName() + QString(".") + tmpName;
|
|
|
|
} else
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionTreeModel::Channel::setIsActive(bool active) {
|
|
|
|
if (active == m_isActive) return;
|
|
|
|
|
|
|
|
m_isActive = active;
|
|
|
|
m_model->refreshActiveChannels();
|
|
|
|
if (m_isActive) {
|
|
|
|
getParam()->addObserver(this);
|
|
|
|
/*--- これが最初にVisibleにしたChannelの場合 ---*/
|
|
|
|
if (!m_model->m_currentChannel) {
|
|
|
|
setIsCurrent(true);
|
|
|
|
m_model->emitCurveSelected(getParam());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
getParam()->removeObserver(this);
|
|
|
|
if (isCurrent()) {
|
|
|
|
setIsCurrent(false);
|
|
|
|
m_model->emitCurveSelected(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_model->emitDataChanged(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool FunctionTreeModel::Channel::isCurrent() const {
|
|
|
|
return m_model->m_currentChannel == this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionTreeModel::Channel::setIsCurrent(bool current) {
|
|
|
|
Channel *oldCurrent = m_model->m_currentChannel;
|
|
|
|
if (current) {
|
|
|
|
// this channel must become the current
|
|
|
|
if (oldCurrent == this) return; // already it is: nothing to do
|
|
|
|
m_model->m_currentChannel = this;
|
|
|
|
|
|
|
|
// change the current fx if the FxChannelGroup is clicked
|
|
|
|
FxChannelGroup *fxGroup = dynamic_cast<FxChannelGroup *>(m_group);
|
|
|
|
if (fxGroup && m_model->getFxHandle()) {
|
|
|
|
m_model->getFxHandle()->setFx(fxGroup->getFx());
|
|
|
|
}
|
|
|
|
// or, change the current object if the stageObjectChannelGroup is clicked
|
|
|
|
else {
|
|
|
|
StageObjectChannelGroup *stageObjectGroup =
|
|
|
|
dynamic_cast<StageObjectChannelGroup *>(m_group);
|
|
|
|
if (stageObjectGroup && m_model->getObjectHandle()) {
|
|
|
|
m_model->getObjectHandle()->setObjectId(
|
|
|
|
stageObjectGroup->getStageObject()->getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// the current channel must be active
|
|
|
|
if (!m_isActive) {
|
|
|
|
m_isActive = true;
|
|
|
|
m_model->refreshActiveChannels();
|
|
|
|
getParam()->addObserver(this);
|
|
|
|
}
|
|
|
|
// refresh the old current (if !=0) and the new one
|
|
|
|
if (oldCurrent) m_model->emitDataChanged(oldCurrent);
|
|
|
|
m_model->emitDataChanged(this);
|
|
|
|
m_model->emitCurveSelected(getParam());
|
|
|
|
// scroll the column to ensure visible the current channel
|
|
|
|
m_model->emitCurrentChannelChanged(this);
|
|
|
|
} else {
|
|
|
|
// this channel is not the current anymore
|
|
|
|
if (oldCurrent != this) return; // it was not: nothing to do
|
|
|
|
m_model->m_currentChannel = 0;
|
|
|
|
// refresh the channel
|
|
|
|
m_model->emitDataChanged(this);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool FunctionTreeModel::Channel::isHidden() const {
|
|
|
|
return getChannelGroup()->getShowFilter() ==
|
|
|
|
ChannelGroup::ShowAnimatedChannels &&
|
|
|
|
!getParam()->hasKeyframes();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::Channel::onChange(const TParamChange &ch) {
|
|
|
|
m_model->onChange(ch);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// FunctionTreeModel
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FunctionTreeModel::FunctionTreeModel(FunctionTreeView *parent)
|
2016-06-15 18:43:10 +12:00
|
|
|
: TreeModel(parent)
|
|
|
|
, m_currentChannel(0)
|
|
|
|
, m_stageObjects(0)
|
|
|
|
, m_fxs(0)
|
|
|
|
, m_currentStageObject(0)
|
|
|
|
, m_currentFx(0)
|
|
|
|
, m_paramsChanged(false) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::~FunctionTreeModel() {
|
|
|
|
// I must delete items here (not in TreeModel::~TreeModel()).
|
|
|
|
// Channel::~Channel() refers to the model, which should be alive.
|
|
|
|
setRootItem(0);
|
|
|
|
if (m_currentFx) m_currentFx->release();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::refreshData(TXsheet *xsh) {
|
|
|
|
m_activeChannels.clear();
|
|
|
|
Channel *currentChannel = m_currentChannel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
beginRefresh();
|
|
|
|
{
|
|
|
|
if (!getRootItem()) {
|
|
|
|
setRootItem(new ChannelGroup("Root"));
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (xsh) {
|
2018-06-04 15:18:43 +12:00
|
|
|
getRootItem()->appendChild(m_stageObjects =
|
|
|
|
new ChannelGroup(tr("Stage")));
|
|
|
|
getRootItem()->appendChild(m_fxs = new ChannelGroup(tr("FX")));
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(getRootItem()->getChildCount() == 2);
|
|
|
|
assert(getRootItem()->getChild(0) == m_stageObjects);
|
|
|
|
assert(getRootItem()->getChild(1) == m_fxs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xsh) {
|
|
|
|
refreshStageObjects(xsh);
|
|
|
|
refreshFxs(xsh);
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshActiveChannels();
|
|
|
|
}
|
|
|
|
endRefresh();
|
|
|
|
|
|
|
|
if (m_currentChannel != currentChannel) emit curveSelected(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionTreeModel::refreshStageObjects(TXsheet *xsh) {
|
|
|
|
static const int channelIds[TStageObject::T_ChannelCount] = {
|
|
|
|
TStageObject::T_X, TStageObject::T_Y, TStageObject::T_Z,
|
|
|
|
TStageObject::T_SO, TStageObject::T_Path, TStageObject::T_Angle,
|
|
|
|
TStageObject::T_ScaleX, TStageObject::T_ScaleY, TStageObject::T_Scale,
|
|
|
|
TStageObject::T_ShearX, TStageObject::T_ShearY}; // Explicitly ordered
|
|
|
|
// channels
|
|
|
|
|
|
|
|
// Retrieve all (not-empty) root stage objects, and add them in the tree model
|
|
|
|
QList<TreeModel::Item *> newItems;
|
|
|
|
TStageObjectTree *ptree = xsh->getStageObjectTree();
|
|
|
|
|
|
|
|
int i, iCount = ptree->getStageObjectCount();
|
|
|
|
for (i = 0; i < iCount; ++i) {
|
|
|
|
TStageObject *pegbar = ptree->getStageObject(i);
|
|
|
|
TStageObjectId id = pegbar->getId();
|
|
|
|
if (id.isColumn() && xsh->isColumnEmpty(id.getIndex())) continue;
|
2020-11-13 13:47:07 +13:00
|
|
|
if (id == ptree->getMotionPathViewerId()) continue;
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
newItems.push_back(new StageObjectChannelGroup(pegbar));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--- newItemsの中で、これまでのChildrenに無いものだけ
|
|
|
|
m_stageObjectsの子に追加。既に有るものはnewChildrenから除外---*/
|
|
|
|
m_stageObjects->setChildren(newItems);
|
|
|
|
|
|
|
|
// Add channels to the NEW stage entries (see the above call to setChildren())
|
|
|
|
iCount = newItems.size();
|
|
|
|
for (i = 0; i < iCount; ++i) {
|
|
|
|
StageObjectChannelGroup *pegbarItem =
|
|
|
|
dynamic_cast<StageObjectChannelGroup *>(newItems[i]);
|
|
|
|
|
|
|
|
TStageObject *stageObject = pegbarItem->getStageObject();
|
|
|
|
|
|
|
|
// Add the standard stage object channels
|
|
|
|
int j, jCount = TStageObject::T_ChannelCount;
|
|
|
|
// making each channel of pegbar
|
|
|
|
for (j = 0; j < jCount; ++j) {
|
|
|
|
TDoubleParam *param =
|
|
|
|
stageObject->getParam((TStageObject::Channel)channelIds[j]);
|
|
|
|
Channel *channel = new Channel(this, param);
|
|
|
|
|
|
|
|
pegbarItem->appendChild(channel);
|
|
|
|
channel->setChannelGroup(pegbarItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
pegbarItem->applyShowFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
// As plastic deformations are stored in stage objects, refresh them if
|
|
|
|
// necessary
|
|
|
|
refreshPlasticDeformations();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionTreeModel::refreshFxs(TXsheet *xsh) {
|
|
|
|
std::vector<TFx *> fxs;
|
|
|
|
xsh->getFxDag()->getFxs(fxs);
|
|
|
|
for (int i = 0; i < xsh->getColumnCount(); i++) {
|
|
|
|
TXshZeraryFxColumn *zc =
|
|
|
|
dynamic_cast<TXshZeraryFxColumn *>(xsh->getColumn(i));
|
|
|
|
if (!zc) continue;
|
|
|
|
fxs.push_back(zc->getZeraryColumnFx()->getZeraryFx());
|
|
|
|
}
|
|
|
|
|
|
|
|
// sort items by fxId
|
|
|
|
for (int j = 1; j < (int)fxs.size(); j++) {
|
|
|
|
int index = j;
|
|
|
|
while (index > 0 &&
|
|
|
|
QString::localeAwareCompare(
|
|
|
|
QString::fromStdWString(fxs[index - 1]->getFxId()),
|
|
|
|
QString::fromStdWString(fxs[index]->getFxId())) > 0) {
|
|
|
|
std::swap(fxs[index - 1], fxs[index]);
|
|
|
|
index = index - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<TreeModel::Item *> newItems;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < (int)fxs.size(); i++) {
|
|
|
|
TFx *fx = fxs[i];
|
|
|
|
if (!fx) continue;
|
|
|
|
TParamContainer *params = fx->getParams();
|
|
|
|
bool hasChannel = false;
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < params->getParamCount(); j++)
|
|
|
|
if (0 != dynamic_cast<TDoubleParam *>(params->getParam(j)) ||
|
|
|
|
0 != dynamic_cast<TPointParam *>(params->getParam(j)) ||
|
|
|
|
0 != dynamic_cast<TRangeParam *>(params->getParam(j)) ||
|
|
|
|
0 != dynamic_cast<TPixelParam *>(params->getParam(j))) {
|
|
|
|
hasChannel = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (hasChannel) newItems.push_back(new FxChannelGroup(fxs[i]));
|
|
|
|
}
|
|
|
|
m_fxs->setChildren(newItems);
|
|
|
|
// Add channels to new fxs (only for those actually added: see setChildren())
|
|
|
|
|
|
|
|
for (i = 0; i < (int)newItems.size(); i++) {
|
|
|
|
TreeModel::Item *item = newItems[i];
|
|
|
|
FxChannelGroup *fxItem = dynamic_cast<FxChannelGroup *>(item);
|
|
|
|
assert(fxItem);
|
|
|
|
if (!fxItem) continue;
|
|
|
|
TFx *fx = fxItem->getFx();
|
|
|
|
assert(fx);
|
|
|
|
if (!fx) continue;
|
|
|
|
TMacroFx *macroFx = dynamic_cast<TMacroFx *>(fx);
|
|
|
|
if (macroFx) {
|
|
|
|
const std::vector<TFxP> ¯oFxs = macroFx->getFxs();
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < (int)macroFxs.size(); j++) {
|
|
|
|
TParamContainer *params = macroFxs[j]->getParams();
|
|
|
|
addChannels(macroFxs[j].getPointer(), fxItem, params);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TParamContainer *params = fx->getParams();
|
|
|
|
addChannels(fx, fxItem, params);
|
|
|
|
}
|
|
|
|
fxItem->applyShowFilter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionTreeModel::refreshPlasticDeformations() {
|
|
|
|
// Refresh ALL stage object items (including OLD ones)
|
|
|
|
int i, iCount = m_stageObjects->getChildCount();
|
|
|
|
for (i = 0; i < iCount; ++i) {
|
|
|
|
// Add the eventual Plastic channels group
|
|
|
|
StageObjectChannelGroup *stageItem =
|
|
|
|
static_cast<StageObjectChannelGroup *>(m_stageObjects->getChild(i));
|
|
|
|
|
|
|
|
TStageObject *stageObject = stageItem->getStageObject();
|
|
|
|
|
|
|
|
const PlasticSkeletonDeformationP &sd =
|
|
|
|
stageObject->getPlasticSkeletonDeformation();
|
|
|
|
FunctionTreeModel::ChannelGroup *&plasticGroup = stageItem->m_plasticGroup;
|
|
|
|
|
|
|
|
if (sd || plasticGroup) {
|
|
|
|
if (!plasticGroup) {
|
|
|
|
// Add a group
|
2018-06-04 15:18:43 +12:00
|
|
|
plasticGroup = new ChannelGroup(tr("Plastic Skeleton"));
|
2016-06-15 18:43:10 +12:00
|
|
|
stageItem->appendChild(plasticGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare each vertex deformation
|
|
|
|
QList<TreeModel::Item *> plasticItems;
|
|
|
|
|
|
|
|
if (sd) {
|
|
|
|
SkD::vd_iterator vdt, vdEnd;
|
|
|
|
sd->vertexDeformations(vdt, vdEnd);
|
|
|
|
|
|
|
|
for (; vdt != vdEnd; ++vdt) {
|
|
|
|
const QString *str = (*vdt).first;
|
|
|
|
|
|
|
|
QList<TreeModel::Item *>::iterator it =
|
|
|
|
std::lower_bound(plasticItems.begin(), plasticItems.end(), *str,
|
|
|
|
SkVDChannelGroup::compareStr);
|
|
|
|
|
|
|
|
plasticItems.insert(it, new SkVDChannelGroup(str, stageItem));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the channel corresponding to the skeleton id
|
|
|
|
{
|
|
|
|
Channel *skelIdsChannel =
|
|
|
|
new Channel(this, sd->skeletonIdsParam().getPointer());
|
|
|
|
|
|
|
|
plasticItems.insert(plasticItems.begin(), skelIdsChannel);
|
|
|
|
skelIdsChannel->setChannelGroup(plasticGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plasticItems.empty()) plasticGroup->setIsOpen(false);
|
|
|
|
|
|
|
|
// Add the vertex deformations group (this needs to be done BEFORE adding
|
|
|
|
// the actual
|
|
|
|
// channels, seemingly due to a limitation in the TreeModel
|
|
|
|
// implementation)
|
|
|
|
plasticGroup->setChildren(plasticItems);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int pi,
|
|
|
|
piCount =
|
|
|
|
plasticItems.size(); // NOTE: plasticItems now stores only PART
|
|
|
|
for (pi = 0; pi != piCount;
|
|
|
|
++pi) // of the specified items - those considered
|
|
|
|
{ // 'new' by internal pointer comparison...
|
|
|
|
SkVDChannelGroup *vxGroup =
|
|
|
|
dynamic_cast<SkVDChannelGroup *>(plasticItems[pi]);
|
|
|
|
if (!vxGroup) continue;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
SkVD *skvd =
|
|
|
|
sd->vertexDeformation(vxGroup->ChannelGroup::getShortName());
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
for (int k = 0; k < SkVD::PARAMS_COUNT; ++k) {
|
|
|
|
// Add channel in the vertex deformation
|
|
|
|
Channel *channel = new Channel(this, skvd->m_params[k].getPointer());
|
|
|
|
channel->setChannelGroup(vxGroup);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
vxGroup->appendChild(channel);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
vxGroup->applyShowFilter();
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
plasticGroup->applyShowFilter();
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::addParameter(ChannelGroup *group,
|
|
|
|
const std::string &prefixString,
|
|
|
|
const std::wstring &fxId, TParam *param) {
|
|
|
|
if (TDoubleParam *dp = dynamic_cast<TDoubleParam *>(param)) {
|
|
|
|
Channel *channel = new Channel(this, dp, prefixString, fxId);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
group->appendChild(channel);
|
|
|
|
channel->setChannelGroup(group);
|
|
|
|
} else if (dynamic_cast<TPointParam *>(param) ||
|
|
|
|
dynamic_cast<TRangeParam *>(param) ||
|
|
|
|
dynamic_cast<TPixelParam *>(param)) {
|
|
|
|
TParamSet *paramSet = dynamic_cast<TParamSet *>(param);
|
|
|
|
assert(paramSet);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
std::string paramName = prefixString + param->getName();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
ChannelGroup *paramChannel = new ParamChannelGroup(param, fxId, paramName);
|
|
|
|
group->appendChild(paramChannel);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TPixelParam *pixParam = dynamic_cast<TPixelParam *>(param);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int p, paramCount = paramSet->getParamCount();
|
|
|
|
for (p = 0; p != paramCount; ++p) {
|
|
|
|
TDoubleParam *dp =
|
|
|
|
dynamic_cast<TDoubleParam *>(paramSet->getParam(p).getPointer());
|
|
|
|
if (!dp ||
|
|
|
|
(pixParam && !pixParam->isMatteEnabled() && p == paramCount - 1))
|
|
|
|
continue;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
Channel *channel = new Channel(this, dp, "", fxId);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
paramChannel->appendChild(channel);
|
|
|
|
channel->setChannelGroup(group);
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::addChannels(TFx *fx, ChannelGroup *groupItem,
|
|
|
|
TParamContainer *params) {
|
|
|
|
FxChannelGroup *fxItem = static_cast<FxChannelGroup *>(groupItem);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
std::wstring fxId = L"";
|
|
|
|
TMacroFx *macro = dynamic_cast<TMacroFx *>(fxItem->getFx());
|
2020-04-17 19:02:53 +12:00
|
|
|
if (macro) fxId = fx->getFxId();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
const std::string ¶mNamePref = fx->getFxType() + ".";
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int p, pCount = params->getParamCount();
|
|
|
|
for (p = 0; p != pCount; ++p)
|
|
|
|
addParameter(fxItem, paramNamePref, fxId, params->getParam(p));
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::addActiveChannels(TreeModel::Item *item) {
|
|
|
|
assert(item);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (Channel *channel = dynamic_cast<Channel *>(item)) {
|
|
|
|
if (channel->isActive()) m_activeChannels.push_back(channel);
|
|
|
|
} else
|
|
|
|
for (int i = 0; i < item->getChildCount(); i++)
|
|
|
|
addActiveChannels(item->getChild(i));
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::refreshActiveChannels() {
|
|
|
|
m_activeChannels.clear();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_stageObjects) addActiveChannels(m_stageObjects);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_fxs) addActiveChannels(m_fxs);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::onChannelDestroyed(Channel *channel) {
|
|
|
|
if (channel == m_currentChannel) m_currentChannel = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::Channel *FunctionTreeModel::getActiveChannel(
|
|
|
|
int index) const {
|
|
|
|
if (index < 0 || index >= (int)m_activeChannels.size())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return m_activeChannels[index];
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int FunctionTreeModel::getColumnIndexByCurve(TDoubleParam *param) const {
|
|
|
|
for (int i = 0; i < (int)m_activeChannels.size(); i++) {
|
|
|
|
if (m_activeChannels[i]->getParam() == param) return i;
|
|
|
|
}
|
|
|
|
return -1;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::ChannelGroup *FunctionTreeModel::getStageObjectChannel(
|
|
|
|
int index) const {
|
|
|
|
if (index < 0 || index >= (int)m_stageObjects->getChildCount())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return dynamic_cast<FunctionTreeModel::ChannelGroup *>(
|
|
|
|
m_stageObjects->getChild(index));
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::ChannelGroup *FunctionTreeModel::getFxChannel(
|
|
|
|
int index) const {
|
|
|
|
if (index < 0 || index >= (int)m_fxs->getChildCount())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return dynamic_cast<FunctionTreeModel::ChannelGroup *>(
|
|
|
|
m_fxs->getChild(index));
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::onChange(const TParamChange &tpc) {
|
|
|
|
if (!m_paramsChanged) {
|
|
|
|
m_paramsChanged = true;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
struct Func final : public TFunctorInvoker::BaseFunctor {
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel *m_obj;
|
2016-10-28 18:48:26 +13:00
|
|
|
// Use a copy of 'TParamChange' since callers declare
|
|
|
|
// and free this value on the stack,
|
|
|
|
// so we can't ensure its valid later on when the notifier executes.
|
|
|
|
const TParamChange m_tpc;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
Func(FunctionTreeModel *obj, const TParamChange *tpc)
|
2016-10-28 18:48:26 +13:00
|
|
|
: m_obj(obj), m_tpc(*tpc) {}
|
|
|
|
void operator()() override { m_obj->onParamChange(m_tpc.m_dragging); }
|
2016-06-15 18:43:10 +12:00
|
|
|
};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QMetaObject::invokeMethod(TFunctorInvoker::instance(), "invoke",
|
|
|
|
Qt::QueuedConnection,
|
|
|
|
Q_ARG(void *, new Func(this, &tpc)));
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::onParamChange(bool isDragging) {
|
|
|
|
m_paramsChanged = false;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
emit curveChanged(isDragging);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::resetAll() {
|
2016-03-19 06:57:51 +13:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
beginResetModel();
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
2016-06-15 18:43:10 +12:00
|
|
|
m_activeChannels.clear();
|
2016-11-24 15:10:50 +13:00
|
|
|
|
|
|
|
TreeModel::Item *root_item = getRootItem();
|
|
|
|
setRootItem_NoFree(NULL);
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_stageObjects = 0;
|
|
|
|
m_fxs = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
#if QT_VERSION < 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
reset();
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
beginRefresh();
|
|
|
|
refreshActiveChannels();
|
|
|
|
endRefresh();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-11-24 15:10:50 +13:00
|
|
|
// postpone until after refresh,
|
|
|
|
// since its members are used for reference.
|
|
|
|
delete root_item;
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_currentChannel = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#if QT_VERSION >= 0x050000
|
2016-06-15 18:43:10 +12:00
|
|
|
endResetModel();
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::setCurrentFx(TFx *fx) {
|
|
|
|
TZeraryColumnFx *zcfx = dynamic_cast<TZeraryColumnFx *>(fx);
|
2020-04-17 19:02:53 +12:00
|
|
|
if (zcfx) fx = zcfx->getZeraryFx();
|
2016-06-15 18:43:10 +12:00
|
|
|
if (fx != m_currentFx) {
|
|
|
|
if (fx) fx->addRef();
|
|
|
|
if (m_currentFx) m_currentFx->release();
|
|
|
|
m_currentFx = fx;
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::applyShowFilters() {
|
|
|
|
// WARNING: This is implemented BAD - notice that the get*() functions below
|
|
|
|
// DO NOT ACTUALLY RETURN CHANNELS, but rather the child
|
|
|
|
// ChannelGROUPS!
|
|
|
|
//
|
|
|
|
// This means that these show filters are presumably applied only to
|
|
|
|
// the FIRST LEVEL OF PARAMETERS...!
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_stageObjects) {
|
|
|
|
int so, soCount = m_stageObjects->getChildCount();
|
|
|
|
for (so = 0; so != soCount; ++so)
|
|
|
|
getStageObjectChannel(so)->applyShowFilter();
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_fxs) {
|
|
|
|
int fx, fxCount = m_fxs->getChildCount();
|
|
|
|
for (fx = 0; fx != fxCount; ++fx) getFxChannel(fx)->applyShowFilter();
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::addParameter(TParam *parameter,
|
|
|
|
const TFilePath &folder) {
|
|
|
|
struct locals {
|
|
|
|
static void locateExistingRoot(ChannelGroup *&root, TFilePath &fp) {
|
|
|
|
std::wstring firstName;
|
|
|
|
TFilePath tempFp;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
while (!fp.isEmpty()) {
|
|
|
|
// Get the path's first name
|
|
|
|
fp.split(firstName, tempFp);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// Search a matching channel group in root's children
|
|
|
|
int c, cCount = root->getChildCount();
|
|
|
|
for (c = 0; c != cCount; ++c) {
|
|
|
|
if (ChannelGroup *group =
|
|
|
|
dynamic_cast<ChannelGroup *>(root->getChild(c))) {
|
|
|
|
if (group->getShortName().toStdWString() == firstName) {
|
|
|
|
root = group, fp = tempFp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (c == cCount) break;
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static void addFolders(ChannelGroup *&group, TFilePath &fp) {
|
|
|
|
std::wstring firstName;
|
|
|
|
TFilePath tempFp;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
while (!fp.isEmpty()) {
|
|
|
|
fp.split(firstName, tempFp);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
ChannelGroup *newGroup =
|
|
|
|
new ChannelGroup(QString::fromStdWString(firstName));
|
|
|
|
group->appendChild(newGroup);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
group = newGroup, fp = tempFp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}; // locals
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// Search for the furthest existing channel group chain leading to our folder
|
|
|
|
ChannelGroup *group = static_cast<ChannelGroup *>(getRootItem());
|
|
|
|
assert(group);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TFilePath path = folder;
|
|
|
|
locals::locateExistingRoot(group, path);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// If the chain interrupts prematurely, create new groups up to the required
|
|
|
|
// folder
|
|
|
|
if (!path.isEmpty()) locals::addFolders(group, path);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(path.isEmpty());
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// Add the parameter to the last group
|
|
|
|
addParameter(group, "", L"", parameter);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// FunctionTreeView
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FunctionTreeView::FunctionTreeView(FunctionViewer *parent)
|
2020-05-21 19:46:42 +12:00
|
|
|
: TreeView(parent)
|
|
|
|
, m_scenePath()
|
|
|
|
, m_clickedItem(0)
|
|
|
|
, m_draggingChannel(0)
|
|
|
|
, m_viewer(parent) {
|
2016-06-15 18:43:10 +12:00
|
|
|
assert(parent);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
setModel(new FunctionTreeModel(this));
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
setObjectName("FunctionEditorTree");
|
|
|
|
setSelectionMode(QAbstractItemView::NoSelection);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
connect(this, SIGNAL(pressed(const QModelIndex &)), this,
|
|
|
|
SLOT(onActivated(const QModelIndex &)));
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
setIndentation(14);
|
|
|
|
setAlternatingRowColors(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FunctionTreeView::onActivated(const QModelIndex &index) {
|
|
|
|
enum {
|
|
|
|
NO_CHANNELS = 0x0,
|
|
|
|
ACTIVE_CHANNELS = 0x1,
|
|
|
|
INACTIVE_CHANNELS = 0x2,
|
|
|
|
HAS_CHANNELS = ACTIVE_CHANNELS | INACTIVE_CHANNELS
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!index.isValid()) return;
|
|
|
|
|
|
|
|
FunctionTreeModel *ftModel = (FunctionTreeModel *)model();
|
|
|
|
if (!ftModel) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
std::vector<FunctionTreeModel::Channel *> childChannels;
|
|
|
|
std::vector<FunctionTreeModel::ChannelGroup *> channelGroups;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// Scan for already active children - to decide whether to activate or
|
|
|
|
// deactivate them
|
|
|
|
int activeFlag = NO_CHANNELS;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TreeModel::Item *item =
|
|
|
|
static_cast<TreeModel::Item *>(index.internalPointer());
|
|
|
|
if (item) {
|
|
|
|
int c, cCount = item->getChildCount();
|
|
|
|
for (c = 0; c != cCount; ++c) {
|
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(item->getChild(c));
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (!channel) {
|
|
|
|
FunctionTreeModel::ChannelGroup *channelGroup =
|
|
|
|
dynamic_cast<FunctionTreeModel::ChannelGroup *>(item->getChild(c));
|
|
|
|
if (!channelGroup) continue;
|
|
|
|
channelGroups.push_back(channelGroup);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (channel->isHidden()) continue;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
childChannels.push_back(channel);
|
|
|
|
|
|
|
|
activeFlag |= (channel->isActive() ? ACTIVE_CHANNELS : INACTIVE_CHANNELS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open the item (ie show children) if it was closed AND not all its children
|
|
|
|
// were active
|
|
|
|
bool someInactiveChannels = (activeFlag != ACTIVE_CHANNELS);
|
|
|
|
|
|
|
|
if (someInactiveChannels && !isExpanded(index)) {
|
|
|
|
setExpanded(index, true);
|
|
|
|
ftModel->onExpanded(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
if (!childChannels.empty()) {
|
|
|
|
// Activate child channels if there is some inactive channel - deactivate
|
|
|
|
// otherwise
|
|
|
|
int c, cCount = childChannels.size();
|
|
|
|
for (c = 0; c != cCount; ++c)
|
|
|
|
childChannels[c]->setIsActive(someInactiveChannels);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
for (int i = 0; i < (int)channelGroups.size(); i++)
|
|
|
|
channelGroups[i]->setChildrenAllActive(someInactiveChannels);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
update();
|
|
|
|
} else {
|
|
|
|
// There was no child channel. Try to activate children groups.
|
|
|
|
int c, cCount = item->getChildCount();
|
|
|
|
for (c = 0; c != cCount; ++c)
|
|
|
|
onActivated(item->getChild(c)->createIndex());
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2020-05-23 09:31:30 +12:00
|
|
|
void FunctionTreeView::mouseDoubleClickEvent(QMouseEvent *event) {
|
|
|
|
emit(fit());
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::onClick(TreeModel::Item *item, const QPoint &itemPos,
|
|
|
|
QMouseEvent *e) {
|
|
|
|
m_draggingChannel = 0;
|
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(item);
|
|
|
|
FxChannelGroup *fxChannelGroup = dynamic_cast<FxChannelGroup *>(item);
|
|
|
|
StageObjectChannelGroup *stageObjectChannelGroup =
|
|
|
|
dynamic_cast<StageObjectChannelGroup *>(item);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_clickedItem = channel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (channel) {
|
|
|
|
fxChannelGroup = dynamic_cast<FxChannelGroup *>(channel->getParent());
|
|
|
|
stageObjectChannelGroup =
|
|
|
|
dynamic_cast<StageObjectChannelGroup *>(channel->getParent());
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int x = itemPos.x();
|
|
|
|
if (x >= 20)
|
|
|
|
channel->setIsCurrent(true);
|
|
|
|
else if (0 <= x && x < 20) {
|
|
|
|
channel->setIsActive(
|
|
|
|
(e->button() == Qt::RightButton) ? true : !channel->isActive());
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (fxChannelGroup) {
|
|
|
|
TFx *fx = fxChannelGroup->getFx();
|
|
|
|
emit switchCurrentFx(fx);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (stageObjectChannelGroup) {
|
|
|
|
TStageObject *obj = stageObjectChannelGroup->getStageObject();
|
|
|
|
emit switchCurrentObject(obj);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::onMidClick(TreeModel::Item *item, const QPoint &itemPos,
|
|
|
|
QMouseEvent *e) {
|
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(item);
|
|
|
|
if (channel && e->button() == Qt::MidButton) {
|
|
|
|
m_draggingChannel = channel;
|
|
|
|
m_dragStartPosition = e->pos();
|
|
|
|
} else
|
|
|
|
m_draggingChannel = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::onDrag(TreeModel::Item *item, const QPoint &itemPos,
|
|
|
|
QMouseEvent *e) {
|
|
|
|
// middle drag of the channel item can retrieve expression name
|
|
|
|
if ((e->buttons() & Qt::MidButton) && m_draggingChannel &&
|
|
|
|
(e->pos() - m_dragStartPosition).manhattanLength() >=
|
|
|
|
QApplication::startDragDistance()) {
|
|
|
|
QDrag *drag = new QDrag(this);
|
|
|
|
QMimeData *mimeData = new QMimeData;
|
|
|
|
mimeData->setText(m_draggingChannel->getExprRefName());
|
|
|
|
drag->setMimeData(mimeData);
|
|
|
|
static const QPixmap cursorPixmap(":Resources/dragcursor_exp_text.png");
|
|
|
|
drag->setDragCursor(cursorPixmap, Qt::MoveAction);
|
|
|
|
Qt::DropAction dropAction = drag->exec();
|
|
|
|
return;
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(item);
|
|
|
|
if (!channel || !m_clickedItem) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// i0: item under the current cursor position
|
|
|
|
// i1: clicked item
|
|
|
|
QModelIndex i0 = channel->createIndex(), i1 = m_clickedItem->createIndex();
|
|
|
|
if (!i0.isValid() || !i1.isValid() || i0.parent() != i1.parent()) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2018-08-30 20:18:43 +12:00
|
|
|
if (i0.row() > i1.row()) std::swap(i0, i1);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel *md = static_cast<FunctionTreeModel *>(model());
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool active = m_clickedItem->isActive();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
for (int row = i0.row(); row <= i1.row(); ++row) {
|
|
|
|
if (isRowHidden(row, i0.parent())) continue;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QModelIndex index = md->index(row, 0, i0.parent());
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TreeModel::Item *chItem =
|
|
|
|
static_cast<TreeModel::Item *>(index.internalPointer());
|
|
|
|
FunctionTreeModel::Channel *ch =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(chItem);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (ch && ch->isActive() != active) {
|
|
|
|
ch->setIsActive(active);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::onRelease() { m_clickedItem = 0; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::openContextMenu(TreeModel::Item *item,
|
|
|
|
const QPoint &globalPos) {
|
|
|
|
if (FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(item))
|
|
|
|
openContextMenu(channel, globalPos);
|
|
|
|
else if (FunctionTreeModel::ChannelGroup *group =
|
|
|
|
dynamic_cast<FunctionTreeModel::ChannelGroup *>(item))
|
|
|
|
openContextMenu(group, globalPos);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::openContextMenu(FunctionTreeModel::Channel *channel,
|
|
|
|
const QPoint &globalPos) {
|
|
|
|
assert(channel);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2020-05-21 19:46:42 +12:00
|
|
|
if (!m_viewer) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QMenu menu;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QAction saveCurveAction(tr("Save Curve"), 0);
|
|
|
|
QAction loadCurveAction(tr("Load Curve"), 0);
|
|
|
|
QAction exportDataAction(tr("Export Data"), 0);
|
|
|
|
menu.addAction(&saveCurveAction);
|
|
|
|
menu.addAction(&loadCurveAction);
|
|
|
|
menu.addAction(&exportDataAction);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QAction *action = menu.exec(globalPos);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TDoubleParam *curve = channel->getParam();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (action == &saveCurveAction)
|
2020-05-21 19:46:42 +12:00
|
|
|
m_viewer->emitIoCurve((int)FunctionViewer::eSaveCurve, curve, "");
|
2016-06-15 18:43:10 +12:00
|
|
|
else if (action == &loadCurveAction)
|
2020-05-21 19:46:42 +12:00
|
|
|
m_viewer->emitIoCurve((int)FunctionViewer::eLoadCurve, curve, "");
|
2016-06-15 18:43:10 +12:00
|
|
|
else if (action == &exportDataAction)
|
2020-05-21 19:46:42 +12:00
|
|
|
m_viewer->emitIoCurve((int)FunctionViewer::eExportCurve, curve,
|
|
|
|
channel->getLongName().toStdString());
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::openContextMenu(FunctionTreeModel::ChannelGroup *group,
|
|
|
|
const QPoint &globalPos) {
|
|
|
|
assert(group);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QMenu menu;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QAction showAnimateOnly(tr("Show Animated Only"), 0);
|
|
|
|
QAction showAll(tr("Show All"), 0);
|
|
|
|
menu.addAction(&showAnimateOnly);
|
|
|
|
menu.addAction(&showAll);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// execute menu
|
|
|
|
QAction *action = menu.exec(globalPos);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (action != &showAll && action != &showAnimateOnly) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionTreeModel::ChannelGroup::ShowFilter showFilter =
|
|
|
|
(action == &showAll)
|
|
|
|
? FunctionTreeModel::ChannelGroup::ShowAllChannels
|
|
|
|
: FunctionTreeModel::ChannelGroup::ShowAnimatedChannels;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
expand(group->createIndex());
|
|
|
|
group->setShowFilter(showFilter);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::updateAll() {
|
|
|
|
FunctionTreeModel *functionTreeModel =
|
|
|
|
dynamic_cast<FunctionTreeModel *>(model());
|
|
|
|
assert(functionTreeModel);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
functionTreeModel->applyShowFilters();
|
|
|
|
update();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/*! show all the animated channels when the scene switched
|
2020-01-15 22:26:05 +13:00
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeView::displayAnimatedChannels() {
|
|
|
|
FunctionTreeModel *functionTreeModel =
|
|
|
|
dynamic_cast<FunctionTreeModel *>(model());
|
|
|
|
assert(functionTreeModel);
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < functionTreeModel->getStageObjectsChannelCount(); i++)
|
|
|
|
functionTreeModel->getStageObjectChannel(i)->displayAnimatedChannels();
|
|
|
|
for (i = 0; i < functionTreeModel->getFxsChannelCount(); i++)
|
|
|
|
functionTreeModel->getFxChannel(i)->displayAnimatedChannels();
|
|
|
|
update();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/*! show all the animated channels when the scene switched
|
2020-01-15 22:26:05 +13:00
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
void FunctionTreeModel::ChannelGroup::displayAnimatedChannels() {
|
|
|
|
int itemCount = getChildCount();
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < itemCount; i++) {
|
|
|
|
FunctionTreeModel::Channel *channel =
|
|
|
|
dynamic_cast<FunctionTreeModel::Channel *>(getChild(i));
|
|
|
|
if (!channel) {
|
|
|
|
FunctionTreeModel::ChannelGroup *channelGroup =
|
|
|
|
dynamic_cast<FunctionTreeModel::ChannelGroup *>(getChild(i));
|
|
|
|
if (!channelGroup) continue;
|
|
|
|
|
|
|
|
channelGroup->displayAnimatedChannels();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
channel->setIsActive(channel->getParam()->hasKeyframes());
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|