mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Added option to paint selected pieces. Fixes #561.
This commit is contained in:
parent
3358553e1d
commit
58981f9580
6 changed files with 55 additions and 1 deletions
|
@ -1172,6 +1172,13 @@ const lcCommand gCommands[] =
|
|||
QT_TRANSLATE_NOOP("Status", "Create a copy of the selected pieces"),
|
||||
"Ctrl+D"
|
||||
},
|
||||
// LC_PIECE_PAINT_SELECTED
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Piece.PaintSelected"),
|
||||
QT_TRANSLATE_NOOP("Menu", "&Paint Selected"),
|
||||
QT_TRANSLATE_NOOP("Status", "Change the color of the selected pieces"),
|
||||
""
|
||||
},
|
||||
// LC_PIECE_RESET_PIVOT_POINT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Piece.ResetPivotPoint"),
|
||||
|
|
|
@ -183,6 +183,7 @@ enum lcCommandId
|
|||
LC_PIECE_INSERT,
|
||||
LC_PIECE_DELETE,
|
||||
LC_PIECE_DUPLICATE,
|
||||
LC_PIECE_PAINT_SELECTED,
|
||||
LC_PIECE_RESET_PIVOT_POINT,
|
||||
LC_PIECE_REMOVE_KEY_FRAMES,
|
||||
LC_PIECE_CONTROL_POINT_INSERT,
|
||||
|
|
|
@ -567,6 +567,7 @@ void lcMainWindow::CreateMenus()
|
|||
PieceMenu->addAction(mActions[LC_PIECE_INSERT]);
|
||||
PieceMenu->addAction(mActions[LC_PIECE_DELETE]);
|
||||
PieceMenu->addAction(mActions[LC_PIECE_DUPLICATE]);
|
||||
PieceMenu->addAction(mActions[LC_PIECE_PAINT_SELECTED]);
|
||||
PieceMenu->addAction(mActions[LC_PIECE_ARRAY]);
|
||||
PieceMenu->addAction(mActions[LC_PIECE_MINIFIG_WIZARD]);
|
||||
PieceMenu->addAction(mActions[LC_PIECE_RESET_PIVOT_POINT]);
|
||||
|
@ -709,7 +710,25 @@ void lcMainWindow::CreateToolBars()
|
|||
mColorList = new lcQColorList();
|
||||
connect(mColorList, SIGNAL(colorChanged(int)), this, SLOT(ColorChanged(int)));
|
||||
|
||||
mColorsToolBar->setWidget(mColorList);
|
||||
QWidget* ColorWidget = new QWidget(mColorsToolBar);
|
||||
|
||||
QVBoxLayout* ColorLayout = new QVBoxLayout(ColorWidget);
|
||||
|
||||
QHBoxLayout* ColorButtonLayout = new QHBoxLayout();
|
||||
ColorButtonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
ColorLayout->addLayout(ColorButtonLayout);
|
||||
|
||||
mColorButton = new QToolButton(ColorWidget);
|
||||
mColorButton->setAutoRaise(true);
|
||||
mColorButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
mColorButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
|
||||
ColorButtonLayout->addWidget(mColorButton);
|
||||
|
||||
connect(mColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
|
||||
|
||||
ColorLayout->addWidget(mColorList);
|
||||
|
||||
mColorsToolBar->setWidget(ColorWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, mColorsToolBar);
|
||||
|
||||
mPropertiesToolBar = new QDockWidget(tr("Properties"), this);
|
||||
|
@ -1110,6 +1129,14 @@ void lcMainWindow::ColorChanged(int ColorIndex)
|
|||
SetColorIndex(ColorIndex);
|
||||
}
|
||||
|
||||
void lcMainWindow::ColorButtonClicked()
|
||||
{
|
||||
lcModel* ActiveModel = GetActiveModel();
|
||||
|
||||
if (ActiveModel)
|
||||
ActiveModel->PaintSelectedPieces();
|
||||
}
|
||||
|
||||
void lcMainWindow::ProjectFileChanged(const QString& Path)
|
||||
{
|
||||
static bool Ignore;
|
||||
|
@ -2038,6 +2065,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
|
|||
|
||||
mActions[LC_PIECE_DELETE]->setEnabled(Flags & LC_SEL_SELECTED);
|
||||
mActions[LC_PIECE_DUPLICATE]->setEnabled(Flags & LC_SEL_SELECTED);
|
||||
mActions[LC_PIECE_PAINT_SELECTED]->setEnabled(Flags & LC_SEL_PIECE);
|
||||
mActions[LC_PIECE_RESET_PIVOT_POINT]->setEnabled(Flags & LC_SEL_SELECTED);
|
||||
mActions[LC_PIECE_REMOVE_KEY_FRAMES]->setEnabled(Flags & LC_SEL_SELECTED);
|
||||
mActions[LC_PIECE_ARRAY]->setEnabled(Flags & LC_SEL_PIECE);
|
||||
|
@ -2152,6 +2180,11 @@ void lcMainWindow::UpdateSnap()
|
|||
|
||||
void lcMainWindow::UpdateColor()
|
||||
{
|
||||
QPixmap Pixmap(16, 16);
|
||||
Pixmap.fill(QColor::fromRgbF(gColorList[mColorIndex].Value[0], gColorList[mColorIndex].Value[1], gColorList[mColorIndex].Value[2]));
|
||||
|
||||
mColorButton->setIcon(Pixmap);
|
||||
mColorButton->setText(QString(" ") + gColorList[mColorIndex].Name);
|
||||
mColorList->setCurrentColor(mColorIndex);
|
||||
}
|
||||
|
||||
|
@ -2885,6 +2918,11 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
|||
ActiveModel->DuplicateSelectedPieces();
|
||||
break;
|
||||
|
||||
case LC_PIECE_PAINT_SELECTED:
|
||||
if (ActiveModel)
|
||||
ActiveModel->PaintSelectedPieces();
|
||||
break;
|
||||
|
||||
case LC_PIECE_RESET_PIVOT_POINT:
|
||||
if (ActiveModel)
|
||||
ActiveModel->ResetSelectedPiecesPivotPoint();
|
||||
|
|
|
@ -370,6 +370,7 @@ protected slots:
|
|||
void ClipboardChanged();
|
||||
void ActionTriggered();
|
||||
void ColorChanged(int ColorIndex);
|
||||
void ColorButtonClicked();
|
||||
void Print(QPrinter* Printer);
|
||||
void EnableWindowFlags(bool);
|
||||
|
||||
|
@ -442,6 +443,7 @@ protected:
|
|||
|
||||
lcPartSelectionWidget* mPartSelectionWidget;
|
||||
lcQColorList* mColorList;
|
||||
QToolButton* mColorButton;
|
||||
lcQPropertiesTree* mPropertiesWidget;
|
||||
lcTimelineWidget* mTimelineWidget;
|
||||
QLineEdit* mTransformXEdit;
|
||||
|
|
|
@ -1231,6 +1231,11 @@ void lcModel::DuplicateSelectedPieces()
|
|||
SaveCheckpoint(tr("Duplicating Pieces"));
|
||||
}
|
||||
|
||||
void lcModel::PaintSelectedPieces()
|
||||
{
|
||||
SetSelectedPiecesColorIndex(gMainWindow->mColorIndex);
|
||||
}
|
||||
|
||||
void lcModel::GetScene(lcScene* Scene, lcCamera* ViewCamera, bool AllowHighlight, bool AllowFade) const
|
||||
{
|
||||
if (mPieceInfo)
|
||||
|
|
|
@ -236,6 +236,7 @@ public:
|
|||
void Copy();
|
||||
void Paste();
|
||||
void DuplicateSelectedPieces();
|
||||
void PaintSelectedPieces();
|
||||
|
||||
void GetScene(lcScene* Scene, lcCamera* ViewCamera, bool AllowHighlight, bool AllowFade) const;
|
||||
void AddSubModelRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue