From 00f3f0588f6e54b94e5c974530a65d2ff55cf2ad Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 16 Jan 2021 18:27:39 -0800 Subject: [PATCH] Cleanup. --- common/lc_model.cpp | 28 ++++++++++++++-------------- common/lc_previewwidget.cpp | 4 ++-- common/lc_timelinewidget.cpp | 4 ++-- common/piece.h | 16 +++++++++++++--- qt/lc_qpropertiestree.cpp | 10 +++++----- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 573ca420..916cb117 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -2495,10 +2495,10 @@ void lcModel::InlineSelectedModels() // todo: recreate in groups in the current model - int ColorIndex = ModelPiece->mColorIndex; + int ColorIndex = ModelPiece->GetColorIndex(); if (ColorIndex == gDefaultColor) - ColorIndex = Piece->mColorIndex; + ColorIndex = Piece->GetColorIndex(); NewPiece->SetPieceInfo(ModelPiece->mPieceInfo, ModelPiece->GetID(), true); NewPiece->Initialize(lcMul(ModelPiece->mModelWorld, Piece->mModelWorld), Piece->GetStepShow()); @@ -2819,7 +2819,7 @@ void lcModel::SetSelectedPiecesColorIndex(int ColorIndex) for (lcPiece* Piece : mPieces) { - if (Piece->IsSelected() && Piece->mColorIndex != ColorIndex) + if (Piece->IsSelected() && Piece->GetColorIndex() != ColorIndex) { Piece->SetColorIndex(ColorIndex); Modified = true; @@ -3270,7 +3270,7 @@ void lcModel::GetPartsList(int DefaultColorIndex, bool ScanSubModels, bool AddSu if (!Piece->IsVisibleInSubModel()) continue; - int ColorIndex = Piece->mColorIndex; + int ColorIndex = Piece->GetColorIndex(); if (ColorIndex == gDefaultColor) ColorIndex = DefaultColorIndex; @@ -3286,7 +3286,7 @@ void lcModel::GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsLis if (Piece->GetStepShow() != Step || Piece->IsHidden()) continue; - int ColorIndex = Piece->mColorIndex; + int ColorIndex = Piece->GetColorIndex(); if (ColorIndex == gDefaultColor) ColorIndex = DefaultColorIndex; @@ -3397,7 +3397,7 @@ void lcModel::GetSelectionInformation(int* Flags, lcArray& Selection, lcArray lcModel::GetSelectionModePieces(lcPiece* SelectedPiece) const { PieceInfo* Info = SelectedPiece->mPieceInfo; - int ColorIndex = SelectedPiece->mColorIndex; + int ColorIndex = SelectedPiece->GetColorIndex(); lcArray Pieces; switch (gMainWindow->GetSelectionMode()) @@ -3413,13 +3413,13 @@ lcArray lcModel::GetSelectionModePieces(lcPiece* SelectedPiece) const case lcSelectionMode::Color: for (lcPiece* Piece : mPieces) - if (Piece->IsVisible(mCurrentStep) && Piece->mColorIndex == ColorIndex && Piece != SelectedPiece) + if (Piece->IsVisible(mCurrentStep) && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece) Pieces.Add(Piece); break; case lcSelectionMode::PieceColor: for (lcPiece* Piece : mPieces) - if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece->mColorIndex == ColorIndex && Piece != SelectedPiece) + if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece) Pieces.Add(Piece); break; } @@ -3811,7 +3811,7 @@ void lcModel::FindPiece(bool FindFirst, bool SearchForward) continue; if ((!SearchOptions.MatchInfo || Current->mPieceInfo == SearchOptions.Info) && - (!SearchOptions.MatchColor || Current->mColorIndex == SearchOptions.ColorIndex) && + (!SearchOptions.MatchColor || Current->GetColorIndex() == SearchOptions.ColorIndex) && (!SearchOptions.MatchName || (Current->GetName().indexOf(SearchOptions.Name, 0, Qt::CaseInsensitive) != -1))) { Focus = Current; @@ -4075,7 +4075,7 @@ void lcModel::PaintToolClicked(lcObject* Object) lcPiece* Piece = (lcPiece*)Object; - if (Piece->mColorIndex != gMainWindow->mColorIndex) + if (Piece->GetColorIndex() != gMainWindow->mColorIndex) { Piece->SetColorIndex(gMainWindow->mColorIndex); @@ -4093,7 +4093,7 @@ void lcModel::ColorPickerToolClicked(lcObject* Object) lcPiece* Piece = (lcPiece*)Object; - gMainWindow->SetColorIndex(Piece->mColorIndex); + gMainWindow->SetColorIndex(Piece->GetColorIndex()); } void lcModel::UpdateZoomTool(lcCamera* Camera, float Mouse) @@ -4266,7 +4266,7 @@ void lcModel::ShowSelectByColorDialog() lcObject* Focus = GetFocusObject(); if (Focus && Focus->IsPiece()) - ColorIndex = ((lcPiece*)Focus)->mColorIndex; + ColorIndex = ((lcPiece*)Focus)->GetColorIndex(); lcSelectByColorDialog Dialog(gMainWindow, ColorIndex); @@ -4277,7 +4277,7 @@ void lcModel::ShowSelectByColorDialog() lcArray Selection; for (lcPiece* Piece : mPieces) - if (Piece->IsVisible(mCurrentStep) && Piece->mColorIndex == ColorIndex) + if (Piece->IsVisible(mCurrentStep) && Piece->GetColorIndex() == ColorIndex) Selection.Add(Piece); SetSelectionAndFocus(Selection, nullptr, 0, false); @@ -4337,7 +4337,7 @@ void lcModel::ShowArrayDialog() lcPiece* NewPiece = new lcPiece(nullptr); NewPiece->SetPieceInfo(Piece->mPieceInfo, Piece->GetID(), true); NewPiece->Initialize(ModelWorld, mCurrentStep); - NewPiece->SetColorIndex(Piece->mColorIndex); + NewPiece->SetColorIndex(Piece->GetColorIndex()); NewPieces.Add(NewPiece); } diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index 4ac205a8..661e4267 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -100,7 +100,7 @@ bool lcPreview::SetCurrentPiece(const QString& PartType, int ColorCode) { if (Info == ModelPiece->mPieceInfo) { - int ModelColorCode = ModelPiece->mColorCode; + int ModelColorCode = ModelPiece->GetColorCode(); if (ModelColorCode == ColorCode) return true; } @@ -163,7 +163,7 @@ void lcPreview::UpdatePreview() if (ModelPiece->mPieceInfo) { PartType = ModelPiece->mPieceInfo->mFileName; - ColorCode = ModelPiece->mColorCode; + ColorCode = ModelPiece->GetColorCode(); break; } } diff --git a/common/lc_timelinewidget.cpp b/common/lc_timelinewidget.cpp index e901ed06..ff5e65eb 100644 --- a/common/lc_timelinewidget.cpp +++ b/common/lc_timelinewidget.cpp @@ -190,7 +190,7 @@ void lcTimelineWidget::Update(bool Clear, bool UpdateItems) { PieceItem->setText(0, Piece->mPieceInfo->m_strDescription); - int ColorIndex = Piece->mColorIndex; + int ColorIndex = Piece->GetColorIndex(); if (!mIcons.contains(ColorIndex)) { int Size = rowHeight(indexFromItem(PieceItem)); @@ -535,7 +535,7 @@ void lcTimelineWidget::PreviewSelection(QTreeWidgetItem* CurrentItem) if (!Info) return; - gMainWindow->PreviewPiece(Info->mFileName, Piece->mColorCode, false); + gMainWindow->PreviewPiece(Info->mFileName, Piece->GetColorCode(), false); } void lcTimelineWidget::UpdateModel() diff --git a/common/piece.h b/common/piece.h index a51568ed..1cb36acd 100644 --- a/common/piece.h +++ b/common/piece.h @@ -525,12 +525,22 @@ public: mStepHide = mStepShow + 1; } + quint32 GetColorCode() const + { + return mColorCode; + } + void SetColorCode(quint32 ColorCode) { mColorCode = ColorCode; mColorIndex = lcGetColorIndex(ColorCode); } + int GetColorIndex() const + { + return mColorIndex; + } + void SetColorIndex(int ColorIndex) { mColorIndex = ColorIndex; @@ -606,9 +616,6 @@ public: public: PieceInfo* mPieceInfo; - int mColorIndex; - quint32 mColorCode; - lcMatrix44 mModelWorld; lcMatrix44 mPivotMatrix; @@ -633,6 +640,9 @@ protected: lcGroup* mGroup; + int mColorIndex; + quint32 mColorCode; + lcStep mStepShow; lcStep mStepHide; diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index 46a0463d..95ec88ce 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -764,7 +764,7 @@ void lcQPropertiesTree::slotSetValue(int Value) int ColorIndex = gDefaultColor; lcObject* Focus = gMainWindow->GetActiveModel()->GetFocusObject(); if (Focus && Focus->IsPiece()) - ColorIndex = ((lcPiece*)Focus)->mColorIndex; + ColorIndex = ((lcPiece*)Focus)->GetColorIndex(); quint32 ColorCode = lcGetColorCode(ColorIndex); gMainWindow->PreviewPiece(Info->mFileName, ColorCode, false); } @@ -777,7 +777,7 @@ void lcQPropertiesTree::slotColorButtonClicked() lcObject* Focus = gMainWindow->GetActiveModel()->GetFocusObject(); if (Focus && Focus->IsPiece()) - ColorIndex = ((lcPiece*)Focus)->mColorIndex; + ColorIndex = ((lcPiece*)Focus)->GetColorIndex(); QWidget* Button = (QWidget*)sender(); @@ -939,7 +939,7 @@ void lcQPropertiesTree::SetPiece(const lcArray& Selection, lcObject* { Show = Piece->GetStepShow(); Hide = Piece->GetStepHide(); - ColorIndex = Piece->mColorIndex; + ColorIndex = Piece->GetColorIndex(); Info = Piece->mPieceInfo; quint32 ColorCode = lcGetColorCode(ColorIndex); gMainWindow->PreviewPiece(Info->mFileName, ColorCode, false); @@ -961,7 +961,7 @@ void lcQPropertiesTree::SetPiece(const lcArray& Selection, lcObject* { Show = SelectedPiece->GetStepShow(); Hide = SelectedPiece->GetStepHide(); - ColorIndex = SelectedPiece->mColorIndex; + ColorIndex = SelectedPiece->GetColorIndex(); Info = SelectedPiece->mPieceInfo; FirstPiece = false; @@ -974,7 +974,7 @@ void lcQPropertiesTree::SetPiece(const lcArray& Selection, lcObject* if (SelectedPiece->GetStepHide() != Hide) Hide = 0; - if (SelectedPiece->mColorIndex != ColorIndex) + if (SelectedPiece->GetColorIndex() != ColorIndex) ColorIndex = gDefaultColor; if (SelectedPiece->mPieceInfo != Info)