mirror of
https://github.com/leozide/leocad.git
synced 2026-07-27 19:56:49 +00:00
Removed group action.
This commit is contained in:
+2
-2
@@ -898,7 +898,7 @@ void lcCamera::RemoveKeyFrames()
|
||||
mUpVector.RemoveAllKeys();
|
||||
}
|
||||
|
||||
lcCameraHistoryState lcCamera::GetHistoryState(const lcModel* Model) const
|
||||
lcCameraHistoryState lcCamera::GetHistoryState([[maybe_unused]] const lcModel* Model) const
|
||||
{
|
||||
lcCameraHistoryState State;
|
||||
|
||||
@@ -917,7 +917,7 @@ lcCameraHistoryState lcCamera::GetHistoryState(const lcModel* Model) const
|
||||
return State;
|
||||
}
|
||||
|
||||
void lcCamera::SetHistoryState(const lcCameraHistoryState& State, const lcModel* Model)
|
||||
void lcCamera::SetHistoryState(const lcCameraHistoryState& State, [[maybe_unused]] const lcModel* Model)
|
||||
{
|
||||
mId = State.Id;
|
||||
mHidden = State.Hidden;
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@ lcGroupHistoryState lcGroup::GetHistoryState(const lcModel* Model) const
|
||||
lcGroupHistoryState State;
|
||||
|
||||
State.Id = mId;
|
||||
State.ParentIndex = ~0;
|
||||
State.ParentIndex = ~0U;
|
||||
State.Name = mName;
|
||||
|
||||
if (mGroup)
|
||||
@@ -79,7 +79,7 @@ lcGroupHistoryState lcGroup::GetHistoryState(const lcModel* Model) const
|
||||
{
|
||||
if (Groups[GroupIndex].get() == mGroup)
|
||||
{
|
||||
State.ParentIndex = GroupIndex;
|
||||
State.ParentIndex = static_cast<uint32_t>(GroupIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+56
-100
@@ -329,15 +329,6 @@ void lcModel::UpdatePieceInfo(std::vector<lcModel*>& UpdatedModels)
|
||||
mPieceInfo->SetBoundingBox(Min, Max);
|
||||
}
|
||||
|
||||
lcCamera* lcModel::GetCamera(const QString& Name) const
|
||||
{
|
||||
for (const std::unique_ptr<lcCamera>& Camera : mCameras)
|
||||
if (Camera->GetName() == Name)
|
||||
return Camera.get();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) const
|
||||
{
|
||||
const QLatin1String LineEnding("\r\n");
|
||||
@@ -1873,7 +1864,7 @@ void lcModel::EndObjectEditAction()
|
||||
|
||||
ModelActionObjectEdit->SaveEndState(this);
|
||||
|
||||
if (ModelActionObjectEdit->StateChanged())
|
||||
if (!ModelActionObjectEdit->StateChanged())
|
||||
mActionSequence.pop_back();
|
||||
}
|
||||
|
||||
@@ -1890,87 +1881,6 @@ void lcModel::RunObjectEditAction(const lcModelActionObjectEdit* ModelActionObje
|
||||
SetCurrentStep(mCurrentStep);
|
||||
}
|
||||
|
||||
void lcModel::RecordGroupPiecesAction(lcModelActionGroupPiecesMode Mode, const QString& GroupName)
|
||||
{
|
||||
std::unique_ptr<lcModelActionGroupPieces> ModelActionGroupPieces = std::make_unique<lcModelActionGroupPieces>(Mode, GroupName);
|
||||
|
||||
RunGroupPiecesAction(ModelActionGroupPieces.get(), true);
|
||||
|
||||
mActionSequence.emplace_back(std::move(ModelActionGroupPieces));
|
||||
}
|
||||
|
||||
void lcModel::RunGroupPiecesAction(const lcModelActionGroupPieces* ModelActionGroupPieces, bool Apply)
|
||||
{
|
||||
if (!ModelActionGroupPieces)
|
||||
return;
|
||||
|
||||
if (Apply == (ModelActionGroupPieces->GetMode() == lcModelActionGroupPiecesMode::Group))
|
||||
{
|
||||
lcGroup* NewGroup = new lcGroup();
|
||||
mGroups.emplace_back(NewGroup);
|
||||
|
||||
NewGroup->mName = ModelActionGroupPieces->GetGroupName();
|
||||
NewGroup->mGroup = nullptr;
|
||||
|
||||
for (const std::unique_ptr<lcPiece>& Piece : mPieces)
|
||||
{
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
lcGroup* TopGroup = Piece->GetTopGroup();
|
||||
|
||||
if (!TopGroup)
|
||||
Piece->SetGroup(NewGroup);
|
||||
else if (TopGroup != NewGroup)
|
||||
TopGroup->mGroup = NewGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set<lcGroup*> SelectedGroups;
|
||||
|
||||
for (const std::unique_ptr<lcPiece>& Piece : mPieces)
|
||||
{
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
lcGroup* Group = Piece->GetTopGroup();
|
||||
|
||||
if (SelectedGroups.insert(Group).second)
|
||||
{
|
||||
for (std::vector<std::unique_ptr<lcGroup>>::iterator GroupIt = mGroups.begin(); GroupIt != mGroups.end(); GroupIt++)
|
||||
{
|
||||
if (GroupIt->get() == Group)
|
||||
{
|
||||
GroupIt->release();
|
||||
mGroups.erase(GroupIt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::unique_ptr<lcPiece>& Piece : mPieces)
|
||||
{
|
||||
lcGroup* Group = Piece->GetGroup();
|
||||
|
||||
if (SelectedGroups.find(Group) != SelectedGroups.end())
|
||||
Piece->SetGroup(nullptr);
|
||||
}
|
||||
|
||||
for (const std::unique_ptr<lcGroup>& Group : mGroups)
|
||||
if (SelectedGroups.find(Group->mGroup) != SelectedGroups.end())
|
||||
Group->mGroup = nullptr;
|
||||
|
||||
for (lcGroup* Group : SelectedGroups)
|
||||
delete Group;
|
||||
|
||||
RemoveEmptyGroups();
|
||||
}
|
||||
|
||||
gMainWindow->UpdateSelectedObjects(true);
|
||||
}
|
||||
|
||||
void lcModel::RunActionSequence(const std::vector<std::unique_ptr<lcModelAction>>& ActionSequence, bool Apply)
|
||||
{
|
||||
bool SelectionChanged = false;
|
||||
@@ -1985,8 +1895,6 @@ 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 lcModelActionGroupPieces* ModelActionGroupPieces = dynamic_cast<const lcModelActionGroupPieces*>(ModelAction))
|
||||
RunGroupPiecesAction(ModelActionGroupPieces, Apply);
|
||||
};
|
||||
|
||||
if (Apply)
|
||||
@@ -2306,10 +2214,27 @@ void lcModel::GroupSelection()
|
||||
return;
|
||||
|
||||
BeginActionSequence();
|
||||
BeginObjectEditAction();
|
||||
|
||||
RecordGroupPiecesAction(lcModelActionGroupPiecesMode::Group, Dialog.mName);
|
||||
lcGroup* NewGroup = GetGroup(Dialog.mName, true);
|
||||
|
||||
for (const std::unique_ptr<lcPiece>& Piece : mPieces)
|
||||
{
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
lcGroup* Group = Piece->GetTopGroup();
|
||||
|
||||
if (!Group)
|
||||
Piece->SetGroup(NewGroup);
|
||||
else if (Group != NewGroup)
|
||||
Group->mGroup = NewGroup;
|
||||
}
|
||||
}
|
||||
|
||||
EndObjectEditAction();
|
||||
EndActionSequence(tr("Group"));
|
||||
|
||||
gMainWindow->UpdateSelectedObjects(true);
|
||||
}
|
||||
|
||||
void lcModel::UngroupSelection()
|
||||
@@ -2320,28 +2245,59 @@ void lcModel::UngroupSelection()
|
||||
return;
|
||||
}
|
||||
|
||||
bool FoundGroup = false;
|
||||
std::set<lcGroup*> SelectedGroups;
|
||||
|
||||
for (const std::unique_ptr<lcPiece>& Piece : mPieces)
|
||||
{
|
||||
if (Piece->IsSelected() && Piece->GetGroup())
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
FoundGroup = true;
|
||||
break;
|
||||
lcGroup* Group = Piece->GetTopGroup();
|
||||
|
||||
if (SelectedGroups.insert(Group).second)
|
||||
{
|
||||
for (std::vector<std::unique_ptr<lcGroup>>::iterator GroupIt = mGroups.begin(); GroupIt != mGroups.end(); GroupIt++)
|
||||
{
|
||||
if (GroupIt->get() == Group)
|
||||
{
|
||||
GroupIt->release();
|
||||
mGroups.erase(GroupIt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!FoundGroup)
|
||||
if (!SelectedGroups.empty())
|
||||
{
|
||||
QMessageBox::information(gMainWindow, tr("Ungroup Selection"), tr("No groups selected."));
|
||||
return;
|
||||
}
|
||||
|
||||
BeginActionSequence();
|
||||
BeginObjectEditAction();
|
||||
|
||||
RecordGroupPiecesAction(lcModelActionGroupPiecesMode::Ungroup, QString());
|
||||
for (const std::unique_ptr<lcPiece>& Piece : mPieces)
|
||||
{
|
||||
lcGroup* Group = Piece->GetGroup();
|
||||
|
||||
if (SelectedGroups.find(Group) != SelectedGroups.end())
|
||||
Piece->SetGroup(nullptr);
|
||||
}
|
||||
|
||||
for (const std::unique_ptr<lcGroup>& Group : mGroups)
|
||||
if (SelectedGroups.find(Group->mGroup) != SelectedGroups.end())
|
||||
Group->mGroup = nullptr;
|
||||
|
||||
for (lcGroup* Group : SelectedGroups)
|
||||
delete Group;
|
||||
|
||||
RemoveEmptyGroups();
|
||||
|
||||
EndObjectEditAction();
|
||||
EndActionSequence(tr("Ungroup"));
|
||||
|
||||
gMainWindow->UpdateSelectedObjects(true);
|
||||
}
|
||||
|
||||
void lcModel::AddSelectedPiecesToGroup()
|
||||
|
||||
@@ -9,10 +9,6 @@ struct lcModelHistoryState;
|
||||
class lcModelAction;
|
||||
class lcModelActionSelection;
|
||||
class lcModelActionObjectEdit;
|
||||
class lcModelActionGroupPieces;
|
||||
enum class lcModelActionSelectionMode;
|
||||
enum class lcModelActionObjectEditMode;
|
||||
enum class lcModelActionGroupPiecesMode;
|
||||
|
||||
#define LC_SEL_NO_PIECES 0x0001 // No pieces in model
|
||||
#define LC_SEL_PIECE 0x0002 // At least 1 piece selected
|
||||
@@ -164,8 +160,6 @@ public:
|
||||
return mCameras;
|
||||
}
|
||||
|
||||
lcCamera* GetCamera(const QString& Name) const;
|
||||
|
||||
const std::vector<std::unique_ptr<lcLight>>& GetLights() const
|
||||
{
|
||||
return mLights;
|
||||
@@ -421,8 +415,6 @@ protected:
|
||||
void BeginObjectEditAction();
|
||||
void EndObjectEditAction();
|
||||
void RunObjectEditAction(const lcModelActionObjectEdit* ModelActionObjectEdit, bool Apply);
|
||||
void RecordGroupPiecesAction(lcModelActionGroupPiecesMode Mode, const QString& GroupName);
|
||||
void RunGroupPiecesAction(const lcModelActionGroupPieces* ModelActionGroupPieces, bool Apply);
|
||||
|
||||
void RunActionSequence(const std::vector<std::unique_ptr<lcModelAction>>& ActionSequence, bool Apply);
|
||||
void BeginActionSequence();
|
||||
|
||||
@@ -194,8 +194,3 @@ bool lcModelActionObjectEdit::StateChanged() const
|
||||
{
|
||||
return mStartState != mEndState;
|
||||
}
|
||||
|
||||
lcModelActionGroupPieces::lcModelActionGroupPieces(lcModelActionGroupPiecesMode Mode, const QString& GroupName)
|
||||
: mMode(Mode), mGroupName(GroupName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -85,30 +85,3 @@ protected:
|
||||
lcModelHistoryState mStartState;
|
||||
lcModelHistoryState mEndState;
|
||||
};
|
||||
|
||||
enum class lcModelActionGroupPiecesMode
|
||||
{
|
||||
Group,
|
||||
Ungroup
|
||||
};
|
||||
|
||||
class lcModelActionGroupPieces : public lcModelAction
|
||||
{
|
||||
public:
|
||||
lcModelActionGroupPieces(lcModelActionGroupPiecesMode Mode, const QString& GroupName);
|
||||
virtual ~lcModelActionGroupPieces() = default;
|
||||
|
||||
lcModelActionGroupPiecesMode GetMode() const
|
||||
{
|
||||
return mMode;
|
||||
}
|
||||
|
||||
const QString& GetGroupName() const
|
||||
{
|
||||
return mGroupName;
|
||||
}
|
||||
|
||||
protected:
|
||||
lcModelActionGroupPiecesMode mMode;
|
||||
QString mGroupName;
|
||||
};
|
||||
|
||||
+2
-2
@@ -1534,7 +1534,7 @@ void lcLight::RemoveKeyFrames()
|
||||
mPOVRayFadePower.RemoveAllKeys();
|
||||
}
|
||||
|
||||
lcLightHistoryState lcLight::GetHistoryState(const lcModel* Model) const
|
||||
lcLightHistoryState lcLight::GetHistoryState([[maybe_unused]] const lcModel* Model) const
|
||||
{
|
||||
lcLightHistoryState State;
|
||||
|
||||
@@ -1564,7 +1564,7 @@ lcLightHistoryState lcLight::GetHistoryState(const lcModel* Model) const
|
||||
return State;
|
||||
}
|
||||
|
||||
void lcLight::SetHistoryState(const lcLightHistoryState& State, const lcModel* Model)
|
||||
void lcLight::SetHistoryState(const lcLightHistoryState& State, [[maybe_unused]] const lcModel* Model)
|
||||
{
|
||||
mId = State.Id;
|
||||
mHidden = State.Hidden;
|
||||
|
||||
+7
-7
@@ -104,13 +104,13 @@ void lcPiece::SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait, bool U
|
||||
else
|
||||
mID.clear();
|
||||
|
||||
mControlPoints.clear();
|
||||
|
||||
delete mMesh;
|
||||
mMesh = nullptr;
|
||||
|
||||
if (UpdateSynthInfo)
|
||||
{
|
||||
mControlPoints.clear();
|
||||
|
||||
delete mMesh;
|
||||
mMesh = nullptr;
|
||||
|
||||
const lcSynthInfo* SynthInfo = mPieceInfo ? mPieceInfo->GetSynthInfo() : nullptr;
|
||||
|
||||
if (SynthInfo)
|
||||
@@ -945,7 +945,7 @@ lcPieceHistoryState lcPiece::GetHistoryState(const lcModel* Model) const
|
||||
State.Hidden = mHidden;
|
||||
State.FileLine = mFileLine;
|
||||
State.PieceId = mID;
|
||||
State.GroupIndex = ~0;
|
||||
State.GroupIndex = ~0U;
|
||||
State.ColorIndex = mColorIndex;
|
||||
State.ColorCode = mColorCode;
|
||||
State.StepShow = mStepShow;
|
||||
@@ -964,7 +964,7 @@ lcPieceHistoryState lcPiece::GetHistoryState(const lcModel* Model) const
|
||||
{
|
||||
if (mGroup == Groups[GroupIndex].get())
|
||||
{
|
||||
State.GroupIndex = GroupIndex;
|
||||
State.GroupIndex = static_cast<uint32_t>(GroupIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user