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
*.3ds
*.obj
.vs
build
debug
release

View file

@ -115,6 +115,13 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
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
{
QT_TRANSLATE_NOOP("Action", "File.Print"),

View file

@ -18,6 +18,7 @@ enum lcCommandId
LC_FILE_EXPORT_POVRAY,
LC_FILE_EXPORT_WAVEFRONT,
LC_FILE_RENDER,
LC_FILE_INSTRUCTIONS,
LC_FILE_PRINT,
LC_FILE_PRINT_PREVIEW,
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_qhtmldialog.h"
#include "lc_renderdialog.h"
#include "lc_instructionsdialog.h"
#include "lc_profile.h"
#include "view.h"
#include "project.h"
@ -480,6 +481,7 @@ void lcMainWindow::CreateMenus()
ExportMenu->addAction(mActions[LC_FILE_EXPORT_WAVEFRONT]);
FileMenu->addSeparator();
FileMenu->addAction(mActions[LC_FILE_RENDER]);
FileMenu->addAction(mActions[LC_FILE_INSTRUCTIONS]);
FileMenu->addAction(mActions[LC_FILE_PRINT]);
FileMenu->addAction(mActions[LC_FILE_PRINT_PREVIEW]);
// FileMenu->addAction(mActions[LC_FILE_PRINT_BOM]);
@ -1037,7 +1039,7 @@ void lcMainWindow::Print(QPrinter* Printer)
int DocCopies;
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());
if (Printer->collateCopies())
@ -1107,8 +1109,8 @@ void lcMainWindow::Print(QPrinter* Printer)
int StepWidth = MarginRect.width();
int StepHeight = MarginRect.height();
lcModel* Model = PageLayouts[Page - 1].first;
lcStep Step = PageLayouts[Page - 1].second;
lcModel* Model = PageLayouts[Page - 1].Model;
lcStep Step = PageLayouts[Page - 1].Step;
QImage Image = Model->GetStepImage(false, StepWidth, StepHeight, Step);
Painter.drawImage(MarginRect.left(), MarginRect.top(), Image);
@ -1201,6 +1203,14 @@ void lcMainWindow::ShowRenderDialog()
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()
{
#ifndef QT_NO_PRINTER
@ -2522,6 +2532,10 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
ShowRenderDialog();
break;
case LC_FILE_INSTRUCTIONS:
ShowInstructionsDialog();
break;
case LC_FILE_PRINT_PREVIEW:
TogglePrintPreview();
break;

View file

@ -379,6 +379,7 @@ protected:
void ShowAboutDialog();
void ShowHTMLDialog();
void ShowRenderDialog();
void ShowInstructionsDialog();
void ShowPrintDialog();
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())
return PageLayouts;
@ -1716,7 +1716,7 @@ std::vector<std::pair<lcModel*, lcStep>> lcModel::GetPageLayouts(std::vector<con
{
while (StepIt.first > CurrentStep)
{
PageLayouts.emplace_back(std::make_pair(this, CurrentStep));
PageLayouts.emplace_back(lcInstructionsPageLayout{ this, CurrentStep });
CurrentStep++;
}
@ -1725,12 +1725,12 @@ std::vector<std::pair<lcModel*, lcStep>> lcModel::GetPageLayouts(std::vector<con
if (Piece->mPieceInfo->IsModel())
{
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.emplace_back(std::make_pair(this, CurrentStep));
PageLayouts.emplace_back(lcInstructionsPageLayout{ this, CurrentStep });
CurrentStep++;
}

View file

@ -20,6 +20,12 @@
class lcGLWidget;
struct lcInstructionsPageLayout
{
lcModel* Model;
lcStep Step;
};
enum class lcSelectionMode
{
Single,
@ -242,7 +248,7 @@ public:
QImage GetStepImage(bool Zoom, int Width, int Height, lcStep Step);
QImage GetPartsListImage(int MaxWidth, lcStep Step) const;
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 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;
if (mActiveModel)
return mActiveModel->GetPageLayouts(AddedModels);
if (!mModels.IsEmpty())
return mModels[0]->GetPageLayouts(AddedModels);
return std::vector<std::pair<lcModel*, lcStep>>();
return std::vector<lcInstructionsPageLayout>();
}
void Project::ExportHTML(const lcHTMLExportOptions& Options)

View file

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

View file

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