Skip to content

Commit

Permalink
Add highlight lines and set step to editor preferences #417
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Mar 12, 2021
1 parent ada0606 commit e98c873
Show file tree
Hide file tree
Showing 18 changed files with 128 additions and 67 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.1.2111
pkgver=2.4.1.2112
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.1.2111) debian; urgency=medium
lpub3d (2.4.1.2112) debian; urgency=medium

* LPub3D version 2.4.1.1.2111_20210312 for Linux
* LPub3D version 2.4.1.1.2112_20210312 for Linux

-- Trevor SANDY <[email protected]> Fri, 12 Mar 2021 07:22:58 +0100
-- Trevor SANDY <[email protected]> Fri, 12 Mar 2021 07:23:37 +0100
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.1.2111
Version: 2.4.1.2112
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.1.2111
Version: 2.4.1.2112
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -731,5 +731,5 @@ update-mime-database /usr/share/mime >/dev/null || true
update-desktop-database || true
%endif

* Fri Mar 12 2021 - trevor.dot.sandy.at.gmail.dot.com 2.4.1.2111
* Fri Mar 12 2021 - trevor.dot.sandy.at.gmail.dot.com 2.4.1.2112
- 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 1 1 2111 cabb1f3
2 4 1 1 2112 ada0606
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.1.1.2111 (12 03 2021 07:22:58)
LPub3D 2.4.1.1.2112 (12 03 2021 07:23:37)

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.1.1.2111 (12 03 2021 07:22:58)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.1.1.2112 (12 03 2021 07:23:37)</h4>
<hr>
<p>
LPub3D Official release.<br>
Expand Down
97 changes: 67 additions & 30 deletions mainApp/editwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,9 @@ void EditWindow::highlightSelectedLines(QVector<int> &lines, bool clear, bool ed
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 = QColor(editorSelection ? Qt::cyan : Qt::green).lighter(180);
if (Preferences::displayTheme == THEME_DARK)
lineColor.setAlpha(100); // make 60% transparent
}
}
}

Expand Down Expand Up @@ -1124,9 +1121,11 @@ void EditWindow::updateSelectedParts() {
if (isIncludeFile)
return;

int lineNumber = 0;
int currentLine = 0;
int selectedLines = 0;
bool clearSelection = false;
TypeLine typeLine = { -1/*fileOrderIndex*/, 0/*lineNumber*/ };

QVector<TypeLine> lineTypeIndexes;
QVector<int> toggleLines;
Expand Down Expand Up @@ -1169,25 +1168,36 @@ void EditWindow::updateSelectedParts() {

while (currentLine < selectedLines)
{
QString selection = content.at(currentLine);
int lineNumber = getSelectedLineNumber();
TypeLine typeLine(fileOrderIndex,lineNumber);
emit setStepForLineSig(typeLine);
if (Preferences::editorLoadSelectionStep)
{
lineNumber = getSelectedLineNumber();
typeLine = { fileOrderIndex, lineNumber };
emit setStepForLineSig(typeLine);
}

if (content.at(currentLine).startsWith("1") ||
content.at(currentLine).contains(" PLI BEGIN SUB "))
{
lineTypeIndexes.append(typeLine);
if (stepLines.isInScope(lineNumber))
if (!Preferences::editorLoadSelectionStep)
{
toggleLines.append(lineNumber);
clearSelection = savedSelection.contains(lineNumber);
highlightSelectedLines(toggleLines, clearSelection, true/*editorSelection*/);
if (clearSelection)
savedSelection.removeAll(lineNumber);
else
savedSelection.append(lineNumber);
toggleLines.clear();
lineNumber = getSelectedLineNumber();
typeLine = { fileOrderIndex, lineNumber };
}

lineTypeIndexes.append(typeLine);

if (Preferences::editorHighlightLines) {
if (stepLines.isInScope(lineNumber))
{
toggleLines.append(lineNumber);
clearSelection = savedSelection.contains(lineNumber);
highlightSelectedLines(toggleLines, clearSelection, true/*editorSelection*/);
if (clearSelection)
savedSelection.removeAll(lineNumber);
else
savedSelection.append(lineNumber);
toggleLines.clear();
}
}
}
// set next selected line
Expand Down Expand Up @@ -1447,10 +1457,12 @@ void EditWindow::closeEvent(QCloseEvent *_event)

void EditWindow::preferences()
{
QString windowTitle = QString("Editor Preferences");
int editorDecoration = Preferences::editorDecoration;
int editorLinesPerPage = Preferences::editorLinesPerPage;
bool editorBufferedPaging = Preferences::editorBufferedPaging;
QString windowTitle = QString("Editor Preferences");
int editorDecoration = Preferences::editorDecoration;
int editorLinesPerPage = Preferences::editorLinesPerPage;
bool editorBufferedPaging = Preferences::editorBufferedPaging;
bool editorHighlightLines = Preferences::editorHighlightLines;
bool editorLoadSelectionStep = Preferences::editorLoadSelectionStep;

auto showMessage = [&windowTitle] (const QString change) {
QPixmap _icon = QPixmap(":/icons/lpub96.png");
Expand Down Expand Up @@ -1482,31 +1494,44 @@ void EditWindow::preferences()
form->addWidget(editorDecorationGrpBox);
QFormLayout *editorDecorationSubform = new QFormLayout(editorDecorationGrpBox);

QLabel *editorDecorationLabel = new QLabel("Text Decoration:", dialog);
QLabel *editorDecorationLabel = new QLabel(tr("Text Decoration:"), dialog);
QComboBox * editorDecorationCombo = new QComboBox(dialog);
editorDecorationCombo->addItem(tr("Simple"));
editorDecorationCombo->addItem(tr("Standard"));
editorDecorationCombo->setCurrentIndex(editorDecoration);
editorDecorationCombo->setToolTip("Set text decoration. Fancy decoration will slow-down loading very large models");
editorDecorationCombo->setStatusTip("Use dropdown to select LDraw editor text decoration");
editorDecorationCombo->setToolTip(tr("Set text decoration. Fancy decoration will slow-down loading very large models"));
editorDecorationSubform->addRow(editorDecorationLabel, editorDecorationCombo);

// options - buffered paging
QGroupBox *editorBufferedPagingGrpBox = new QGroupBox(tr("Buffered paging"));
editorBufferedPagingGrpBox->setCheckable(true);
editorBufferedPagingGrpBox->setChecked(editorBufferedPaging);
editorBufferedPagingGrpBox->setToolTip("Set buffered paging. Improve the loading times for very large models");
editorBufferedPagingGrpBox->setToolTip(tr("Set buffered paging. Improve the loading times for very large models"));
form->addWidget(editorBufferedPagingGrpBox);
QFormLayout *editorBufferedPagingSubform = new QFormLayout(editorBufferedPagingGrpBox);

QLabel *editorLinesPerPageLabel = new QLabel("Lines Per Buffered Page:", dialog);
QLabel *editorLinesPerPageLabel = new QLabel(tr("Lines Per Buffered Page:"), dialog);
QSpinBox *editorLinesPerPageSpin = new QSpinBox(dialog);
editorLinesPerPageSpin->setRange(EDITOR_MIN_LINES_DEFAULT,EDITOR_MAX_LINES_DEFAULT);
editorLinesPerPageSpin->setValue(editorLinesPerPage);
editorLinesPerPageSpin->setToolTip("Set lines per page to optimize scrolling.");
editorLinesPerPageSpin->setStatusTip(QString("Set the desired buffered lines per page between %1 and %2.").arg(EDITOR_MIN_LINES_DEFAULT).arg(EDITOR_MAX_LINES_DEFAULT));
editorLinesPerPageSpin->setToolTip(tr("Set lines per page between %1 and %2 to optimize scrolling.").arg(EDITOR_MIN_LINES_DEFAULT).arg(EDITOR_MAX_LINES_DEFAULT));
editorBufferedPagingSubform->addRow(editorLinesPerPageLabel, editorLinesPerPageSpin);

// options - selected lines
QGroupBox *editorSelectedItemsGrpBox = new QGroupBox(tr("Selected Items"));
form->addWidget(editorSelectedItemsGrpBox);
QFormLayout *editorSelectedItemsSubform = new QFormLayout(editorSelectedItemsGrpBox);

QCheckBox *editorHighlightLinesBox = new QCheckBox(tr("Highlight Selected Lines"), dialog);
editorHighlightLinesBox->setToolTip(tr("Highlight selected line(s) when clicked in Editor"));
editorHighlightLinesBox->setChecked(editorHighlightLines);
editorSelectedItemsSubform->addRow(editorHighlightLinesBox);

QCheckBox *editorLoadSelectionStepBox = new QCheckBox(tr("Load Selection Step in 3DViewer"), dialog);
editorLoadSelectionStepBox->setToolTip(tr("Load the first step (on multi-line select) of selected lines in the 3DViewer"));
editorLoadSelectionStepBox->setChecked(editorLoadSelectionStep);
editorSelectedItemsSubform->addRow(editorLoadSelectionStepBox);

// options - button box
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, dialog);
Expand All @@ -1533,6 +1558,18 @@ void EditWindow::preferences()
Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorLinesPerPage"),Preferences::editorLinesPerPage);
emit lpubAlert->messageSig(LOG_INFO,QString("Buffered lines par page changed from %1 to %2").arg(editorLinesPerPage).arg(Preferences::editorLinesPerPage));
}

Preferences::editorHighlightLines = editorHighlightLinesBox->isChecked();
if (editorHighlightLines != Preferences::editorHighlightLines) {
Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorHighlightLines"),Preferences::editorHighlightLines);
emit lpubAlert->messageSig(LOG_INFO,QString("Highlight selected lines changed from %1 to %2").arg(editorHighlightLines).arg(Preferences::editorLinesPerPage));
}

Preferences::editorLoadSelectionStep = editorLoadSelectionStepBox->isChecked();
if (editorLoadSelectionStep != Preferences::editorLoadSelectionStep) {
Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorLoadSelectionStep"),Preferences::editorLoadSelectionStep);
emit lpubAlert->messageSig(LOG_INFO,QString("Load selection step in 3DViewer changed from %1 to %2").arg(editorLoadSelectionStep).arg(Preferences::editorLoadSelectionStep));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion mainApp/excludedparts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ExcludedParts::ExcludedParts()
if (excludedParts.size() == 0) {
bool rxFound = false;
QString excludedPartsFile = Preferences::excludedPartsFile;
QRegExp rx("^(\\b.*\[^\\s]\\b)(?:\\s)\\s+(.*)$");
QRegExp rx("^(\\b.*[^\\s]\\b)(?:\\s)\\s+(.*)$");
if (!excludedPartsFile.isEmpty()) {
QFile file(excludedPartsFile);
if ( ! file.open(QFile::ReadOnly | QFile::Text)) {
Expand Down
34 changes: 20 additions & 14 deletions mainApp/lpub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ void Gui::updateClipboard()
void Gui::displayPage()
{
emit messageSig(LOG_STATUS, "Processing page display...");
pageProcessRunning = PROC_DISPLAY_PAGE;
timer.start();
if (macroNesting == 0) {
bool updateViewer = currentStep ? currentStep->updateViewer : true;
Expand All @@ -405,6 +406,7 @@ void Gui::displayPage()
if (! ContinuousPage())
emit messageSig(LOG_STATUS,QString("Page loaded%1.")
.arg(Preferences::modeGUI ? QString(". %1").arg(gui->elapsedTime(timer.elapsed())) : ""));
pageProcessRunning = PROC_NONE;
}

void Gui::nextPage()
Expand Down Expand Up @@ -1247,18 +1249,21 @@ void Gui::displayFile(
int stepNumber = 1;
Where top(modelName,0);
Where bottom(modelName,0);
if (getCurrentStep()) {
top = getCurrentStep()->topOfStep();
bottom = getCurrentStep()->bottomOfStep();
stepNumber = getCurrentStep()->stepNumber.number;
}
if (!bottom.lineNumber) {
bool partsAdded = false;
while (!partsAdded)
mi->scanForward(bottom, StepMask|StepGroupMask, partsAdded);
if (!pageProcessRunning && !exporting()) {
if (getCurrentStep()) {
top = getCurrentStep()->topOfStep();
bottom = getCurrentStep()->bottomOfStep();
stepNumber = getCurrentStep()->stepNumber.number;
}
if (!bottom.lineNumber) {
Rc rc = OkRc;
bool partsAdded = false;
while (!partsAdded && rc != EndOfFileRc)
rc = mi->scanForward(bottom, StepMask|StepGroupEndMask, partsAdded);
}
}
StepLines lineScope(top.lineNumber, bottom.lineNumber);
displayFileSig(ldrawFile, modelName, lineScope);
const StepLines lineScope(top.lineNumber, bottom.lineNumber);
displayFileSig(ldrawFile, modelName, lineScope);
#ifdef QT_DEBUG_MODE
emit messageSig(LOG_DEBUG,tr("Editor loaded step %1, lines %2-%3 - %4")
.arg(stepNumber)
Expand Down Expand Up @@ -2984,7 +2989,8 @@ Gui::Gui()
displayPageNum = 1;
numPrograms = 0;

processOption = EXPORT_ALL_PAGES;
pageProcessRunning = PROC_NONE; // display page process
processOption = EXPORT_ALL_PAGES; // export process
exportMode = EXPORT_PDF;
pageRangeText = "1";
exportPixelRatio = 1.0;
Expand All @@ -2998,7 +3004,7 @@ Gui::Gui()
previousPageContinuousIsRunning = false;

mBuildModRange = { 0, 0, -1 };
mStepRotation = {0.0f, 0.0f, 0.0f};
mStepRotation = { 0.0f, 0.0f, 0.0f };
mRotStepAngleX = 0.0f;
mRotStepAngleY = 0.0f;
mRotStepAngleZ = 0.0f;
Expand Down Expand Up @@ -5537,7 +5543,7 @@ void Gui::parseError(const QString message, const Where &here, Preferences::MsgK
Preferences::MsgID msgID(msgKey,messageLine.indexToString());
Preferences::showMessage(msgID, parseMessage, keyType[msgKey][0], keyType[msgKey][1], option, override);
}
if (writingToTmp)
if (pageProcessRunning == PROC_WRITE_TO_TMP)
emit progressPermMessageSig(QString("Writing submodel [Parse Error%1")
.arg(okToShowMessage ? "]... " : " - see log]... " ));
}
Expand Down
2 changes: 1 addition & 1 deletion mainApp/lpub.h
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ public slots:

int numPrograms;

bool writingToTmp;
int pageProcessRunning; // indicate page processing stage - 0=none, 1=writeToTmp,2-find/drawPage...,

bool okToInvokeProgressBar()
{
Expand Down
18 changes: 18 additions & 0 deletions mainApp/lpub_preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ bool Preferences::defaultBlendFile = false;
bool Preferences::useSystemEditor = false;
bool Preferences::buildModEnabled = true;
bool Preferences::editorBufferedPaging = true;
bool Preferences::editorHighlightLines = true;
bool Preferences::editorLoadSelectionStep = true;

#ifdef Q_OS_MAC
bool Preferences::missingRendererLibs = false;
Expand Down Expand Up @@ -2886,6 +2888,22 @@ void Preferences::editorPreferences()
} else {
editorDecoration = Settings.value(QString("%1/%2").arg(SETTINGS,"EditorDecoration")).toInt();
}

// Highlight selected lines when clicked in Editor
if ( ! Settings.contains(QString("%1/%2").arg(SETTINGS,"EditorHighlightLines"))) {
QVariant uValue(editorHighlightLines);
Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorHighlightLines"),uValue);
} else {
editorHighlightLines = Settings.value(QString("%1/%2").arg(SETTINGS,"EditorHighlightLines")).toBool();
}

// Load the first step (on multi-line select) of selected lines in the 3DViewer
if ( ! Settings.contains(QString("%1/%2").arg(SETTINGS,"EditorLoadSelectionStep"))) {
QVariant uValue(editorLoadSelectionStep);
Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorLoadSelectionStep"),uValue);
} else {
editorLoadSelectionStep = Settings.value(QString("%1/%2").arg(SETTINGS,"EditorLoadSelectionStep")).toBool();
}
}

void Preferences::userInterfacePreferences()
Expand Down
2 changes: 2 additions & 0 deletions mainApp/lpub_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ class Preferences
static bool debugLogging;
static bool useSystemEditor;
static bool editorBufferedPaging;
static bool editorHighlightLines;
static bool editorLoadSelectionStep;

#ifdef Q_OS_MAC
static bool missingRendererLibs;
Expand Down
1 change: 1 addition & 0 deletions mainApp/name.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ enum Theme { ThemeDark, ThemeDefault };
enum SaveOnSender { SaveOnNone, SaveOnRedraw, SaveOnUpdate };
enum NativeType { NTypeDefault, NTypeCalledOut, NTypeMultiStep };
enum ShowLineType { LINE_HIGHLIGHT, LINE_ERROR };
enum ProcessType { PROC_NONE, PROC_WRITE_TO_TMP, PROC_DISPLAY_PAGE };
enum SceneObjectInfo { ObjectId };


Expand Down
13 changes: 5 additions & 8 deletions mainApp/nativeviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3315,21 +3315,18 @@ void Gui::setCurrentStep(Step *step)

void Gui::setStepForLine(const TypeLine &here)
{
if (!currentStep || (!currentStep->multiStep && !currentStep->calledOut))
if (!currentStep || !gMainWindow->isVisible() || exporting())
return;

const Where top = currentStep->multiStep ? currentStep->topOfSteps() : currentStep->topOfCallout();
const Where bottom = currentStep->multiStep ? currentStep->bottomOfSteps() : currentStep->bottomOfCallout();
QString stepKey = getViewerStepKeyFromRange(Where(here.modelIndex, here.lineIndex), top, bottom);
const QString stepKey = getViewerStepKeyFromRange(Where(here.modelIndex, here.lineIndex), topOfPage(), bottomOfPage());

if (!stepKey.isEmpty()) {
if (!currentStep->viewerStepKey.startsWith(&stepKey)) {
setCurrentStep(stepKey);
showLine(getCurrentStep()->topOfStep());
enableBuildModActions();
if (gMainWindow->isVisible()) {
getCurrentStep()->viewerOptions->ZoomExtents = true;
getCurrentStep()->loadTheViewer();
}
getCurrentStep()->viewerOptions->ZoomExtents = true;
getCurrentStep()->loadTheViewer();
}
}
}
Expand Down
Loading

0 comments on commit e98c873

Please sign in to comment.