mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Better updates for the timeline.
This commit is contained in:
parent
c4b15d05a9
commit
537aa5552b
5 changed files with 47 additions and 14 deletions
|
@ -1359,7 +1359,6 @@ void lcMainWindow::RemoveRecentFile(int FileIndex)
|
|||
|
||||
void lcMainWindow::UpdateFocusObject(lcObject* Focus)
|
||||
{
|
||||
UpdateTimeline();
|
||||
mPropertiesWidget->updateFocusObject(Focus);
|
||||
|
||||
lcVector3 Position;
|
||||
|
|
|
@ -849,6 +849,8 @@ void lcModel::Merge(lcModel* Other)
|
|||
Other->mGroups.RemoveAll();
|
||||
|
||||
delete Other;
|
||||
|
||||
gMainWindow->UpdateTimeline();
|
||||
}
|
||||
|
||||
void lcModel::Cut()
|
||||
|
@ -857,6 +859,7 @@ void lcModel::Cut()
|
|||
|
||||
if (RemoveSelectedObjects())
|
||||
{
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(NULL);
|
||||
UpdateSelection();
|
||||
gMainWindow->UpdateAllViews();
|
||||
|
@ -890,9 +893,10 @@ void lcModel::Paste()
|
|||
Merge(Model);
|
||||
SaveCheckpoint(tr("Pasting"));
|
||||
|
||||
SetSelection((lcArray<lcObject*>&)PastedPieces);
|
||||
SetSelectionAndFocus((lcArray<lcObject*>&)PastedPieces, NULL, 0);
|
||||
|
||||
CalculateStep(mCurrentStep);
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -1219,6 +1223,7 @@ void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint)
|
|||
Buffer.open(QIODevice::ReadOnly);
|
||||
LoadLDraw(Buffer, lcGetActiveProject());
|
||||
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(GetFocusObject());
|
||||
gMainWindow->UpdateCameraMenu();
|
||||
UpdateSelection();
|
||||
|
@ -1355,6 +1360,7 @@ void lcModel::InsertStep()
|
|||
|
||||
SaveCheckpoint(tr("Inserting Step"));
|
||||
CalculateStep(mCurrentStep);
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(GetFocusObject());
|
||||
gMainWindow->UpdateAllViews();
|
||||
UpdateSelection();
|
||||
|
@ -1378,6 +1384,7 @@ void lcModel::RemoveStep()
|
|||
|
||||
SaveCheckpoint(tr("Removing Step"));
|
||||
CalculateStep(mCurrentStep);
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(GetFocusObject());
|
||||
gMainWindow->UpdateAllViews();
|
||||
UpdateSelection();
|
||||
|
@ -1835,6 +1842,7 @@ void lcModel::AddPiece()
|
|||
Piece->Initialize(WorldMatrix, mCurrentStep);
|
||||
Piece->SetColorIndex(gMainWindow->mColorIndex);
|
||||
AddPiece(Piece);
|
||||
gMainWindow->UpdateTimeline();
|
||||
ClearSelectionAndSetFocus(Piece, LC_PIECE_SECTION_POSITION);
|
||||
|
||||
SaveCheckpoint("Adding Piece");
|
||||
|
@ -1871,6 +1879,7 @@ void lcModel::DeleteSelectedObjects()
|
|||
{
|
||||
if (RemoveSelectedObjects())
|
||||
{
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(NULL);
|
||||
UpdateSelection();
|
||||
gMainWindow->UpdateAllViews();
|
||||
|
@ -1989,6 +1998,7 @@ void lcModel::SetPieceSteps(const QList<QPair<lcPiece*, int>>& PieceSteps)
|
|||
SaveCheckpoint("Modifying");
|
||||
gMainWindow->UpdateAllViews();
|
||||
UpdateSelection();
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(GetFocusObject());
|
||||
}
|
||||
}
|
||||
|
@ -2450,6 +2460,7 @@ void lcModel::SetObjectProperty(lcObject* Object, lcObjectPropertyType ObjectPro
|
|||
if (!CheckPointString.isEmpty())
|
||||
{
|
||||
SaveCheckpoint(CheckPointString);
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(GetFocusObject());
|
||||
gMainWindow->UpdateAllViews();
|
||||
}
|
||||
|
@ -2930,10 +2941,19 @@ void lcModel::ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection)
|
|||
ClearSelectionAndSetFocus(ObjectSection.Object, ObjectSection.Section);
|
||||
}
|
||||
|
||||
void lcModel::SetSelection(const lcArray<lcObject*>& Objects)
|
||||
void lcModel::SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject* Focus, lcuint32 Section)
|
||||
{
|
||||
ClearSelection(false);
|
||||
AddToSelection(Objects);
|
||||
|
||||
if (Focus)
|
||||
{
|
||||
Focus->SetFocused(Section, true);
|
||||
|
||||
if (Focus->IsPiece())
|
||||
SelectGroup(((lcPiece*)Focus)->GetTopGroup(), true);
|
||||
}
|
||||
|
||||
AddToSelection(Selection);
|
||||
}
|
||||
|
||||
void lcModel::AddToSelection(const lcArray<lcObject*>& Objects)
|
||||
|
@ -3186,6 +3206,7 @@ void lcModel::InsertPieceToolClicked(const lcMatrix44& WorldMatrix)
|
|||
Piece->UpdatePosition(mCurrentStep);
|
||||
AddPiece(Piece);
|
||||
|
||||
gMainWindow->UpdateTimeline();
|
||||
ClearSelectionAndSetFocus(Piece, LC_PIECE_SECTION_POSITION);
|
||||
|
||||
SaveCheckpoint(tr("Insert"));
|
||||
|
@ -3306,6 +3327,7 @@ void lcModel::EraserToolClicked(lcObject* Object)
|
|||
}
|
||||
|
||||
delete Object;
|
||||
gMainWindow->UpdateTimeline();
|
||||
gMainWindow->UpdateFocusObject(GetFocusObject());
|
||||
UpdateSelection();
|
||||
gMainWindow->UpdateAllViews();
|
||||
|
@ -3471,7 +3493,7 @@ void lcModel::ShowSelectByNameDialog()
|
|||
if (!gMainWindow->DoDialog(LC_DIALOG_SELECT_BY_NAME, &Options))
|
||||
return;
|
||||
|
||||
SetSelection(Options.Objects);
|
||||
SetSelectionAndFocus(Options.Objects, NULL, 0);
|
||||
}
|
||||
|
||||
void lcModel::ShowArrayDialog()
|
||||
|
@ -3550,6 +3572,7 @@ void lcModel::ShowArrayDialog()
|
|||
}
|
||||
|
||||
AddToSelection(NewPieces);
|
||||
gMainWindow->UpdateTimeline();
|
||||
SaveCheckpoint(tr("Array"));
|
||||
}
|
||||
|
||||
|
@ -3581,7 +3604,8 @@ void lcModel::ShowMinifigDialog()
|
|||
Pieces.Add(Piece);
|
||||
}
|
||||
|
||||
SetSelection(Pieces);
|
||||
SetSelectionAndFocus(Pieces, NULL, 0);
|
||||
gMainWindow->UpdateTimeline();
|
||||
SaveCheckpoint(tr("Minifig"));
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ public:
|
|||
void ClearSelection(bool UpdateInterface);
|
||||
void ClearSelectionAndSetFocus(lcObject* Object, lcuint32 Section);
|
||||
void ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection);
|
||||
void SetSelection(const lcArray<lcObject*>& Objects);
|
||||
void SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject* Focus, lcuint32 Section);
|
||||
void AddToSelection(const lcArray<lcObject*>& Objects);
|
||||
void SelectAllPieces();
|
||||
void InvertSelection();
|
||||
|
|
|
@ -39,6 +39,9 @@ void lcTimelineWidget::CustomMenuRequested(QPoint Pos)
|
|||
|
||||
void lcTimelineWidget::Update()
|
||||
{
|
||||
if (mIgnoreUpdates)
|
||||
return;
|
||||
|
||||
lcModel* Model = lcGetActiveModel();
|
||||
|
||||
if (!Model)
|
||||
|
@ -67,9 +70,9 @@ void lcTimelineWidget::Update()
|
|||
delete StepItem;
|
||||
}
|
||||
|
||||
for (int Step = topLevelItemCount(); Step < Steps; Step++)
|
||||
for (int TopLevelItemIdx = topLevelItemCount(); TopLevelItemIdx < Steps; TopLevelItemIdx++)
|
||||
{
|
||||
QTreeWidgetItem* StepItem = new QTreeWidgetItem(this, QStringList(tr("Step %1").arg(Step + 1)));
|
||||
QTreeWidgetItem* StepItem = new QTreeWidgetItem(this, QStringList(tr("Step %1").arg(TopLevelItemIdx + 1)));
|
||||
StepItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
|
||||
addTopLevelItem(StepItem);
|
||||
StepItem->setExpanded(true);
|
||||
|
@ -78,13 +81,13 @@ void lcTimelineWidget::Update()
|
|||
const lcArray<lcPiece*>& Pieces = Model->GetPieces();
|
||||
QTreeWidgetItem* StepItem = NULL;
|
||||
int PieceItemIndex = 0;
|
||||
int Step = -1;
|
||||
int Step = 0;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx != Pieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = Pieces[PieceIdx];
|
||||
|
||||
if (Step != Piece->GetStepShow())
|
||||
while (Step != Piece->GetStepShow())
|
||||
{
|
||||
if (StepItem)
|
||||
{
|
||||
|
@ -106,7 +109,7 @@ void lcTimelineWidget::Update()
|
|||
}
|
||||
}
|
||||
|
||||
Step = Piece->GetStepShow();
|
||||
Step++;
|
||||
StepItem = topLevelItem(Step - 1);
|
||||
PieceItemIndex = 0;
|
||||
}
|
||||
|
@ -184,9 +187,14 @@ void lcTimelineWidget::ItemSelectionChanged()
|
|||
Selection.Add(Piece);
|
||||
}
|
||||
|
||||
lcPiece* CurrentPiece = NULL;
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
if (CurrentItem && CurrentItem->isSelected())
|
||||
CurrentPiece = (lcPiece*)CurrentItem->data(0, Qt::UserRole).value<uintptr_t>();
|
||||
|
||||
bool Blocked = blockSignals(true);
|
||||
mIgnoreUpdates = true;
|
||||
lcGetActiveModel()->SetSelection(Selection);
|
||||
lcGetActiveModel()->SetSelectionAndFocus(Selection, CurrentPiece, LC_PIECE_SECTION_POSITION);
|
||||
mIgnoreUpdates = false;
|
||||
blockSignals(Blocked);
|
||||
}
|
||||
|
@ -210,5 +218,7 @@ void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
|||
}
|
||||
}
|
||||
|
||||
mIgnoreUpdates = true;
|
||||
lcGetActiveModel()->SetPieceSteps(PieceSteps);
|
||||
mIgnoreUpdates = false;
|
||||
}
|
||||
|
|
|
@ -1921,7 +1921,7 @@ void View::StopTracking(bool Accept)
|
|||
if (mInputState.Control)
|
||||
mModel->AddToSelection(Objects);
|
||||
else
|
||||
mModel->SetSelection(Objects);
|
||||
mModel->SetSelectionAndFocus(Objects, NULL, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue