Allow undoing hiding operations. Fixes #251.

This commit is contained in:
Leonardo Zide 2018-09-02 10:31:57 -07:00
parent 59ecbcdd5e
commit 69d46cc4c4

View file

@ -3625,13 +3625,9 @@ void lcModel::RemoveFromSelection(const lcObjectSection& ObjectSection)
void lcModel::SelectAllPieces() void lcModel::SelectAllPieces()
{ {
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) for (lcPiece* Piece : mPieces)
{
lcPiece* Piece = mPieces[PieceIdx];
if (Piece->IsVisible(mCurrentStep)) if (Piece->IsVisible(mCurrentStep))
Piece->SetSelected(true); Piece->SetSelected(true);
}
gMainWindow->UpdateSelectedObjects(true); gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews(); gMainWindow->UpdateAllViews();
@ -3639,13 +3635,9 @@ void lcModel::SelectAllPieces()
void lcModel::InvertSelection() void lcModel::InvertSelection()
{ {
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) for (lcPiece* Piece : mPieces)
{
lcPiece* Piece = mPieces[PieceIdx];
if (Piece->IsVisible(mCurrentStep)) if (Piece->IsVisible(mCurrentStep))
Piece->SetSelected(!Piece->IsSelected()); Piece->SetSelected(!Piece->IsSelected());
}
gMainWindow->UpdateSelectedObjects(true); gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews(); gMainWindow->UpdateAllViews();
@ -3653,60 +3645,95 @@ void lcModel::InvertSelection()
void lcModel::HideSelectedPieces() void lcModel::HideSelectedPieces()
{ {
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) bool Modified = false;
{
lcPiece* Piece = mPieces[PieceIdx];
for (lcPiece* Piece : mPieces)
{
if (Piece->IsSelected()) if (Piece->IsSelected())
{ {
Piece->SetHidden(true); Piece->SetHidden(true);
Piece->SetSelected(false); Piece->SetSelected(false);
Modified = true;
} }
} }
if (!Modified)
return;
gMainWindow->UpdateTimeline(false, true); gMainWindow->UpdateTimeline(false, true);
gMainWindow->UpdateSelectedObjects(true); gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews(); gMainWindow->UpdateAllViews();
SaveCheckpoint(tr("Hide"));
} }
void lcModel::HideUnselectedPieces() void lcModel::HideUnselectedPieces()
{ {
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) bool Modified = false;
{
lcPiece* Piece = mPieces[PieceIdx];
for (lcPiece* Piece : mPieces)
{
if (!Piece->IsSelected()) if (!Piece->IsSelected())
{
Piece->SetHidden(true); Piece->SetHidden(true);
Modified = true;
}
} }
if (!Modified)
return;
gMainWindow->UpdateTimeline(false, true); gMainWindow->UpdateTimeline(false, true);
gMainWindow->UpdateSelectedObjects(true); gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews(); gMainWindow->UpdateAllViews();
SaveCheckpoint(tr("Hide"));
} }
void lcModel::UnhideSelectedPieces() void lcModel::UnhideSelectedPieces()
{ {
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) bool Modified = false;
{
lcPiece* Piece = mPieces[PieceIdx];
if (Piece->IsSelected()) for (lcPiece* Piece : mPieces)
{
if (Piece->IsSelected() && Piece->IsHidden())
{
Piece->SetHidden(false); Piece->SetHidden(false);
Modified = true;
}
} }
if (!Modified)
return;
gMainWindow->UpdateTimeline(false, true); gMainWindow->UpdateTimeline(false, true);
gMainWindow->UpdateSelectedObjects(true); gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews(); gMainWindow->UpdateAllViews();
SaveCheckpoint(tr("Unhide"));
} }
void lcModel::UnhideAllPieces() void lcModel::UnhideAllPieces()
{ {
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) bool Modified = false;
mPieces[PieceIdx]->SetHidden(false);
for (lcPiece* Piece : mPieces)
{
if (Piece->IsHidden())
{
Piece->SetHidden(false);
Modified = true;
}
}
if (!Modified)
return;
gMainWindow->UpdateTimeline(false, true); gMainWindow->UpdateTimeline(false, true);
gMainWindow->UpdateSelectedObjects(true); gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews(); gMainWindow->UpdateAllViews();
SaveCheckpoint(tr("Unhide"));
} }
void lcModel::FindPiece(bool FindFirst, bool SearchForward) void lcModel::FindPiece(bool FindFirst, bool SearchForward)