Skip to content

Commit

Permalink
Highlight part line in editor and select part in 3DViewer #417
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Sep 20, 2020
1 parent ef3cb44 commit 30b90a2
Show file tree
Hide file tree
Showing 38 changed files with 1,086 additions and 411 deletions.
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 23, 2019
# Copyright (c) 2017 - 2019 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.0.1719
pkgver=2.4.0.1720
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/alldeps/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.0.1719) debian; urgency=medium
lpub3d (2.4.0.1720) debian; urgency=medium

* LPub3D version 2.4.0.1.1719_20200920 for Linux
* LPub3D version 2.4.0.1.1720_20200920 for Linux

-- Trevor SANDY <[email protected]> Sun, 20 Sep 2020 09:41:32 +0200
-- Trevor SANDY <[email protected]> Sun, 20 Sep 2020 09:42:12 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.0.1719
Version: 2.4.0.1720
Maintainer: Trevor SANDY <[email protected]>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/alldeps/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.0.1719
Version: 2.4.0.1720
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -728,5 +728,5 @@ update-mime-database /usr/share/mime >/dev/null || true
update-desktop-database || true
%endif

* Sun Sep 20 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1719
* Sun Sep 20 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1720
- LPub3D Linux package (rpm) release
Binary file modified builds/utilities/ci/secure/.secrets.tar.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion builds/utilities/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2 4 0 1 1719 6dab7d4
2 4 0 1 1720 ef3cb44
111 changes: 98 additions & 13 deletions lclib/common/lc_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,12 @@ void lcMainWindow::Halt3DViewer(bool b)
}
/*** LPub3D Mod end ***/

/*** LPub3D Mod - Selected Parts ***/
int lcMainWindow::GetImageType(){
return lcGetActiveProject()->GetImageType();
}
/*** LPub3D Mod end ***/

/*** LPub3D Mod - rotate step objects ***/
void lcMainWindow::SetStepRotStepMeta(lcCommandId CommandId)
{
Expand Down Expand Up @@ -2384,34 +2390,111 @@ void lcMainWindow::RemoveRecentFile(int FileIndex)
UpdateRecentFiles();
}

void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
/*** LPub3D Mod - Selected Parts ***/
void lcMainWindow::SetSelectedPieces(QVector<int> &LineTypeIndexes){
if (GetImageType() == Options::CSI) {

lcModel* ActiveModel = GetActiveModel();

if (ActiveModel) {
ActiveModel->SetSelectedPieces(LineTypeIndexes);
}
}
}
/*** LPub3D Mod end ***/

/*** LPub3D Mod - Whole model and selected Parts ***/
void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged, int EmitSelection)
{
int Flags = 0;
lcArray<lcObject*> Selection;
lcObject* Focus = nullptr;

lcGetActiveModel()->GetSelectionInformation(&Flags, Selection, &Focus);
lcModel* ActiveModel = GetActiveModel();
if (ActiveModel)
ActiveModel->GetSelectionInformation(&Flags, Selection, &Focus);

/*** LPub3D Mod - Select whole model if Rotate Tool selected ***/
lcTool Tool = GetTool();
QAction* Action = mActions[LC_EDIT_ACTION_FIRST + Tool];
if (Tool == LC_TOOL_ROTATE && Action && Action->isChecked()) {
View* ActiveView = GetActiveView();
lcModel* ActiveModel = ActiveView ? ActiveView->GetActiveModel() : nullptr;

if (Action && Action->isChecked()) {

if (ActiveModel) {
for (lcPiece* Piece : ActiveModel->GetPieces())
if (Piece->IsVisible(ActiveModel->GetCurrentStep()))
Piece->SetSelected(true);
if (!SelectionChanged)
SelectionChanged = true;
lcObject* ThrowAway;
lcGetActiveModel()->GetSelectionInformation(&Flags, Selection, &ThrowAway);
/*** LPub3D Mod - Select whole model if Rotate Tool selected ***/
if (Tool == LC_TOOL_ROTATE) {

for (lcPiece* Piece : ActiveModel->GetPieces())
if (Piece->IsVisible(ActiveModel->GetCurrentStep()))
Piece->SetSelected(true);

if (!SelectionChanged)
SelectionChanged = true;

lcObject* ThrowAway;
ActiveModel->GetSelectionInformation(&Flags, Selection, &ThrowAway);
/*** LPub3D Mod end ***/

} else

/*** LPub3D Mod - Selected Parts ***/
if (EmitSelection && Tool == LC_TOOL_SELECT && GetImageType() == Options::CSI) {

QVector<TypeLine> LineTypeIndexes;

if (Selection.GetSize() > 0) {

QString Message;
if (Preferences::debugLogging) {
Message = tr("%1 viewer object(s) selected in model [%2]").arg(Selection.GetSize()).arg(ActiveModel->GetName());
gui->statusMessage(LOG_DEBUG, Message);
}

if ((Selection.GetSize() == 1))
{
lcObject *SelectedItem = Selection[0];

if (SelectedItem && SelectedItem->IsPiece()) {

TypeLine typeLine(gui->getSubmodelIndex(ActiveModel->GetName()),((lcPiece*)SelectedItem)->GetLineTypeIndex());
LineTypeIndexes.append(typeLine);

Message = tr("Selected Piece - %1 (ID: %2) LineTypeIndex: %3")
.arg(((lcPiece*)SelectedItem)->GetName())
.arg(((lcPiece*)SelectedItem)->GetID())
.arg(LineTypeIndexes.last().lineIndex);
gui->statusMessage(LOG_DEBUG, Message);
}
}
else if (Selection.GetSize() > 0)
{
for (lcObject *SelectedItem : Selection) {

if (SelectedItem->IsPiece()) {

TypeLine typeLine(gui->getSubmodelIndex(ActiveModel->GetName()),((lcPiece*)SelectedItem)->GetLineTypeIndex());
LineTypeIndexes.append(typeLine);

if (Preferences::debugLogging) {
Message = tr("Selected Piece - %1 (ID: %2) LineTypeIndex: %3")
.arg(((lcPiece*)SelectedItem)->GetName())
.arg(((lcPiece*)SelectedItem)->GetID())
.arg(LineTypeIndexes.last().lineIndex);
gui->statusMessage(LOG_DEBUG, Message);
}
}
}
}
}
emit SelectedPartLinesSig(LineTypeIndexes, PartSource(EmitSelection));
}
/*** LPub3D Mod end ***/
}
}
/*** LPub3D Mod end ***/

if (SelectionChanged)
{

mTimelineWidget->UpdateSelection();

mActions[LC_EDIT_CUT]->setEnabled(Flags & LC_SEL_SELECTED);
Expand Down Expand Up @@ -2448,6 +2531,8 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
mActions[LC_PIECE_SHOW_EARLIER]->setEnabled(Flags & LC_SEL_PIECE); // FIXME: disable if current step is 1
mActions[LC_PIECE_SHOW_LATER]->setEnabled(Flags & LC_SEL_PIECE);
mActions[LC_TIMELINE_MOVE_SELECTION]->setEnabled(Flags & LC_SEL_PIECE);

mActions[LC_PIECE_EDIT_END_SUBMODEL]->setEnabled(GetCurrentTabModel() != ActiveModel);
}

mPropertiesWidget->Update(Selection, Focus);
Expand Down
16 changes: 12 additions & 4 deletions lclib/common/lc_mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class lcMainWindow : public QMainWindow
void AddView(View* View);
void RemoveView(View* View);
void SetActiveView(View* ActiveView);
/*** void UpdateAllViews(); // LPub3D Mod - moved to public slots ***/
/*** void UpdateAllViews(); // LPub3D Mod - moved to public slots ***/
void SetTool(lcTool Tool);
void SetTransformType(lcTransformType TransformType);
void SetRotateStepCoordType(lcRotateStepCoordType RotateStepCoordType);
Expand All @@ -305,7 +305,7 @@ class lcMainWindow : public QMainWindow
void SetShadingMode(lcShadingMode ShadingMode);
void SetSelectionMode(lcSelectionMode SelectionMode);

/*** void NewProject(); // LPub3D Mod - moved to public slots ***/
/*** void NewProject(); // LPub3D Mod - moved to public slots ***/
bool OpenProject(const QString& FileName);
void MergeProject();
void ImportLDD();
Expand All @@ -327,7 +327,7 @@ class lcMainWindow : public QMainWindow
void TogglePrintPreview();
void ToggleFullScreen();

void UpdateSelectedObjects(bool SelectionChanged);
void UpdateSelectedObjects(bool SelectionChanged, int EmitSelection = VIEWER_LINE);
void UpdateTimeline(bool Clear, bool UpdateItems);
void UpdatePaste(bool Enabled);
void UpdateCurrentStep();
Expand Down Expand Up @@ -398,6 +398,11 @@ public slots:
void SetStepRotStepMeta(lcCommandId CommandId);
/*** LPub3D Mod end ***/

/*** LPub3D Mod - Selected Parts ***/
int GetImageType();
void SetSelectedPieces(QVector<int> &LineTypeIndexes);
/*** LPub3D Mod end ***/

/*** LPub3D Mod - rotate step signals ***/
signals:
lcVector3 GetRotStepMeta(); // used to capture step meta angles
Expand All @@ -410,7 +415,10 @@ public slots:
/*** LPub3D Mod - export image completion ***/
void updateSig();
/*** LPub3D Mod end ***/

/*** LPub3D Mod - Selected Parts ***/
void SetActiveModelSig(const QString &, bool);
void SelectedPartLinesSig(QVector<TypeLine> &, PartSource);
/*** LPub3D Mod end ***/
protected slots:
void UpdateGamepads();
void ModelTabContextMenuRequested(const QPoint& Point);
Expand Down
Loading

0 comments on commit 30b90a2

Please sign in to comment.