Skip to content

Commit

Permalink
Highlighted line Improve sync between editor and viewer #417
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Oct 1, 2020
1 parent 7b9a015 commit 321e895
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 62 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 19, 2020
# Copyright (c) 2017 - 2020 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.0.1955
pkgver=2.4.0.1956
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.1955) debian; urgency=medium
lpub3d (2.4.0.1956) debian; urgency=medium

* LPub3D version 2.4.0.1.1955_20201002 for Linux
* LPub3D version 2.4.0.1.1956_20201002 for Linux

-- Trevor SANDY <[email protected]> Fri, 02 Oct 2020 01:26:09 +0200
-- Trevor SANDY <[email protected]> Fri, 02 Oct 2020 01:26:52 +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.1955
Version: 2.4.0.1956
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.1955
Version: 2.4.0.1956
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

* Fri Oct 02 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1955
* Fri Oct 02 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1956
- 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 1955 3a8504c
2 4 0 1 1956 7b9a015
32 changes: 25 additions & 7 deletions lclib/common/lc_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ void lcMainWindow::SetSelectedPieces(QVector<int> &LineTypeIndexes){
/*** LPub3D Mod end ***/

/*** LPub3D Mod - Whole model and selected Parts ***/
void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged, int EmitSelection)
void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged, int SelectionType)
{
int Flags = 0;
lcArray<lcObject*> Selection;
Expand All @@ -2401,14 +2401,31 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged, int EmitSelectio
ActiveModel->GetSelectionInformation(&Flags, Selection, &Focus);

lcTool Tool = GetTool();
bool BuildModTool = Tool == LC_TOOL_SELECT || Tool == LC_TOOL_ERASER;
QAction* Action = mActions[LC_EDIT_ACTION_FIRST + Tool];
bool BuildModTool = false;
switch (Tool)
{
case LC_TOOL_SELECT:
case LC_TOOL_INSERT:
case LC_TOOL_MOVE:
case LC_TOOL_ROTATE:
case LC_TOOL_ERASER:
case LC_TOOL_PAINT:
case LC_TOOL_COLOR_PICKER:
BuildModTool = true;
break;
default:
BuildModTool = false;
break;
}
bool BuildModEnabled = lcGetProfileInt(LC_PROFILE_BUILD_MODIFICATION);
bool BuildModType = GetImageType() != Options::PLI;

QAction* Action = mActions[LC_EDIT_ACTION_FIRST + Tool];
if (Action && Action->isChecked()) {

if (ActiveModel) {
/*** LPub3D Mod - Select whole model if Rotate Tool selected and not build modification ***/
if (Tool == LC_TOOL_ROTATE && !lcGetProfileInt(LC_PROFILE_BUILD_MODIFICATION)) {
if (Tool == LC_TOOL_ROTATE && !BuildModEnabled) {

for (lcPiece* Piece : ActiveModel->GetPieces())
if (Piece->IsVisible(ActiveModel->GetCurrentStep()))
Expand All @@ -2424,7 +2441,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged, int EmitSelectio
} else

/*** LPub3D Mod - Selected Parts ***/
if (EmitSelection && BuildModTool && GetImageType() != Options::PLI) {
if (SelectionType && BuildModTool && BuildModType) {

QVector<TypeLine> LineTypeIndexes;

Expand Down Expand Up @@ -2472,7 +2489,8 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged, int EmitSelectio
}
}
}
emit SelectedPartLinesSig(LineTypeIndexes, PartSource(EmitSelection));
if (SelectionType != VIEWER_LINE)
emit SelectedPartLinesSig(LineTypeIndexes, PartSource(SelectionType));
}
/*** LPub3D Mod end ***/
}
Expand Down Expand Up @@ -2557,7 +2575,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged, int EmitSelectio
/*** LPub3D Mod end ***/

/*** LPub3D Mod - replace mStatusBarLabel ***/
statusBar()->showMessage(Focus && Focus->IsPiece() && EmitSelection == VIEWER_MOD ? Label : Selection.GetSize() == 1 ? Message.append(" " + Label) : Message);
statusBar()->showMessage(Focus && Focus->IsPiece() && SelectionType == VIEWER_MOD ? Label : Selection.GetSize() == 1 ? Message.append(" " + Label) : Message);
/* mStatusPositionLabel->setText(Label); */
/*** LPub3D Mod end ***/
}
Expand Down
2 changes: 1 addition & 1 deletion lclib/common/lc_mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class lcMainWindow : public QMainWindow
void ToggleFullScreen();

/*** LPub3D Mod - selected Line ***/
void UpdateSelectedObjects(bool SelectionChanged, int EmitSelection = VIEWER_LINE);
void UpdateSelectedObjects(bool SelectionChanged, int SelectionType = VIEWER_LINE);
/*** LPub3D Mod end ***/
void UpdateTimeline(bool Clear, bool UpdateItems);
void UpdatePaste(bool Enabled);
Expand Down
59 changes: 40 additions & 19 deletions lclib/common/lc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3545,24 +3545,18 @@ bool lcModel::AnyObjectsSelected() const
for (lcCamera* Camera : mCameras)
if (Camera->IsSelected())
return true;
/*** LPub3D Mod - Build Modification, suppress select move overlay for pieces ***/
/***/
if (Preferences::buildModEnabled) {
/*** LPub3D Mod - Build Modification ***/
if (lcGetProfileInt(LC_PROFILE_BUILD_MODIFICATION)) {
if (gMainWindow->GetImageType() != Options::PLI) {
for (lcPiece* Piece : mPieces)
if (Piece->IsSelected())
return true;
}
}
/***/
/*** LPub3D Mod end ***/
/*** LPub3D Mod - Suppress select move overlay for light ***/
/***/
for (lcLight* Light : mLights)
if (Light->IsSelected())
return true;
/***/
/*** LPub3D Mod end ***/
return false;
}

Expand Down Expand Up @@ -3977,19 +3971,31 @@ lcArray<lcObject*> lcModel::GetSelectionModePieces(lcPiece* SelectedPiece) const

void lcModel::ClearSelection(bool UpdateInterface)
{
for (lcPiece* Piece : mPieces)
/*** LPub3D Mod - Selected Parts ***/
bool WasSelected = false;
/*** LPub3D Mod end ***/

/*** LPub3D Mod - Selected Parts ***/
for (lcPiece* Piece : mPieces) {
if (!WasSelected && Piece->IsSelected())
WasSelected = true;
Piece->SetSelected(false);
}
/*** LPub3D Mod end ***/

for (lcCamera* Camera : mCameras)
Camera->SetSelected(false);

for (lcLight* Light : mLights)
Light->SetSelected(false);

if (UpdateInterface)
/*** LPub3D Mod - Selected Parts ***/
if (UpdateInterface || WasSelected)
{
gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews();
gMainWindow->UpdateSelectedObjects(true, WasSelected ? VIEWER_CLEAR : VIEWER_LINE);
if (UpdateInterface)
gMainWindow->UpdateAllViews();
/*** LPub3D Mod end ***/
}
}

Expand Down Expand Up @@ -4053,16 +4059,17 @@ void lcModel::ClearSelectionAndSetFocus(lcObject* Object, quint32 Section, bool
ClearSelection(false);
/*** LPub3D Mod - Build Modification ***/
bool IsPiece = false;
/*** LPub3D Mod end ***/
bool IsObject = false;

if (Object)
if ((IsObject = Object))
{
/*** LPub3D Mod end ***/
Object->SetFocused(Section, true);

/*** LPub3D Mod - Build Modification ***/
if ((IsPiece = Object->IsPiece()))
/*** LPub3D Mod end ***/
{
/*** LPub3D Mod end ***/
SelectGroup(((lcPiece*)Object)->GetTopGroup(), true);

if (EnableSelectionMode)
Expand All @@ -4073,7 +4080,9 @@ void lcModel::ClearSelectionAndSetFocus(lcObject* Object, quint32 Section, bool
}
}
/*** LPub3D Mod - Build Modification ***/
gMainWindow->UpdateSelectedObjects(true, IsPiece ? VIEWER_MOD : VIEWER_LINE);
// If we have objects we send back viewer mod if we have a piece other wise we return VIEWER_LINE
// It no object, we return VIEWER_NONE here and have ClearSelection handle returns for objects that were selected.
gMainWindow->UpdateSelectedObjects(true, IsObject ? IsPiece ? VIEWER_MOD : VIEWER_LINE : VIEWER_NONE);
/*** LPub3D Mod end ***/
gMainWindow->UpdateAllViews();
}
Expand Down Expand Up @@ -4108,13 +4117,22 @@ void lcModel::SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject

void lcModel::AddToSelection(const lcArray<lcObject*>& Objects, bool EnableSelectionMode, bool UpdateInterface)
{
/*** LPub3D Mod - Selected Parts ***/
bool IsPiece = false;
/*** LPub3D Mod end ***/

for (lcObject* Object : Objects)
{
bool WasSelected = Object->IsSelected();
Object->SetSelected(true);

if (Object->IsPiece())
{
/*** LPub3D Mod - Selected Parts ***/
if (!IsPiece)
IsPiece = true;
/*** LPub3D Mod end ***/

if (!WasSelected)
SelectGroup(((lcPiece*)Object)->GetTopGroup(), true);

Expand All @@ -4126,10 +4144,13 @@ void lcModel::AddToSelection(const lcArray<lcObject*>& Objects, bool EnableSelec
}
}

if (UpdateInterface)
/*** LPub3D Mod - Selected Parts ***/
if (UpdateInterface || IsPiece)
{
gMainWindow->UpdateSelectedObjects(true);
gMainWindow->UpdateAllViews();
gMainWindow->UpdateSelectedObjects(true, VIEWER_MOD);
if (UpdateInterface)
gMainWindow->UpdateAllViews();
/*** LPub3D Mod end ***/
}
}

Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LPub3D 2.4.0.1.1955 (02 10 2020 01:26:09)
LPub3D 2.4.0.1.1956 (02 10 2020 01:26:52)

Features, enhancements, fixes and changes
------------
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/RELEASE_NOTES.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table class="tg">
<tr>
<th class="tg-0pky">
<h4><a id="LPub3D_0"></a>LPub3D 2.4.0.1.1955 (02 10 2020 01:26:09)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.0.1.1956 (02 10 2020 01:26:52)</h4>
<hr>
<p>
LPub3D Continuous release.<br>
Expand Down
26 changes: 18 additions & 8 deletions mainApp/editwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "lc_model.h"
#include "lc_library.h"
#include "project.h"
#include "lc_mainwindow.h"

#include "previewwidget.h"

Expand Down Expand Up @@ -838,7 +839,7 @@ bool EditWindow::saveFile()
return rc;
}

void EditWindow::highlightSelectedLines(QVector<int> &lines)
void EditWindow::highlightSelectedLines(QVector<int> &lines, bool clear)
{
disconnect(_textEdit->document(), SIGNAL(contentsChange(int,int,int)),
this, SLOT( contentsChange(int,int,int)));
Expand All @@ -853,15 +854,22 @@ void EditWindow::highlightSelectedLines(QVector<int> &lines)

QColor lineColor = QColor(Qt::transparent);
bool applyFormat = lines.size();
if (applyFormat){
if (Preferences::displayTheme == THEME_DEFAULT) {
lineColor = QColor(Qt::yellow).lighter(180);
} else if (Preferences::displayTheme == THEME_DARK) {
lineColor = QColor(Qt::yellow).lighter(180);
lineColor.setAlpha(100); // make 60% transparent
if (applyFormat) {
if (clear) {
if (Preferences::displayTheme == THEME_DEFAULT) {
lineColor = QColor(Qt::white);
} else if (Preferences::displayTheme == THEME_DARK) {
lineColor = QColor(THEME_SCENE_BGCOLOR_DARK);
}
} else {
if (Preferences::displayTheme == THEME_DEFAULT) {
lineColor = QColor(Qt::yellow).lighter(180);
} else if (Preferences::displayTheme == THEME_DARK) {
lineColor = QColor(Qt::yellow).lighter(180);
lineColor.setAlpha(100); // make 60% transparent
}
}
}

QTextCharFormat plainFormat(highlightCursor.charFormat());
QTextCharFormat colorFormat = plainFormat;
colorFormat.setBackground(lineColor);
Expand Down Expand Up @@ -979,6 +987,8 @@ void EditWindow::pageUpDown(
}

void EditWindow::updateSelectedParts() {
if (!gMainWindow->isVisible())
return;

if (isIncludeFile)
return;
Expand Down
2 changes: 1 addition & 1 deletion mainApp/editwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public slots:
void setSubFiles(const QStringList& subFiles);
void modelFileChanged(const QString &fileName);
void showLine(int, int);
void highlightSelectedLines(QVector<int> &lines);
void highlightSelectedLines(QVector<int> &lines, bool clear);
void triggerPreviewLine();
void updateDisabled(bool);
void clearEditorWindow();
Expand Down
4 changes: 2 additions & 2 deletions mainApp/lpub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3025,8 +3025,8 @@ Gui::Gui()
connect(this, SIGNAL(showLineSig(int, int)),
editWindow, SLOT( showLine( int, int)));

connect(this, SIGNAL(highlightSelectedLinesSig(QVector<int> &)),
editWindow, SLOT( highlightSelectedLines( QVector<int> &)));
connect(this, SIGNAL(highlightSelectedLinesSig(QVector<int> &, bool)),
editWindow, SLOT( highlightSelectedLines( QVector<int> &, bool)));

connect(this, SIGNAL(clearEditorWindowSig()),
editWindow, SLOT( clearEditorWindow()));
Expand Down
2 changes: 1 addition & 1 deletion mainApp/lpub.h
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ public slots:
void displayFileSig(LDrawFile *ldrawFile, const QString &subFile);
void displayModelFileSig(LDrawFile *ldrawFile, const QString &subFile);
void displayParmsFileSig(const QString &fileName);
void highlightSelectedLinesSig(QVector<int> &indexes);
void highlightSelectedLinesSig(QVector<int> &indexes, bool clear);
void setSelectedPiecesSig(QVector<int> &indexes);
void showLineSig(int lineNumber, int type);
void setSubFilesSig(const QStringList &subFiles);
Expand Down
5 changes: 4 additions & 1 deletion mainApp/name.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ enum SaveOnSender { SaveOnNone, SaveOnRedraw, SaveOnUpdate };
enum NativeType { NTypeDefault, NTypeCalledOut, NTypeMultiStep };
enum ShowLineType { LINE_HIGHLIGHT, LINE_ERROR };
enum SceneObjectInfo { ObjectId };


enum PartSource {
NOT_FOUND = -1, // -1
NEW_PART = NOT_FOUND, // -1
Expand All @@ -69,7 +71,8 @@ enum PartSource {
VIEWER_NONE = EDITOR_LINE, // 0
VIEWER_LINE, // 1
VIEWER_MOD, // 2
VIEWER_DEL // 3
VIEWER_DEL, // 3
VIEWER_CLEAR // 4
};

enum BuildModFlags {
Expand Down
Loading

0 comments on commit 321e895

Please sign in to comment.