Added model properties action.
This commit is contained in:
+40
-7
@@ -1898,6 +1898,38 @@ void lcModel::RunObjectEditAction(const lcModelActionObjectEdit* ModelActionObje
|
||||
SetCurrentStep(mCurrentStep);
|
||||
}
|
||||
|
||||
void lcModel::SetModelProperties(const lcModelProperties& ModelProperties)
|
||||
{
|
||||
mProperties = ModelProperties;
|
||||
|
||||
if (gMainWindow)
|
||||
gMainWindow->GetPreviewWidget()->UpdatePreview();
|
||||
}
|
||||
|
||||
void lcModel::RecordModelPropertiesAction(const lcModelProperties& ModelProperties)
|
||||
{
|
||||
std::unique_ptr<lcModelActionProperties> ModelActionProperties = std::make_unique<lcModelActionProperties>();
|
||||
ModelActionProperties->SaveStartState(this);
|
||||
|
||||
SetModelProperties(ModelProperties);
|
||||
|
||||
ModelActionProperties->SaveEndState(this);
|
||||
|
||||
if (ModelActionProperties->StateChanged())
|
||||
mActionSequence.emplace_back(std::move(ModelActionProperties));
|
||||
}
|
||||
|
||||
void lcModel::RunModelPropertiesAction(const lcModelActionProperties* ModelActionProperties, bool Apply)
|
||||
{
|
||||
if (!ModelActionProperties)
|
||||
return;
|
||||
|
||||
if (Apply)
|
||||
ModelActionProperties->LoadEndState(this);
|
||||
else
|
||||
ModelActionProperties->LoadStartState(this);
|
||||
}
|
||||
|
||||
void lcModel::RunActionSequence(const std::vector<std::unique_ptr<lcModelAction>>& ActionSequence, bool Apply)
|
||||
{
|
||||
bool SelectionChanged = false;
|
||||
@@ -1912,6 +1944,8 @@ void lcModel::RunActionSequence(const std::vector<std::unique_ptr<lcModelAction>
|
||||
}
|
||||
else if (const lcModelActionObjectEdit* ModelActionObjectEdit = dynamic_cast<const lcModelActionObjectEdit*>(ModelAction))
|
||||
RunObjectEditAction(ModelActionObjectEdit, Apply);
|
||||
else if (const lcModelActionProperties* ModelActionProperties = dynamic_cast<const lcModelActionProperties*>(ModelAction))
|
||||
RunModelPropertiesAction(ModelActionProperties, Apply);
|
||||
};
|
||||
|
||||
if (Apply)
|
||||
@@ -3286,6 +3320,7 @@ void lcModel::InlineSelectedModels()
|
||||
EndActionSequence(tr("Inline Model"));
|
||||
|
||||
gMainWindow->UpdateTimeline(false, false);
|
||||
gMainWindow->UpdateInUseCategory();
|
||||
}
|
||||
|
||||
void lcModel::RemoveCameraFromViews(lcCamera* Camera)
|
||||
@@ -4667,8 +4702,8 @@ void lcModel::UnhideSelectedPieces()
|
||||
DiscardActionSequence();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EndObjectEditAction();
|
||||
EndActionSequence(tr("Unhide Pieces"));
|
||||
|
||||
@@ -5443,11 +5478,9 @@ void lcModel::ShowPropertiesDialog()
|
||||
if (mProperties == Options.Properties)
|
||||
return;
|
||||
|
||||
mProperties = Options.Properties;
|
||||
|
||||
gMainWindow->GetPreviewWidget()->UpdatePreview();
|
||||
|
||||
SaveCheckpoint(tr("Changing Properties"));
|
||||
BeginActionSequence();
|
||||
RecordModelPropertiesAction(Options.Properties);
|
||||
EndActionSequence(tr("Change Model Properties"));
|
||||
}
|
||||
|
||||
void lcModel::ShowSelectByNameDialog()
|
||||
|
||||
@@ -9,6 +9,7 @@ struct lcModelHistoryState;
|
||||
class lcModelAction;
|
||||
class lcModelActionSelection;
|
||||
class lcModelActionObjectEdit;
|
||||
class lcModelActionProperties;
|
||||
|
||||
#define LC_SEL_NO_PIECES 0x0001 // No pieces in model
|
||||
#define LC_SEL_PIECE 0x0002 // At least 1 piece selected
|
||||
@@ -70,6 +71,11 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const lcModelProperties& Properties) const
|
||||
{
|
||||
return !(*this == Properties);
|
||||
}
|
||||
|
||||
void SaveLDraw(QTextStream& Stream) const;
|
||||
bool ParseLDrawHeader(QString Line, bool FirstLine);
|
||||
void ParseLDrawLine(QTextStream& Stream);
|
||||
@@ -228,6 +234,7 @@ public:
|
||||
template<typename StateType, typename ObjectType>
|
||||
void LoadObjectHistoryState(const std::vector<StateType>& ObjectStates, std::vector<std::unique_ptr<ObjectType>>& Objects);
|
||||
void LoadHistoryState(const lcModelHistoryState& HistoryState);
|
||||
void SetModelProperties(const lcModelProperties& ModelProperties);
|
||||
|
||||
lcPiece* AddPiece(PieceInfo* Info, quint32 Section);
|
||||
void AddPiece(std::unique_ptr<lcPiece> Piece, size_t PieceIndex);
|
||||
@@ -410,6 +417,8 @@ protected:
|
||||
void BeginObjectEditAction();
|
||||
void EndObjectEditAction();
|
||||
void RunObjectEditAction(const lcModelActionObjectEdit* ModelActionObjectEdit, bool Apply);
|
||||
void RecordModelPropertiesAction(const lcModelProperties& ModelProperties);
|
||||
void RunModelPropertiesAction(const lcModelActionProperties* ModelActionProperties, bool Apply);
|
||||
|
||||
void RunActionSequence(const std::vector<std::unique_ptr<lcModelAction>>& ActionSequence, bool Apply);
|
||||
void BeginActionSequence();
|
||||
|
||||
@@ -194,3 +194,38 @@ bool lcModelActionObjectEdit::StateChanged() const
|
||||
{
|
||||
return mStartState != mEndState;
|
||||
}
|
||||
|
||||
void lcModelActionProperties::SaveStartState(const lcModel* Model)
|
||||
{
|
||||
SaveState(mStartState, Model);
|
||||
}
|
||||
|
||||
void lcModelActionProperties::SaveEndState(const lcModel* Model)
|
||||
{
|
||||
SaveState(mEndState, Model);
|
||||
}
|
||||
|
||||
void lcModelActionProperties::LoadStartState(lcModel* Model) const
|
||||
{
|
||||
LoadState(mStartState, Model);
|
||||
}
|
||||
|
||||
void lcModelActionProperties::LoadEndState(lcModel* Model) const
|
||||
{
|
||||
LoadState(mEndState, Model);
|
||||
}
|
||||
|
||||
bool lcModelActionProperties::StateChanged() const
|
||||
{
|
||||
return mStartState != mEndState;
|
||||
}
|
||||
|
||||
void lcModelActionProperties::SaveState(lcModelProperties& State, const lcModel* Model)
|
||||
{
|
||||
State = Model->GetProperties();
|
||||
}
|
||||
|
||||
void lcModelActionProperties::LoadState(const lcModelProperties& State, lcModel* Model)
|
||||
{
|
||||
Model->SetModelProperties(State);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "lc_model.h"
|
||||
|
||||
enum class lcObjectType;
|
||||
enum class lcSelectionMode;
|
||||
|
||||
@@ -85,3 +87,24 @@ protected:
|
||||
lcModelHistoryState mStartState;
|
||||
lcModelHistoryState mEndState;
|
||||
};
|
||||
|
||||
class lcModelActionProperties : public lcModelAction
|
||||
{
|
||||
public:
|
||||
lcModelActionProperties() = default;
|
||||
virtual ~lcModelActionProperties() = default;
|
||||
|
||||
void SaveStartState(const lcModel* Model);
|
||||
void SaveEndState(const lcModel* Model);
|
||||
void LoadStartState(lcModel* Model) const;
|
||||
void LoadEndState(lcModel* Model) const;
|
||||
|
||||
bool StateChanged() const;
|
||||
|
||||
protected:
|
||||
static void SaveState(lcModelProperties& State, const lcModel* Model);
|
||||
static void LoadState(const lcModelProperties& State, lcModel* Model);
|
||||
|
||||
lcModelProperties mStartState;
|
||||
lcModelProperties mEndState;
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "piece.h"
|
||||
#include "group.h"
|
||||
|
||||
constexpr uintptr_t LC_GROUPDIALOG_NEW_GROUP = ~0;
|
||||
constexpr uintptr_t LC_GROUPDIALOG_NEW_GROUP = ~0U;
|
||||
|
||||
class lcEditGroupsDialogDelegate : public QItemDelegate
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user