Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Feat(StylePicker): Add Replace Style Option

Abel Youe79af2f2d5d0
diff --git a/toonz/sources/tnztools/stylepickertool.cpp b/toonz/sources/tnztools/stylepickertool.cpp
index 7a4afeba1..3327ad651 100644
--- a/toonz/sources/tnztools/stylepickertool.cpp
+++ b/toonz/sources/tnztools/stylepickertool.cpp
@@ -10,6 +10,7 @@
#include "toonzqt/tselectionhandle.h"
#include "toonzqt/styleselection.h"
#include "toonzqt/gutil.h"
+#include "toonzqt/icongenerator.h"
// TnzLib includes
#include "toonz/txshsimplelevel.h"
@@ -44,6 +45,7 @@ StylePickerTool::StylePickerTool()
: TTool("T_StylePicker")
, m_currentStyleId(0)
, m_colorType("Mode:")
+ , m_replaceStyle("Replace Style", false)
, m_passivePick("Passive Pick", false)
, m_organizePalette("Organize Palette", false) {
m_prop.bind(m_colorType);
@@ -56,12 +58,15 @@ StylePickerTool::StylePickerTool()
m_prop.bind(m_passivePick);
m_passivePick.setId("PassivePick");
+ m_prop.bind(m_replaceStyle);
+ m_replaceStyle.setId("ReplaceStyle");
+
m_prop.bind(m_organizePalette);
m_organizePalette.setId("OrganizePalette");
}
void StylePickerTool::onActivate() {
- TPaletteHandle *ph = getApplication()->getCurrentPalette();
+ TPaletteHandle* ph = getApplication()->getCurrentPalette();
if (ph) {
bool ret = connect(ph, &TPaletteHandle::paletteSwitched, this,
&StylePickerTool::onPaletteSwitched);
@@ -74,17 +79,17 @@ void StylePickerTool::onDeactivate() {
&StylePickerTool::onPaletteSwitched);
}
-void StylePickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
+void StylePickerTool::leftButtonDown(const TPointD& pos, const TMouseEvent& e) {
m_oldStyleId = m_currentStyleId =
getApplication()->getCurrentLevelStyleIndex();
pick(pos, e, false);
}
-void StylePickerTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
+void StylePickerTool::leftButtonDrag(const TPointD& pos, const TMouseEvent& e) {
pick(pos, e);
}
-void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
+void StylePickerTool::pick(const TPointD& pos, const TMouseEvent& e,
bool isDragging) {
// Area = 0, Line = 1, All = 2
int modeValue = m_colorType.getIndex();
@@ -116,7 +121,7 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
TImageP pickedImage = pickedCell.getImage(false).getPointer();
TToonzImageP picked_ti = pickedImage;
TVectorImageP picked_vi = pickedImage;
- TXshSimpleLevel *picked_level = pickedCell.getSimpleLevel();
+ TXshSimpleLevel* picked_level = pickedCell.getSimpleLevel();
if ((picked_ti || picked_vi) && picked_level) {
TPointD tmpMousePosition = getColumnMatrix(superPickedColumnId).inv() *
getViewer()->winToWorld(e.m_pos);
@@ -162,7 +167,7 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
TImageP image = getImage(false);
TToonzImageP ti = image;
TVectorImageP vi = image;
- TXshSimpleLevel *level =
+ TXshSimpleLevel* level =
getApplication()->getCurrentLevel()->getSimpleLevel();
if ((!ti && !vi) || !level) return;
@@ -193,11 +198,10 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
}
/*--- Styleを選択している場合は選択を解除する ---*/
- TSelection *selection =
+ TSelection* selection =
TTool::getApplication()->getCurrentSelection()->getSelection();
if (selection) {
- TStyleSelection *styleSelection =
- dynamic_cast<TStyleSelection *>(selection);
+ TStyleSelection* styleSelection = dynamic_cast<TStyleSelection*>(selection);
if (styleSelection) styleSelection->selectNone();
}
@@ -209,16 +213,16 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
getApplication()->setCurrentLevelStyleIndex(styleId, !isDragging);
}
-void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
+void StylePickerTool::mouseMove(const TPointD& pos, const TMouseEvent& e) {
if (!m_passivePick.getValue()) return;
/*--- PassiveにStyleを拾う機能 ---*/
- PaletteController *controller =
+ PaletteController* controller =
TTool::getApplication()->getPaletteController();
TImageP image = getImage(false);
TToonzImageP ti = image;
TVectorImageP vi = image;
- TXshSimpleLevel *level =
+ TXshSimpleLevel* level =
getApplication()->getCurrentLevel()->getSimpleLevel();
if ((!ti && !vi) || !level || !m_viewer->getGeometry().contains(pos)) {
controller->notifyStylePassivePicked(-1, -1, -1);
@@ -262,6 +266,31 @@ int StylePickerTool::getCursorId() const {
return ret;
}
+TPalette* StylePickerTool::getPal() {
+ TXshLevel* level = getApplication()->getCurrentLevel()->getLevel();
+ if (!level) {
+ DVGui::error(tr("No current level."));
+ return nullptr;
+ }
+ if (level->getType() != PLI_XSHLEVEL && level->getType() != TZP_XSHLEVEL &&
+ (m_organizePalette.getValue() ? level->getType() != PLT_XSHLEVEL
+ : true)) {
+ DVGui::error(tr("Current level has no available palette."));
+ return nullptr;
+ }
+ TPalette* pal = nullptr;
+ if (level->getType() == PLT_XSHLEVEL)
+ pal = level->getPaletteLevel()->getPalette();
+ else
+ pal = level->getSimpleLevel()->getPalette();
+
+ if (!pal) {
+ DVGui::error(tr("No available palette."));
+ return nullptr;
+ }
+ return pal;
+}
+
bool StylePickerTool::onPropertyChanged(std::string propertyName) {
if (propertyName == m_organizePalette.getName()) {
if (m_organizePalette.getValue()) {
@@ -269,36 +298,38 @@ bool StylePickerTool::onPropertyChanged(std::string propertyName) {
m_organizePalette.setValue(false);
getApplication()->getCurrentTool()->notifyToolChanged();
return false;
- }
+ } else
+ m_replaceStyle.setValue(false);
} else {
std::cout << "End Organize Palette" << std::endl;
}
+ } else if (propertyName == m_replaceStyle.getName()) {
+ if (m_replaceStyle.getValue()) {
+ if (!getPal()) {
+ m_replaceStyle.setValue(false);
+ return false;
+ } else
+ m_organizePalette.setValue(false);
+ } else {
+ TXshLevel* xl = TTool::getApplication()->getCurrentLevel()->getLevel();
+ if (xl) {
+ std::vector<TFrameId> fids;
+ xl->getFids(fids);
+ for (TFrameId fid : fids)
+ IconGenerator::instance()->invalidate(xl, fid);
+ }
+ }
+ return true;
}
-
- return true;
}
+/* Check if the organizing operation is available */
bool StylePickerTool::startOrganizePalette() {
- /* Check if the organizing operation is available */
- TXshLevel *level = getApplication()->getCurrentLevel()->getLevel();
- if (!level) {
- DVGui::error(tr("No current level."));
- return false;
- }
- if (level->getType() != PLI_XSHLEVEL && level->getType() != TZP_XSHLEVEL &&
- level->getType() != PLT_XSHLEVEL) {
- DVGui::error(tr("Current level has no available palette."));
- return false;
- }
/* palette should have more than one page to organize */
- TPalette *pal = NULL;
- if (level->getType() == PLT_XSHLEVEL)
- pal = level->getPaletteLevel()->getPalette();
- else
- pal = level->getSimpleLevel()->getPalette();
- if (!pal || pal->getPageCount() < 2) {
- DVGui::error(
- tr("Palette must have more than one palette to be organized."));
+ TPalette* pal = getPal();
+ if (!pal) return false;
+ if (pal->getPageCount() < 2) {
+ DVGui::error(tr("Palette to be organized must have more than one page."));
return false;
}
@@ -309,14 +340,14 @@ bool StylePickerTool::startOrganizePalette() {
/*
If the working palette is changed, then deactivate the "organize palette"
- toggle.
+ and "replace style" toggle.
*/
void StylePickerTool::onPaletteSwitched() {
- m_organizePalette.setValue(false);
- getApplication()->getCurrentTool()->notifyToolChanged();
- return;
- }
-
+ m_organizePalette.setValue(false);
+ m_replaceStyle.setValue(false);
+ getApplication()->getCurrentTool()->notifyToolChanged();
+ return;
+}
//-------------------------------------------------------------------------------------------------------
void StylePickerTool::updateTranslation() {
diff --git a/toonz/sources/tnztools/stylepickertool.h b/toonz/sources/tnztools/stylepickertool.h
index 9d0d08677..3f019536e 100644
--- a/toonz/sources/tnztools/stylepickertool.h
+++ b/toonz/sources/tnztools/stylepickertool.h
@@ -5,9 +5,17 @@
#include "tools/tool.h"
#include "tproperty.h"
-#include <QObject>
-// For Qt translation support
-#include <QCoreApplication>
+
+#include "toonz/toonzimageutils.h"
+#include "toonz/ttilesaver.h"
+#include "toonz/ttileset.h"
+
+#include "toonz/tpalettehandle.h"
+#include "toonz/txshlevelhandle.h"
+#include "tstroke.h"
+#include "toonz/txshsimplelevel.h"
+
+#include "toonzqt/icongenerator.h"
class StylePickerTool final : public TTool, public QObject {
Q_DECLARE_TR_FUNCTIONS(StylePickerTool)
@@ -16,10 +24,12 @@ class StylePickerTool final : public TTool, public QObject {
TEnumProperty m_colorType;
TPropertyGroup m_prop;
+ TBoolProperty m_replaceStyle;
TBoolProperty m_passivePick;
TBoolProperty m_organizePalette;
+ TPalette *getPal();
bool startOrganizePalette();
public:
@@ -47,16 +57,276 @@ public:
bool onPropertyChanged(std::string propertyName) override;
bool isOrganizePaletteActive() { return m_organizePalette.getValue(); }
+ bool isReplaceStyleActive() { return m_replaceStyle.getValue(); }
void updateTranslation() override;
public slots:
/*
This function is called when working paltte is switched
- If the working palette is changed, then deactivate the "organize palette"
- toggle.
- */
+ If the working palette is changed, then deactivate the "organize palette"
+ toggle.
+*/
void onPaletteSwitched();
};
+namespace {
+
+void replaceStyle(const TVectorImageP &vi, int styleId, int oldStyleId,
+ std::vector<IntPair> *modifiedStrokes,
+ std::vector<IntPair> *modifiedRegions) {
+ std::vector<int> indexs;
+
+ for (int i = 0; i < vi->getStrokeCount(); ++i) {
+ TStroke *stroke = vi->getStroke(i);
+ if (stroke->getStyle() == oldStyleId) {
+ if (modifiedStrokes) modifiedStrokes->emplace_back(i, oldStyleId);
+ stroke->setStyle(styleId);
+ indexs.push_back(i);
+ }
+ }
+ // vi->notifyChangedStrokes(indexs, {});
+ for (int i = 0; i < vi->getRegionCount(); ++i) {
+ TRegion *region = vi->getRegion(i);
+ if (region->getStyle() == oldStyleId) {
+ if (modifiedRegions) modifiedRegions->emplace_back(i, oldStyleId);
+ region->setStyle(styleId);
+ }
+ }
+ // vi->validateRegions();
+}
+
+void replaceStyle(const TRasterCM32P &r, int styleId, int oldStyleId,
+ TTileSaverCM32 *saver) {
+ for (int y = 0; y < r->getLy(); y++) {
+ TPixelCM32 *pix = r->pixels(y), *endPix = pix + r->getLx();
+
+ if (saver) {
+ std::vector<std::pair<int, int>> segments;
+ int startX = -1;
+
+ TPixelCM32 *scanPix = pix;
+ for (int x = 0; scanPix < endPix; x++, scanPix++) {
+ bool needsChange = (scanPix->getInk() == oldStyleId ||
+ scanPix->getPaint() == oldStyleId);
+
+ if (needsChange) {
+ if (startX == -1) startX = x;
+ } else {
+ if (startX != -1) {
+ segments.emplace_back(startX, x - 1);
+ startX = -1;
+ }
+ }
+ }
+
+ if (startX != -1) {
+ segments.emplace_back(startX, r->getLx() - 1);
+ }
+
+ for (const auto &seg : segments) {
+ saver->save(TRect(seg.first, y, seg.second, y));
+ }
+
+ for (const auto &seg : segments) {
+ for (int x = seg.first; x <= seg.second; x++) {
+ TPixelCM32 *p = pix + x;
+ if (p->getInk() == oldStyleId) p->setInk(styleId);
+ if (p->getPaint() == oldStyleId) p->setPaint(styleId);
+ }
+ }
+ } else {
+ for (int x = 0; pix < endPix; x++, pix++) {
+ if (pix->getInk() == oldStyleId) pix->setInk(styleId);
+ if (pix->getPaint() == oldStyleId) pix->setPaint(styleId);
+ }
+ }
+ }
+}
+
+class ReplaceStyleUndo final : public TUndo {
+ TXshLevelHandle *m_levelHandle;
+ TPaletteHandle *m_paletteHandler;
+ TPalette *m_palette;
+ TXshSimpleLevel *m_level;
+ int m_styleId, m_oldStyleId;
+ int m_levelType;
+ std::map<TFrameId, TTileSetCM32 *> m_tileSets;
+ std::map<TFrameId, std::pair<std::vector<IntPair>, std::vector<IntPair>>>
+ m_modifiedStrokeRegions;
+
+ void notifyLevelChanged() const {
+ if (m_level) {
+ m_level->getProperties()->setDirtyFlag(true);
+ m_levelHandle->notifyLevelChange();
+ std::vector<TFrameId> fids;
+ m_level->getFids(fids);
+ for (TFrameId fid : fids)
+ IconGenerator::instance()->invalidate(m_level, fid);
+ }
+ };
+
+public:
+ ReplaceStyleUndo(TXshLevelHandle *levelHandler, TPaletteHandle *paletteHandle,
+ int styleId, int oldStyleId)
+ : m_levelHandle(levelHandler)
+ , m_paletteHandler(paletteHandle)
+ , m_palette(paletteHandle->getPalette())
+ , m_level(levelHandler->getSimpleLevel())
+ , m_styleId(styleId)
+ , m_oldStyleId(oldStyleId) {
+ if (!m_level || !m_palette) return;
+ std::vector<TFrameId> fids;
+ m_level->getFids(fids);
+ m_levelType = m_level->getType() == TXshLevelType::TZP_XSHLEVEL ? 1
+ : m_level->getType() == TXshLevelType::PLI_XSHLEVEL ? 2
+ : 0;
+ if (!m_levelType) return;
+ if (m_levelType == 1)
+ for (const TFrameId &fid : fids) {
+ TToonzImageP ti = m_level->getFrame(fid, true);
+ if (!ti) continue;
+
+ TRasterCM32P ras = ti->getRaster();
+ if (!ras) continue;
+
+ TTileSetCM32 *tileSet = new TTileSetCM32(ras->getSize());
+
+ TTileSaverCM32 saver(ras, tileSet);
+
+ replaceStyle(ras, m_styleId, m_oldStyleId, &saver);
+ if (saver.getTileSet()->getTileCount() == 0) {
+ delete tileSet;
+ continue;
+ }
+ m_tileSets[fid] = tileSet;
+ }
+ else
+ for (const TFrameId &fid : fids) {
+ TVectorImageP vi = m_level->getFrame(fid, true);
+ if (!vi) continue;
+ std::vector<IntPair> modifiedStrokes;
+ std::vector<IntPair> modifiedRegions;
+
+ replaceStyle(vi, m_styleId, m_oldStyleId, &modifiedStrokes,
+ &modifiedRegions);
+ if (modifiedStrokes.empty() && modifiedRegions.empty())
+ continue;
+ else
+ m_modifiedStrokeRegions[fid] = std::make_pair(
+ std::move(modifiedStrokes), std::move(modifiedRegions));
+ }
+ notifyLevelChanged();
+ paletteHandle->setStyleIndex(styleId);
+ }
+ ~ReplaceStyleUndo() {
+ for (auto &pair : m_tileSets) {
+ delete pair.second;
+ }
+ m_tileSets.clear();
+ };
+
+ void redo() const override {
+ if (!m_level) return;
+
+ if (m_levelType == 1)
+ for (auto const [fid, tileSet] : m_tileSets) {
+ auto it = m_tileSets.find(fid);
+ if (it == m_tileSets.end()) continue;
+
+ TToonzImageP img = m_level->getFrame(fid, true);
+ if (!img) continue;
+
+ TRasterCM32P ras = img->getRaster();
+ if (!ras) continue;
+
+ replaceStyle(ras, m_styleId, m_oldStyleId, nullptr);
+ }
+ else
+ for (auto const [fid, pair] : m_modifiedStrokeRegions) {
+ TVectorImageP vi = m_level->getFrame(fid, true);
+ if (!vi) continue;
+ replaceStyle(vi, m_styleId, m_oldStyleId, nullptr, nullptr);
+ }
+
+ m_levelHandle->setLevel(m_level);
+ notifyLevelChanged();
+ if (m_palette && m_paletteHandler) m_paletteHandler->setPalette(m_palette);
+ if (m_paletteHandler) m_paletteHandler->setStyleIndex(m_styleId);
+ };
+
+ void undo() const override {
+ if (!m_level) return;
+
+ if (m_levelType == 1)
+ for (auto const [fid, tileSet] : m_tileSets) {
+ TToonzImageP img = m_level->getFrame(fid, true);
+ if (img && tileSet) {
+ ToonzImageUtils::paste(img, tileSet);
+ m_level->setFrame(fid, img);
+ }
+ }
+ else
+ for (auto const [fid, pair] : m_modifiedStrokeRegions) {
+ TVectorImageP vi = m_level->getFrame(fid, true);
+ if (!vi) continue;
+ std::vector<int> indexs;
+ for (auto const [index, id] : pair.first) {
+ TStroke *stroke = vi->getStroke(index);
+ if (stroke) {
+ stroke->setStyle(id);
+ indexs.push_back(index);
+ }
+ }
+ // vi->notifyChangedStrokes(indexs, {});
+ for (auto const [index, id] : pair.second) {
+ TRegion *region = vi->getRegion(index);
+ if (region) {
+ region->setStyle(id);
+ }
+ }
+ // vi->validateRegions();
+ }
+ m_levelHandle->setLevel(m_level);
+ notifyLevelChanged();
+ if (m_palette && m_paletteHandler) m_paletteHandler->setPalette(m_palette);
+ if (m_paletteHandler) m_paletteHandler->setStyleIndex(m_oldStyleId);
+ };
+
+ int getSize() const override {
+ int size = sizeof(*this);
+ for (const auto &pair : m_tileSets) {
+ if (pair.second) {
+ size += pair.second->getMemorySize();
+ }
+ }
+ return size;
+ };
+
+ QString getHistoryString() override {
+ return QString("Replace Level %1 Style: #%2 -> #%3")
+ .arg(m_level ? QString::fromStdWString(m_level->getName()) : QString())
+ .arg(m_oldStyleId)
+ .arg(m_styleId);
+ };
+};
+
+} // namespace
+
+/* called in ColorModelViewer::pick() - replace current style with selected
+ * style */
+static void replaceLevelStyle(TXshLevelHandle *levelHandle,
+ TPaletteHandle *paletteHandle, int styleId,
+ int oldStyleId) {
+ TXshSimpleLevel *level = levelHandle->getSimpleLevel();
+ TPalette *palette = paletteHandle->getPalette();
+ if (!palette || !level) return;
+ if (!palette || styleId == oldStyleId) return;
+ auto style = palette->getStyle(styleId);
+
+ ReplaceStyleUndo *undo =
+ new ReplaceStyleUndo(levelHandle, paletteHandle, styleId, oldStyleId);
+ // undo->redo();
+ TUndoManager::manager()->add(undo);
+}
#endif
diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp
index 2ae9131f3..3b96843bd 100644
--- a/toonz/sources/tnztools/tooloptions.cpp
+++ b/toonz/sources/tnztools/tooloptions.cpp
@@ -2609,10 +2609,17 @@ StylePickerToolOptionsBox::StylePickerToolOptionsBox(
// into rightmost of the tool option bar
ToolOptionCheckbox *organizePaletteCB =
dynamic_cast<ToolOptionCheckbox *>(m_controls.value("Organize Palette"));
+ ToolOptionCheckbox *replaceStyleCB =
+ dynamic_cast<ToolOptionCheckbox *>(m_controls.value("Replace Style"));
m_layout->removeWidget(organizePaletteCB);
+ m_layout->removeWidget(replaceStyleCB);
// m_layout->addWidget(new ToolOptionsBarSeparator(this), 0);
+ m_layout->addWidget(replaceStyleCB);
m_layout->addWidget(organizePaletteCB);
m_layout->addSpacing(5);
+ replaceStyleCB->setToolTip(
+ tr("With this option being activated, the picked style will replace\n"
+ "the current style in current level."));
organizePaletteCB->setToolTip(
tr("With this option being activated, the picked style will be\nmoved to "
"the end of the first page of the palette."));
@@ -2842,7 +2849,7 @@ RotateToolOptionsBox::RotateToolOptionsBox(QWidget *parent, TTool *tool,
button->addAction(resetRotationAction);
connect(button, SIGNAL(clicked()), resetRotationAction, SLOT(trigger()));
-
+
m_layout->addStretch(1);
m_layout->addWidget(button, 0);
m_layout->addSpacing(5);
diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cpp
index 522fcbeac..dfee616cd 100644
--- a/toonz/sources/toonz/colormodelviewer.cpp
+++ b/toonz/sources/toonz/colormodelviewer.cpp
@@ -95,8 +95,8 @@ ColorModelViewer::ColorModelViewer(QWidget *parent)
FlipConsole::eFlipVertical, FlipConsole::eResetView}),
eDontKeepFilesOpened, true)
, m_mode(0)
- , m_currentRefImgPath(TFilePath()),
- m_alwaysPickLineStyle(false) {
+ , m_currentRefImgPath(TFilePath())
+ , m_alwaysPickLineStyle(false) {
setObjectName("colormodel");
pickLineStyles = new QToolButton(this);
@@ -119,7 +119,7 @@ ColorModelViewer::ColorModelViewer(QWidget *parent)
bool ret = connect(this, SIGNAL(refImageNotFound()), this,
SLOT(onRefImageNotFound()), Qt::QueuedConnection);
- ret = ret && connect(pickLineStyles, &QToolButton::clicked, this,
+ ret = ret && connect(pickLineStyles, &QToolButton::clicked, this,
[this](bool clicked) {
m_alwaysPickLineStyle = clicked;
changePickType();
@@ -313,6 +313,8 @@ void ColorModelViewer::pick(const QPoint &p) {
TPaletteHandle *ph =
TApp::instance()->getPaletteController()->getCurrentLevelPalette();
TPalette *currentPalette = ph->getPalette();
+ TXshLevelHandle *lh = TApp::instance()->getCurrentLevel();
+ TXshSimpleLevel *level = lh->getSimpleLevel();
if (!currentPalette) return;
/*- 画面外ではPickできない -*/
@@ -362,12 +364,20 @@ void ColorModelViewer::pick(const QPoint &p) {
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
if (tool->getName() == "T_StylePicker") {
StylePickerTool *spTool = dynamic_cast<StylePickerTool *>(tool);
- if (spTool && spTool->isOrganizePaletteActive()) {
- TPoint point = picker.getRasterPoint(pos);
- int frame = m_flipConsole->getCurrentFrame() - 1;
- PaletteCmd::organizePaletteStyle(
- ph, styleIndex, TColorStyle::PickedPosition(point, frame));
- }
+ if (spTool)
+ if (spTool->isOrganizePaletteActive()) {
+ TPoint point = picker.getRasterPoint(pos);
+ int frame = m_flipConsole->getCurrentFrame() - 1;
+ PaletteCmd::organizePaletteStyle(
+ ph, styleIndex, TColorStyle::PickedPosition(point, frame));
+ return;
+ } else if (spTool->isReplaceStyleActive() && level &&
+ level->getPalette() == currentPalette) {
+ TPoint point = picker.getRasterPoint(pos);
+ int frame = m_flipConsole->getCurrentFrame() - 1;
+ replaceLevelStyle(lh, ph, styleIndex, ph->getStyleIndex());
+ return;
+ }
}
ph->setStyleIndex(styleIndex);
@@ -402,7 +412,7 @@ void ColorModelViewer::showEvent(QShowEvent *e) {
bool ret = connect(paletteHandle, SIGNAL(paletteSwitched()), this,
SLOT(showCurrentImage()));
ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()), this,
- SLOT(showCurrentImage()));
+ SLOT(showCurrentImage()));
ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,
SLOT(showCurrentImage()));
/*- ツールのTypeに合わせてPickのタイプも変え、カーソルも切り替える -*/
@@ -456,8 +466,8 @@ void ColorModelViewer::changePickType() {
setToolCursor(m_imageViewer, ToolCursor::PickerCursorLine);
} else if (var == AREAS) {
if (m_alwaysPickLineStyle)
- m_mode = 2;// Areas & Line
- else
+ m_mode = 2; // Areas & Line
+ else
m_mode = 0;
setToolCursor(m_imageViewer, ToolCursor::PickerCursorArea);
} else // Line & Areas
@@ -468,7 +478,6 @@ void ColorModelViewer::changePickType() {
pickLineStyles->setEnabled(var == AREAS);
pickLineStyles->setChecked(m_mode != 0);
}
-
}
//-----------------------------------------------------------------------------