|
shun-iwasawa |
dd780b |
#include "colormodelbehaviorpopup.h"
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
#include "toonzqt/colorfield.h"
|
|
shun-iwasawa |
dd780b |
#include "toonzqt/intfield.h"
|
|
shun-iwasawa |
dd780b |
#include "toonzqt/gutil.h"
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
#include "tenv.h"
|
|
shun-iwasawa |
dd780b |
#include "tpixel.h"
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
#include <qlabel></qlabel>
|
|
shun-iwasawa |
dd780b |
#include <qcolor></qcolor>
|
|
shun-iwasawa |
dd780b |
#include <qbuttongroup></qbuttongroup>
|
|
shun-iwasawa |
dd780b |
#include <qradiobutton></qradiobutton>
|
|
shun-iwasawa |
dd780b |
#include <qgroupbox></qgroupbox>
|
|
shun-iwasawa |
dd780b |
#include <qcombobox></qcombobox>
|
|
shun-iwasawa |
dd780b |
#include <qpushbutton></qpushbutton>
|
|
shun-iwasawa |
dd780b |
#include <qgridlayout></qgridlayout>
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
TEnv::IntVar ColorModelBehavior_PaletteOperation(
|
|
shun-iwasawa |
dd780b |
"ColorModelBehavior_PaletteOperation", 0);
|
|
shun-iwasawa |
dd780b |
// moved from preferences to env
|
|
shun-iwasawa |
dd780b |
TEnv::IntVar ColorModelBehavior_RasterImagePickType(
|
|
shun-iwasawa |
dd780b |
"ColorModelBehavior_RasterImagePickType", 0);
|
|
shun-iwasawa |
dd780b |
TEnv::StringVar ColorModelBehavior_ChipGridColor(
|
|
shun-iwasawa |
dd780b |
"ColorModelBehavior_ChipGridColor", "#FF00FF");
|
|
shun-iwasawa |
dd780b |
TEnv::IntVar ColorModelBehavior_ChipGridLineWidth(
|
|
shun-iwasawa |
dd780b |
"ColorModelBehavior_ChipGridLineWidth", 2);
|
|
shun-iwasawa |
dd780b |
TEnv::IntVar ColorModelBehavior_ChipOrder("ColorModelBehavior_ChipOrder", 0);
|
|
shun-iwasawa |
dd780b |
//-------------------------------------------------------------------
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
ColorModelBehaviorPopup::ColorModelBehaviorPopup(
|
|
shun-iwasawa |
dd780b |
const std::set<tfilepath>& paths, QWidget* parent)</tfilepath>
|
|
shun-iwasawa |
dd780b |
: Dialog(parent, true, true) {
|
|
shun-iwasawa |
dd780b |
setWindowTitle(tr("Select the Palette Operation"));
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
// check if the paths contain standard raster image (i.e. without palette)
|
|
shun-iwasawa |
dd780b |
// N.B. note that paths must contain only one path for now
|
|
shun-iwasawa |
dd780b |
for (auto itr = paths.begin(); itr != paths.end(); ++itr) {
|
|
shun-iwasawa |
dd780b |
std::string type((*itr).getType());
|
|
shun-iwasawa |
dd780b |
if (type != "tlv" && type != "pli") {
|
|
shun-iwasawa |
dd780b |
m_hasRasterImage = true;
|
|
shun-iwasawa |
dd780b |
break;
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
m_buttonGroup = new QButtonGroup(this);
|
|
shun-iwasawa |
dd780b |
QRadioButton* keepColorModelPltButton =
|
|
shun-iwasawa |
dd780b |
new QRadioButton(tr("Overwrite the destination palette."));
|
|
shun-iwasawa |
dd780b |
QRadioButton* replaceColorModelPltButton = new QRadioButton(
|
|
shun-iwasawa |
dd780b |
tr("Keep the destination palette and apply it to the color model."));
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->addButton(keepColorModelPltButton);
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->addButton(replaceColorModelPltButton);
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->setId(keepColorModelPltButton, PaletteCmd::KeepColorModelPlt);
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->setId(replaceColorModelPltButton,
|
|
shun-iwasawa |
dd780b |
PaletteCmd::ReplaceColorModelPlt);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QLabel* label =
|
|
shun-iwasawa |
dd780b |
new QLabel(tr("The color model palette is different from the destination "
|
|
shun-iwasawa |
dd780b |
"palette.\nWhat do you want to do? "));
|
|
shun-iwasawa |
dd780b |
label->setAlignment(Qt::AlignLeft);
|
|
shun-iwasawa |
dd780b |
m_topLayout->addWidget(label);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QGroupBox* paletteBox = new QGroupBox(this);
|
|
shun-iwasawa |
dd780b |
QVBoxLayout* paletteLay = new QVBoxLayout();
|
|
shun-iwasawa |
dd780b |
paletteLay->setMargin(15);
|
|
shun-iwasawa |
dd780b |
paletteLay->setSpacing(15);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
paletteLay->addWidget(keepColorModelPltButton);
|
|
shun-iwasawa |
dd780b |
paletteLay->addWidget(replaceColorModelPltButton);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
paletteBox->setLayout(paletteLay);
|
|
shun-iwasawa |
dd780b |
m_topLayout->addWidget(paletteBox);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
bool ret = true;
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QGroupBox* pickColorBox = NULL;
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (m_hasRasterImage) {
|
|
shun-iwasawa |
dd780b |
QRadioButton* addColorModelPltButton = new QRadioButton(
|
|
shun-iwasawa |
dd780b |
tr("Add color model's palette to the destination palette."));
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->addButton(addColorModelPltButton);
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->setId(addColorModelPltButton, PaletteCmd::AddColorModelPlt);
|
|
shun-iwasawa |
dd780b |
paletteLay->addWidget(addColorModelPltButton);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
//-------
|
|
shun-iwasawa |
dd780b |
m_topLayout->addSpacing(10);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
pickColorBox = new QGroupBox(tr("Picking Colors from Raster Image"), this);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
m_pickColorCombo = new QComboBox(this);
|
|
shun-iwasawa |
dd780b |
m_colorChipBehaviorFrame = new QFrame(this);
|
|
shun-iwasawa |
dd780b |
m_colorChipGridColor =
|
|
shun-iwasawa |
dd780b |
new DVGui::ColorField(this, false, TPixel32::Magenta, 40, false);
|
|
shun-iwasawa |
dd780b |
m_colorChipGridLineWidth = new DVGui::IntLineEdit(this, 2, 1, 20);
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder = new QButtonGroup(this);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QPushButton* upperLeftOrderBtn =
|
|
Kite |
521c84 |
new QPushButton(createQIcon("colorchiporder_upleft", true), "", this);
|
|
shun-iwasawa |
dd780b |
QPushButton* lowerLeftOrderBtn =
|
|
Kite |
521c84 |
new QPushButton(createQIcon("colorchiporder_lowleft", true), "", this);
|
|
shun-iwasawa |
dd780b |
QPushButton* leftUpperOrderBtn =
|
|
Kite |
521c84 |
new QPushButton(createQIcon("colorchiporder_leftup", true), "", this);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QStringList paletteTypes;
|
|
shun-iwasawa |
dd780b |
paletteTypes << tr("Pick Every Colors as Different Styles")
|
|
shun-iwasawa |
dd780b |
<< tr("Integrate Similar Colors as One Style")
|
|
shun-iwasawa |
dd780b |
<< tr("Pick Colors in Color Chip Grid");
|
|
shun-iwasawa |
dd780b |
m_pickColorCombo->addItems(paletteTypes);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
upperLeftOrderBtn->setCheckable(true);
|
|
shun-iwasawa |
dd780b |
lowerLeftOrderBtn->setCheckable(true);
|
|
shun-iwasawa |
dd780b |
leftUpperOrderBtn->setCheckable(true);
|
|
shun-iwasawa |
dd780b |
upperLeftOrderBtn->setIconSize(QSize(48, 42));
|
|
shun-iwasawa |
dd780b |
lowerLeftOrderBtn->setIconSize(QSize(48, 42));
|
|
shun-iwasawa |
dd780b |
leftUpperOrderBtn->setIconSize(QSize(48, 42));
|
|
shun-iwasawa |
dd780b |
upperLeftOrderBtn->setFixedSize(QSize(54, 48));
|
|
shun-iwasawa |
dd780b |
lowerLeftOrderBtn->setFixedSize(QSize(54, 48));
|
|
shun-iwasawa |
dd780b |
leftUpperOrderBtn->setFixedSize(QSize(54, 48));
|
|
shun-iwasawa |
dd780b |
upperLeftOrderBtn->setToolTip(tr("Horizontal - Top to bottom"));
|
|
shun-iwasawa |
dd780b |
lowerLeftOrderBtn->setToolTip(tr("Horizontal - Bottom to top"));
|
|
shun-iwasawa |
dd780b |
leftUpperOrderBtn->setToolTip(tr("Vertical - Left to right"));
|
|
shun-iwasawa |
dd780b |
upperLeftOrderBtn->setObjectName("MatchLineButton");
|
|
shun-iwasawa |
dd780b |
lowerLeftOrderBtn->setObjectName("MatchLineButton");
|
|
shun-iwasawa |
dd780b |
leftUpperOrderBtn->setObjectName("MatchLineButton");
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder->addButton(upperLeftOrderBtn);
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder->addButton(lowerLeftOrderBtn);
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder->addButton(leftUpperOrderBtn);
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder->setId(upperLeftOrderBtn, PaletteCmd::UpperLeft);
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder->setId(lowerLeftOrderBtn, PaletteCmd::LowerLeft);
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder->setId(leftUpperOrderBtn, PaletteCmd::LeftUpper);
|
|
shun-iwasawa |
dd780b |
m_colorChipOrder->setExclusive(true);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QGridLayout* pickColorLay = new QGridLayout();
|
|
shun-iwasawa |
dd780b |
pickColorLay->setMargin(10);
|
|
shun-iwasawa |
dd780b |
pickColorLay->setHorizontalSpacing(5);
|
|
shun-iwasawa |
dd780b |
pickColorLay->setVerticalSpacing(10);
|
|
shun-iwasawa |
dd780b |
{
|
|
shun-iwasawa |
dd780b |
pickColorLay->addWidget(new QLabel(tr("Pick Type:"), this), 0, 0,
|
|
shun-iwasawa |
dd780b |
Qt::AlignRight | Qt::AlignVCenter);
|
|
shun-iwasawa |
dd780b |
pickColorLay->addWidget(m_pickColorCombo, 0, 1, Qt::AlignLeft);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QGridLayout* colorChipGridLay = new QGridLayout();
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->setMargin(0);
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->setHorizontalSpacing(5);
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->setVerticalSpacing(10);
|
|
shun-iwasawa |
dd780b |
{
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->addWidget(new QLabel(tr("Grid Line Color:"), this), 0,
|
|
shun-iwasawa |
dd780b |
0, Qt::AlignRight | Qt::AlignVCenter);
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->addWidget(m_colorChipGridColor, 0, 1, Qt::AlignLeft);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->addWidget(new QLabel(tr("Grid Line Width:"), this), 1,
|
|
shun-iwasawa |
dd780b |
0, Qt::AlignRight | Qt::AlignVCenter);
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->addWidget(m_colorChipGridLineWidth, 1, 1,
|
|
shun-iwasawa |
dd780b |
Qt::AlignLeft);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->addWidget(new QLabel(tr("Chip Order:"), this), 2, 0,
|
|
shun-iwasawa |
dd780b |
Qt::AlignRight | Qt::AlignVCenter);
|
|
shun-iwasawa |
dd780b |
QHBoxLayout* orderLay = new QHBoxLayout();
|
|
shun-iwasawa |
dd780b |
orderLay->setMargin(0);
|
|
shun-iwasawa |
dd780b |
orderLay->setSpacing(0);
|
|
shun-iwasawa |
dd780b |
{
|
|
shun-iwasawa |
dd780b |
orderLay->addWidget(upperLeftOrderBtn, 0);
|
|
shun-iwasawa |
dd780b |
orderLay->addWidget(lowerLeftOrderBtn, 0);
|
|
shun-iwasawa |
dd780b |
orderLay->addWidget(leftUpperOrderBtn, 0);
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->addLayout(orderLay, 2, 1, Qt::AlignLeft);
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->setColumnStretch(0, 0);
|
|
shun-iwasawa |
dd780b |
colorChipGridLay->setColumnStretch(1, 1);
|
|
shun-iwasawa |
dd780b |
m_colorChipBehaviorFrame->setLayout(colorChipGridLay);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
pickColorLay->addWidget(m_colorChipBehaviorFrame, 1, 0, 1, 2);
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
pickColorLay->setColumnStretch(0, 0);
|
|
shun-iwasawa |
dd780b |
pickColorLay->setColumnStretch(1, 1);
|
|
shun-iwasawa |
dd780b |
pickColorBox->setLayout(pickColorLay);
|
|
shun-iwasawa |
dd780b |
m_topLayout->addWidget(pickColorBox);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
ret = ret && connect(m_pickColorCombo, SIGNAL(currentIndexChanged(int)),
|
|
shun-iwasawa |
dd780b |
this, SLOT(onPickColorComboActivated(int)));
|
|
shun-iwasawa |
dd780b |
ret = ret && connect(replaceColorModelPltButton, SIGNAL(toggled(bool)),
|
|
shun-iwasawa |
dd780b |
pickColorBox, SLOT(setDisabled(bool)));
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
QPushButton* applyButton = new QPushButton(QObject::tr("Apply"));
|
|
shun-iwasawa |
dd780b |
ret = ret && connect(applyButton, SIGNAL(clicked()), this, SLOT(accept()));
|
|
shun-iwasawa |
dd780b |
QPushButton* cancelButton = new QPushButton(QObject::tr("Cancel"));
|
|
shun-iwasawa |
dd780b |
ret = ret && connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
shun-iwasawa |
dd780b |
assert(ret);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
addButtonBarWidget(applyButton, cancelButton);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
// obtain initial values from env
|
|
shun-iwasawa |
dd780b |
QAbstractButton* button =
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->button(ColorModelBehavior_PaletteOperation);
|
|
shun-iwasawa |
dd780b |
if (button)
|
|
shun-iwasawa |
dd780b |
button->setChecked(true);
|
|
shun-iwasawa |
dd780b |
else
|
|
shun-iwasawa |
dd780b |
keepColorModelPltButton->setChecked(true);
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (m_hasRasterImage) {
|
|
shun-iwasawa |
dd780b |
m_pickColorCombo->setCurrentIndex(ColorModelBehavior_RasterImagePickType);
|
|
shun-iwasawa |
dd780b |
QColor chipGridColor(
|
|
shun-iwasawa |
dd780b |
QString::fromStdString(ColorModelBehavior_ChipGridColor));
|
|
shun-iwasawa |
dd780b |
m_colorChipGridColor->setColor(TPixel32(
|
|
shun-iwasawa |
dd780b |
chipGridColor.red(), chipGridColor.green(), chipGridColor.blue()));
|
|
shun-iwasawa |
dd780b |
m_colorChipGridLineWidth->setValue(ColorModelBehavior_ChipGridLineWidth);
|
|
shun-iwasawa |
dd780b |
button = m_colorChipOrder->button(ColorModelBehavior_ChipOrder);
|
|
shun-iwasawa |
dd780b |
if (button) button->setChecked(true);
|
|
shun-iwasawa |
dd780b |
onPickColorComboActivated(ColorModelBehavior_RasterImagePickType);
|
|
shun-iwasawa |
dd780b |
pickColorBox->setDisabled(ColorModelBehavior_PaletteOperation == 1);
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
//-------------------------------------------------------------------
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
void ColorModelBehaviorPopup::getLoadingConfiguration(
|
|
shun-iwasawa |
dd780b |
PaletteCmd::ColorModelLoadingConfiguration& config) {
|
|
shun-iwasawa |
dd780b |
config.behavior = static_cast<palettecmd::colormodelpltbehavior>(</palettecmd::colormodelpltbehavior>
|
|
shun-iwasawa |
dd780b |
m_buttonGroup->checkedId());
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (m_colorChipOrder)
|
|
shun-iwasawa |
dd780b |
config.colorChipOrder =
|
|
shun-iwasawa |
dd780b |
static_cast<palettecmd::colorchiporder>(m_colorChipOrder->checkedId());</palettecmd::colorchiporder>
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (m_pickColorCombo)
|
|
shun-iwasawa |
dd780b |
config.rasterPickType = static_cast<palettecmd::colormodelrasterpicktype>(</palettecmd::colormodelrasterpicktype>
|
|
shun-iwasawa |
dd780b |
m_pickColorCombo->currentIndex());
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (m_colorChipGridColor) config.gridColor = m_colorChipGridColor->getColor();
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (m_colorChipGridLineWidth)
|
|
shun-iwasawa |
dd780b |
config.gridLineWidth = m_colorChipGridLineWidth->getValue();
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
//-------------------------------------------------------------------
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
void ColorModelBehaviorPopup::onPickColorComboActivated(int index) {
|
|
shun-iwasawa |
dd780b |
if (!m_colorChipBehaviorFrame) return;
|
|
shun-iwasawa |
dd780b |
m_colorChipBehaviorFrame->setEnabled(index == 2);
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
//-------------------------------------------------------------------
|
|
shun-iwasawa |
dd780b |
// save current state to env
|
|
shun-iwasawa |
dd780b |
ColorModelBehaviorPopup::~ColorModelBehaviorPopup() {
|
|
shun-iwasawa |
dd780b |
int id = m_buttonGroup->checkedId();
|
|
shun-iwasawa |
dd780b |
if (id != -1) ColorModelBehavior_PaletteOperation = id;
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (!m_hasRasterImage) return;
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
ColorModelBehavior_RasterImagePickType = m_pickColorCombo->currentIndex();
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
TPixel32 gridColor = m_colorChipGridColor->getColor();
|
|
shun-iwasawa |
dd780b |
ColorModelBehavior_ChipGridColor =
|
|
shun-iwasawa |
dd780b |
QColor(gridColor.r, gridColor.g, gridColor.b)
|
|
shun-iwasawa |
dd780b |
.name(QColor::HexRgb)
|
|
shun-iwasawa |
dd780b |
.toStdString();
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
ColorModelBehavior_ChipGridLineWidth = m_colorChipGridLineWidth->getValue();
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
id = m_colorChipOrder->checkedId();
|
|
shun-iwasawa |
dd780b |
if (id != -1) ColorModelBehavior_ChipOrder = id;
|
|
shun-iwasawa |
dd780b |
}
|