Instructions Dialog mockup.

This commit is contained in:
Leonardo Zide 2020-05-31 18:46:36 -07:00
parent a23921826d
commit 44fa79ecb6
12 changed files with 144 additions and 15 deletions

1
.gitignore vendored
View file

@ -20,6 +20,7 @@
*.dae *.dae
*.3ds *.3ds
*.obj *.obj
.vs
build build
debug debug
release release

View file

@ -115,6 +115,13 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
QT_TRANSLATE_NOOP("Status", "Render the current model using POV-Ray"), QT_TRANSLATE_NOOP("Status", "Render the current model using POV-Ray"),
"" ""
}, },
// LC_FILE_INSTRUCTIONS
{
QT_TRANSLATE_NOOP("Action", "File.Instructions"),
QT_TRANSLATE_NOOP("Menu", "&Instructions..."),
QT_TRANSLATE_NOOP("Status", "Configure instructions layout"),
""
},
// LC_FILE_PRINT // LC_FILE_PRINT
{ {
QT_TRANSLATE_NOOP("Action", "File.Print"), QT_TRANSLATE_NOOP("Action", "File.Print"),

View file

@ -18,6 +18,7 @@ enum lcCommandId
LC_FILE_EXPORT_POVRAY, LC_FILE_EXPORT_POVRAY,
LC_FILE_EXPORT_WAVEFRONT, LC_FILE_EXPORT_WAVEFRONT,
LC_FILE_RENDER, LC_FILE_RENDER,
LC_FILE_INSTRUCTIONS,
LC_FILE_PRINT, LC_FILE_PRINT,
LC_FILE_PRINT_PREVIEW, LC_FILE_PRINT_PREVIEW,
LC_FILE_PRINT_BOM, LC_FILE_PRINT_BOM,

View file

@ -0,0 +1,62 @@
#include "lc_global.h"
#include "lc_instructionsdialog.h"
#include "project.h"
#include "lc_model.h"
lcInstructionsPageWidget::lcInstructionsPageWidget(QWidget* Parent, Project* Project)
: QGraphicsView(Parent)
{
}
void lcInstructionsPageWidget::SetCurrentPage(lcInstructionsPageLayout* PageLayout)
{
QGraphicsScene* Scene = new QGraphicsScene(this);
setScene(Scene);
Scene->setSceneRect(0, 0, 1000, 1000);
// Scene->setBackgroundBrush(Qt::black);
QImage StepImage = PageLayout->Model->GetStepImage(false, 500, 500, PageLayout->Step);
QGraphicsPixmapItem* StepImageItem = Scene->addPixmap(QPixmap::fromImage(StepImage));
StepImageItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
QGraphicsSimpleTextItem* StepNumberItem = Scene->addSimpleText(QString::number(PageLayout->Step), QFont("Helvetica", 96));
StepNumberItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
QImage PartsImage = PageLayout->Model->GetPartsListImage(300, PageLayout->Step);
QGraphicsPixmapItem* PartsImageItem = Scene->addPixmap(QPixmap::fromImage(PartsImage));
PartsImageItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
PartsImageItem->setPos(StepNumberItem->pos() + QPointF(StepNumberItem->sceneBoundingRect().width(), 0));
}
lcInstructionsDialog::lcInstructionsDialog(QWidget* Parent, Project* Project)
: QMainWindow(Parent), mProject(Project)
{
QWidget* CentralWidget = new QWidget(this);
setCentralWidget(CentralWidget);
setWindowTitle(tr("Instructions"));
QVBoxLayout* Layout = new QVBoxLayout(CentralWidget);
QSplitter* Splitter = new QSplitter(CentralWidget);
Splitter->setOrientation(Qt::Horizontal);
Layout->addWidget(Splitter);
mThumbnailsWidget = new QListWidget(Splitter);
Splitter->addWidget(mThumbnailsWidget);
mPageWidget = new lcInstructionsPageWidget(Splitter, mProject);
Splitter->addWidget(mPageWidget);
mPageLayouts = mProject->GetPageLayouts();
for (size_t PageNumber = 0; PageNumber < mPageLayouts.size(); PageNumber++)
mThumbnailsWidget->addItem(QString("Page %1").arg(PageNumber + 1));
connect(mThumbnailsWidget, SIGNAL(currentRowChanged(int)), this, SLOT(CurrentThumbnailChanged(int)));
mThumbnailsWidget->setCurrentRow(0);
}
void lcInstructionsDialog::CurrentThumbnailChanged(int Index)
{
mPageWidget->SetCurrentPage(&mPageLayouts[Index]);
}

View file

@ -0,0 +1,33 @@
#pragma once
struct lcInstructionsPageLayout;
class lcInstructionsPageWidget : public QGraphicsView
{
Q_OBJECT
public:
lcInstructionsPageWidget(QWidget* Parent, Project* Project);
void SetCurrentPage(lcInstructionsPageLayout* PageLayout);
};
class lcInstructionsDialog : public QMainWindow
{
Q_OBJECT
public:
lcInstructionsDialog(QWidget* Parent, Project* Project);
protected slots:
void CurrentThumbnailChanged(int Index);
protected:
Project* mProject;
int mCurrentPageNumber;
std::vector<lcInstructionsPageLayout> mPageLayouts;
QListWidget* mThumbnailsWidget;
lcInstructionsPageWidget* mPageWidget;
};

View file

@ -14,6 +14,7 @@
#include "lc_setsdatabasedialog.h" #include "lc_setsdatabasedialog.h"
#include "lc_qhtmldialog.h" #include "lc_qhtmldialog.h"
#include "lc_renderdialog.h" #include "lc_renderdialog.h"
#include "lc_instructionsdialog.h"
#include "lc_profile.h" #include "lc_profile.h"
#include "view.h" #include "view.h"
#include "project.h" #include "project.h"
@ -480,6 +481,7 @@ void lcMainWindow::CreateMenus()
ExportMenu->addAction(mActions[LC_FILE_EXPORT_WAVEFRONT]); ExportMenu->addAction(mActions[LC_FILE_EXPORT_WAVEFRONT]);
FileMenu->addSeparator(); FileMenu->addSeparator();
FileMenu->addAction(mActions[LC_FILE_RENDER]); FileMenu->addAction(mActions[LC_FILE_RENDER]);
FileMenu->addAction(mActions[LC_FILE_INSTRUCTIONS]);
FileMenu->addAction(mActions[LC_FILE_PRINT]); FileMenu->addAction(mActions[LC_FILE_PRINT]);
FileMenu->addAction(mActions[LC_FILE_PRINT_PREVIEW]); FileMenu->addAction(mActions[LC_FILE_PRINT_PREVIEW]);
// FileMenu->addAction(mActions[LC_FILE_PRINT_BOM]); // FileMenu->addAction(mActions[LC_FILE_PRINT_BOM]);
@ -1037,7 +1039,7 @@ void lcMainWindow::Print(QPrinter* Printer)
int DocCopies; int DocCopies;
int PageCopies; int PageCopies;
std::vector<std::pair<lcModel*, lcStep>> PageLayouts = lcGetActiveProject()->GetPageLayouts(); std::vector<lcInstructionsPageLayout> PageLayouts = lcGetActiveProject()->GetPageLayouts();
const int PageCount = static_cast<int>(PageLayouts.size()); const int PageCount = static_cast<int>(PageLayouts.size());
if (Printer->collateCopies()) if (Printer->collateCopies())
@ -1107,8 +1109,8 @@ void lcMainWindow::Print(QPrinter* Printer)
int StepWidth = MarginRect.width(); int StepWidth = MarginRect.width();
int StepHeight = MarginRect.height(); int StepHeight = MarginRect.height();
lcModel* Model = PageLayouts[Page - 1].first; lcModel* Model = PageLayouts[Page - 1].Model;
lcStep Step = PageLayouts[Page - 1].second; lcStep Step = PageLayouts[Page - 1].Step;
QImage Image = Model->GetStepImage(false, StepWidth, StepHeight, Step); QImage Image = Model->GetStepImage(false, StepWidth, StepHeight, Step);
Painter.drawImage(MarginRect.left(), MarginRect.top(), Image); Painter.drawImage(MarginRect.left(), MarginRect.top(), Image);
@ -1201,6 +1203,14 @@ void lcMainWindow::ShowRenderDialog()
Dialog.exec(); Dialog.exec();
} }
void lcMainWindow::ShowInstructionsDialog()
{
lcInstructionsDialog* Dialog = new lcInstructionsDialog(this, lcGetActiveProject());
Dialog->setWindowModality(Qt::ApplicationModal);
Dialog->setAttribute(Qt::WA_DeleteOnClose);
Dialog->show();
}
void lcMainWindow::ShowPrintDialog() void lcMainWindow::ShowPrintDialog()
{ {
#ifndef QT_NO_PRINTER #ifndef QT_NO_PRINTER
@ -2522,6 +2532,10 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
ShowRenderDialog(); ShowRenderDialog();
break; break;
case LC_FILE_INSTRUCTIONS:
ShowInstructionsDialog();
break;
case LC_FILE_PRINT_PREVIEW: case LC_FILE_PRINT_PREVIEW:
TogglePrintPreview(); TogglePrintPreview();
break; break;

View file

@ -379,6 +379,7 @@ protected:
void ShowAboutDialog(); void ShowAboutDialog();
void ShowHTMLDialog(); void ShowHTMLDialog();
void ShowRenderDialog(); void ShowRenderDialog();
void ShowInstructionsDialog();
void ShowPrintDialog(); void ShowPrintDialog();
bool OpenProjectFile(const QString& FileName); bool OpenProjectFile(const QString& FileName);

View file

@ -1695,9 +1695,9 @@ void lcModel::SaveStepImages(const QString& BaseName, bool AddStepSuffix, bool Z
} }
} }
std::vector<std::pair<lcModel*, lcStep>> lcModel::GetPageLayouts(std::vector<const lcModel*>& AddedModels) std::vector<lcInstructionsPageLayout> lcModel::GetPageLayouts(std::vector<const lcModel*>& AddedModels)
{ {
std::vector<std::pair<lcModel*, lcStep>> PageLayouts; std::vector<lcInstructionsPageLayout> PageLayouts;
if (std::find(AddedModels.begin(), AddedModels.end(), this) != AddedModels.end()) if (std::find(AddedModels.begin(), AddedModels.end(), this) != AddedModels.end())
return PageLayouts; return PageLayouts;
@ -1716,7 +1716,7 @@ std::vector<std::pair<lcModel*, lcStep>> lcModel::GetPageLayouts(std::vector<con
{ {
while (StepIt.first > CurrentStep) while (StepIt.first > CurrentStep)
{ {
PageLayouts.emplace_back(std::make_pair(this, CurrentStep)); PageLayouts.emplace_back(lcInstructionsPageLayout{ this, CurrentStep });
CurrentStep++; CurrentStep++;
} }
@ -1725,12 +1725,12 @@ std::vector<std::pair<lcModel*, lcStep>> lcModel::GetPageLayouts(std::vector<con
if (Piece->mPieceInfo->IsModel()) if (Piece->mPieceInfo->IsModel())
{ {
lcModel* SubModel = Piece->mPieceInfo->GetModel(); lcModel* SubModel = Piece->mPieceInfo->GetModel();
std::vector<std::pair<lcModel*, lcStep>> SubModelLayouts = SubModel->GetPageLayouts(AddedModels); std::vector<lcInstructionsPageLayout> SubModelLayouts = SubModel->GetPageLayouts(AddedModels);
PageLayouts.insert(PageLayouts.end(), std::make_move_iterator(SubModelLayouts.begin()), std::make_move_iterator(SubModelLayouts.end())); PageLayouts.insert(PageLayouts.end(), std::make_move_iterator(SubModelLayouts.begin()), std::make_move_iterator(SubModelLayouts.end()));
} }
} }
PageLayouts.emplace_back(std::make_pair(this, CurrentStep)); PageLayouts.emplace_back(lcInstructionsPageLayout{ this, CurrentStep });
CurrentStep++; CurrentStep++;
} }

View file

@ -20,6 +20,12 @@
class lcGLWidget; class lcGLWidget;
struct lcInstructionsPageLayout
{
lcModel* Model;
lcStep Step;
};
enum class lcSelectionMode enum class lcSelectionMode
{ {
Single, Single,
@ -242,7 +248,7 @@ public:
QImage GetStepImage(bool Zoom, int Width, int Height, lcStep Step); QImage GetStepImage(bool Zoom, int Width, int Height, lcStep Step);
QImage GetPartsListImage(int MaxWidth, lcStep Step) const; QImage GetPartsListImage(int MaxWidth, lcStep Step) const;
void SaveStepImages(const QString& BaseName, bool AddStepSuffix, bool Zoom, int Width, int Height, lcStep Start, lcStep End); void SaveStepImages(const QString& BaseName, bool AddStepSuffix, bool Zoom, int Width, int Height, lcStep Start, lcStep End);
std::vector<std::pair<lcModel*, lcStep>> GetPageLayouts(std::vector<const lcModel*>& AddedModels); std::vector<lcInstructionsPageLayout> GetPageLayouts(std::vector<const lcModel*>& AddedModels);
void RayTest(lcObjectRayTest& ObjectRayTest) const; void RayTest(lcObjectRayTest& ObjectRayTest) const;
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const; void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;

View file

@ -1473,14 +1473,14 @@ void Project::ExportCSV()
} }
} }
std::vector<std::pair<lcModel*, lcStep>> Project::GetPageLayouts() const std::vector<lcInstructionsPageLayout> Project::GetPageLayouts() const
{ {
std::vector<const lcModel*> AddedModels; std::vector<const lcModel*> AddedModels;
if (mActiveModel) if (!mModels.IsEmpty())
return mActiveModel->GetPageLayouts(AddedModels); return mModels[0]->GetPageLayouts(AddedModels);
return std::vector<std::pair<lcModel*, lcStep>>(); return std::vector<lcInstructionsPageLayout>();
} }
void Project::ExportHTML(const lcHTMLExportOptions& Options) void Project::ExportHTML(const lcHTMLExportOptions& Options)

View file

@ -36,6 +36,8 @@ enum LC_MOUSE_TRACK
LC_TRACK_RIGHT LC_TRACK_RIGHT
}; };
struct lcInstructionsPageLayout;
class Project class Project
{ {
public: public:
@ -80,7 +82,7 @@ public:
QString GetImageFileName(bool AllowCurrentFolder) const; QString GetImageFileName(bool AllowCurrentFolder) const;
std::vector<std::pair<lcModel*, lcStep>> GetPageLayouts() const; std::vector<lcInstructionsPageLayout> GetPageLayouts() const;
void SetActiveModel(int ModelIndex); void SetActiveModel(int ModelIndex);
void SetActiveModel(const QString& FileName); void SetActiveModel(const QString& FileName);

View file

@ -166,6 +166,7 @@ macx {
} }
SOURCES += common/view.cpp \ SOURCES += common/view.cpp \
common/lc_instructionsdialog.cpp \
common/texfont.cpp \ common/texfont.cpp \
common/project.cpp \ common/project.cpp \
common/pieceinf.cpp \ common/pieceinf.cpp \
@ -226,6 +227,7 @@ SOURCES += common/view.cpp \
qt/lc_setsdatabasedialog.cpp \ qt/lc_setsdatabasedialog.cpp \
common/lc_partpalettedialog.cpp common/lc_partpalettedialog.cpp
HEADERS += \ HEADERS += \
common/lc_instructionsdialog.h \
common/view.h \ common/view.h \
common/texfont.h \ common/texfont.h \
common/project.h \ common/project.h \