export xsheet PDF

This commit is contained in:
shun-iwasawa 2021-08-16 08:19:37 +09:00 committed by manongjohn
parent 9dbac90477
commit e5e01cdeaa
10 changed files with 2643 additions and 0 deletions

View file

@ -0,0 +1,47 @@
[XSheetPDFTemplate]
Label="A3 size, 6 seconds sheet"
PageSize=A3
Margin="9.0,5.0,6.0,11.0"
Number\BodyAmount=2
Number\KeyColAmount=7
Number\CellsColAmount=8
Number\CameraColAmount=3
Number\FrameLength=144
Number\MemoLinesAmount=8
Number\ExtraCellsColAmount=3
Number\DrawCameraGrid=1
Length\BodyWidth=137.5
Length\BodyHeight=315.5
Length\BodyHMargin=7.0
Length\BodyTop=91.0
Length\HeaderHeight=6.5
Length\KeyColWidth=4.5
Length\LastKeyColWidth=7
Length\DialogColWidth=11
Length\CellsColWidth=8
Length\CameraColWidth=8
Length\RowHeight=4.25
Length\1SecHeight=103
Length\InfoOriginLeft=56
Length\InfoOriginTop=0
Length\InfoTitleHeight=4.5
Length\InfoBodyHeight=12.5
InfoFormats\1\width=36
InfoFormats\1\label=EPISODE
InfoFormats\2\width=30
InfoFormats\2\label=SEQ.
InfoFormats\3\width=38
InfoFormats\3\label=SCENE
InfoFormats\3\infoType=Scene
InfoFormats\4\width=55
InfoFormats\4\label=TIME
InfoFormats\4\infoType=Time
InfoFormats\5\width=32
InfoFormats\5\label=NAME
InfoFormats\6\width=35
InfoFormats\6\label=SHEET
InfoFormats\6\infoType=SheetInv
InfoFormats\size=6
DataFields\Memo="0,23,282,65"
DataFields\DateTimeAndScenePath="0,23,282,65"
DataFields\Logo="0,0,51,17"

View file

@ -0,0 +1,47 @@
[XSheetPDFTemplate]
Label="B4 size, 3 seconds sheet"
PageSize=JisB4
Margin="7.5,6.0,7.5,6.0"
Number\BodyAmount=1
Number\KeyColAmount=14
Number\CellsColAmount=14
Number\CameraColAmount=1
Number\FrameLength=72
Number\MemoLinesAmount=3
Number\ExtraCellsColAmount=0
Number\DrawCameraGrid=1
Length\BodyWidth=242
Length\BodyHeight=317.5
Length\BodyHMargin=0
Length\BodyTop=34.5
Length\HeaderHeight=8.5
Length\KeyColWidth=5
Length\LastKeyColWidth=6.5
Length\DialogColWidth=11.5
Length\CellsColWidth=8.25
Length\CameraColWidth=38.5
Length\RowHeight=4.2625
Length\1SecHeight=103
Length\InfoOriginLeft=87
Length\InfoOriginTop=0
Length\InfoTitleHeight=4.5
Length\InfoBodyHeight=8.5
InfoFormats\1\width=26.5
InfoFormats\1\label=EPISODE
InfoFormats\2\width=18
InfoFormats\2\label=SEQ.
InfoFormats\3\width=18.5
InfoFormats\3\label=SCENE
InfoFormats\3\infoType=Scene
InfoFormats\4\width=40
InfoFormats\4\label=TIME
InfoFormats\4\infoType=Time
InfoFormats\5\width=26
InfoFormats\5\label=NAME
InfoFormats\6\width=26
InfoFormats\6\label=SHEET
InfoFormats\6\infoType=SheetInv
InfoFormats\size=6
DataFields\Memo="0,14,242,18.5"
DataFields\DateTimeAndScenePath="0,14,242,18.5"
DataFields\Logo="0,0,87,13"

View file

@ -0,0 +1,46 @@
[XSheetPDFTemplate]
Label="B4 size, 6 seconds sheet"
PageSize=JisB4
Margin="9.5,6.0,8.5,6.0"
Number\BodyAmount=2
Number\KeyColAmount=4
Number\CellsColAmount=5
Number\CameraColAmount=3
Number\FrameLength=144
Number\MemoLinesAmount=3
Number\ExtraCellsColAmount=3
Length\BodyWidth=117
Length\BodyHeight=315.5
Length\BodyHMargin=5
Length\BodyTop=36.5
Length\HeaderHeight=6.5
Length\KeyColWidth=5
Length\LastKeyColWidth=7
Length\DialogColWidth=10
Length\CellsColWidth=10
Length\CameraColWidth=10
Length\RowHeight=4.25
Length\1SecHeight=103
Length\InfoOriginLeft=84
Length\InfoOriginTop=0
Length\InfoTitleHeight=4.5
Length\InfoBodyHeight=8.5
InfoFormats\1\width=26
InfoFormats\1\label=EPISODE
InfoFormats\2\width=18.5
InfoFormats\2\label=SEQ.
InfoFormats\3\width=18.5
InfoFormats\3\label=SCENE
InfoFormats\3\infoType=Scene
InfoFormats\4\width=40
InfoFormats\4\label=TIME
InfoFormats\4\infoType=Time
InfoFormats\5\width=26
InfoFormats\5\label=NAME
InfoFormats\6\width=26
InfoFormats\6\label=SHEET
InfoFormats\6\infoType=Sheet
InfoFormats\size=6
DataFields\Memo="0,14,239,20.5"
DataFields\DateTimeAndScenePath="0,14,239,20.5"
DataFields\Logo="0,0,84,13"

View file

@ -176,6 +176,8 @@ the tree or
void setName(const std::string &name);
std::string getName() const;
bool hasSpecifiedName() const { return m_name != ""; }
//! Returns the id's full name, ie the name of the object with its id
//! appended.
std::string getFullName() const;

View file

@ -122,6 +122,7 @@ set(MOC_HEADERS
xdtsimportpopup.h
expressionreferencemanager.h
tooloptionsshortcutinvoker.h
exportxsheetpdf.h
motionpathpanel.h
graphwidget.h
../stopmotion/stopmotion.h
@ -352,6 +353,7 @@ set(SOURCES
expressionreferencemanager.cpp
tooloptionsshortcutinvoker.cpp
tvpjson_io.cpp
exportxsheetpdf.cpp
# Tracker file
dummyprocessor.cpp
metnum.cpp

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,280 @@
#pragma once
#ifndef EXPORTXSHEETPDF_H
#define EXPORTXSHEETPDF_H
#include "toonzqt/dvdialog.h"
#include "toonz/txshcell.h"
#include <QMarginsF>
#include <QSize>
#include <QPoint>
#include <QPainter>
#include <QList>
#include <QPageSize>
#include <QPdfWriter>
#include <QScrollArea>
#include <QPair>
// forward declaration
class QComboBox;
class QCheckBox;
class TXshLevelColumn;
class TXshSoundColumn;
namespace DVGui {
class FileField;
class ColorField;
} // namespace DVGui
class XSheetPDFTemplate;
class QFontComboBox;
class QTextEdit;
class QRadioButton;
class QLineEdit;
class QIntValidator;
// シートに記載する情報
enum XSheetPDFDataType {
Data_Memo = 0,
Data_Second,
Data_Frame,
Data_TotalPages,
Data_CurrentPage,
Data_DateTimeAndScenePath,
Data_SceneName,
Data_Logo,
Data_Invalid
};
typedef void(*DecoFunc)(QPainter&, QRect, QMap<XSheetPDFDataType, QRect>&);
enum ExportArea { Area_Actions = 0, Area_Cells };
struct XSheetPDFFormatInfo {
QColor lineColor;
QString dateTimeText;
QString scenePathText;
QString sceneNameText;
ExportArea exportArea;
QString templateFontFamily;
QString contentsFontFamily;
QString memoText;
QString logoText;
QPixmap logoPixmap;
bool drawSound;
bool serialFrameNumber;
bool drawLevelNameOnBottom;
};
class XSheetPDFTemplate {
protected:
struct XSheetPDF_InfoFormat {
int width;
QString label;
DecoFunc decoFunc = nullptr;
};
struct XSheetPDFTemplateParams {
QPageSize::PageSizeId documentPageSize;
QMarginsF documentMargin;
QList<XSheetPDF_InfoFormat> array_Infos;
int bodylabelTextSize_Large;
int bodylabelTextSize_Small;
int keyBlockWidth;
int cellsBlockWidth;
int cameraBlockWidth;
int infoHeaderHeight;
} m_p;
QMap<QString, int> m_params;
QPen thinPen, thickPen;
XSheetPDFFormatInfo m_info;
QList<QList<QRect>> m_colLabelRects;
QList<QList<QRect>> m_colLabelRects_bottom;
QList<QList<QRect>> m_cellRects;
QList<QRect> m_soundCellRects;
QMap<XSheetPDFDataType, QRect> m_dataRects;
// column and column name (if manually specified)
QList<QPair<TXshLevelColumn*, QString>> m_columns;
QList<TXshSoundColumn*> m_soundColumns;
int m_duration;
bool m_useExtraColumns;
void adjustSpacing(QPainter& painter, const int width, const QString& label,
const double ratio = 0.8);
void drawGrid(QPainter& painter, int colAmount, int colWidth, int blockWidth);
void registerColLabelRects(QPainter& painter, int colAmount, int colWidth,
int bodyId);
void registerCellRects(QPainter& painter, int colAmount, int colWidth,
int bodyId);
void registerSoundRects(QPainter& painter, int colWidth, int bodyId);
// Key Block
void drawKeyBlock(QPainter& painter, int framePage, const int bodyId);
void drawDialogBlock(QPainter& painter, const int framePage,
const int bodyId);
void drawCellsBlock(QPainter& painter, int bodyId);
void drawCameraBlock(QPainter& painter);
void drawXsheetBody(QPainter& painter, int framePage, int bodyId);
void drawInfoHeader(QPainter& painter);
void addInfo(int w, QString lbl, DecoFunc f = nullptr);
void drawContinuousLine(QPainter& painter, QRect rect, bool isEmpty);
void drawCellNumber(QPainter& painter, QRect rect, TXshCell& cell);
void drawEndMark(QPainter& painter, QRect upperRect);
void drawLevelName(QPainter& painter, QRect rect, QString name,
bool isBottom = false);
void drawLogo(QPainter& painter);
void drawSound(QPainter& painter, int framePage);
int param(const QString& id, int defaultValue = 0) {
if (!m_params.contains(id)) std::cout << id.toStdString() << std::endl;
return m_params.value(id, defaultValue);
}
public:
XSheetPDFTemplate(const QList<QPair<TXshLevelColumn*, QString>>& columns,
const int duration);
void drawXsheetTemplate(QPainter& painter, int framePage,
bool isPreview = false);
void drawXsheetContents(QPainter& painter, int framePage, int prallelPage,
bool isPreview = false);
void initializePage(QPdfWriter& writer);
QPixmap initializePreview();
int framePageCount();
int parallelPageCount();
int columnsInPage();
QSize logoPixelSize();
void setLogoPixmap(QPixmap pm);
void setSoundColumns(const QList<TXshSoundColumn*>& soundColumns) {
m_soundColumns = soundColumns;
}
void setInfo(const XSheetPDFFormatInfo& info);
};
class XSheetPDFTemplate_B4_6sec : public XSheetPDFTemplate {
public:
XSheetPDFTemplate_B4_6sec(
const QList<QPair<TXshLevelColumn*, QString>>& columns,
const int duration);
};
class XSheetPDFTemplate_Custom : public XSheetPDFTemplate {
bool m_valid;
public:
XSheetPDFTemplate_Custom(
const QString& fp, const QList<QPair<TXshLevelColumn*, QString>>& columns,
const int duration);
bool isValid() { return m_valid; }
};
//-----------------------------------------------------------------------------
class XsheetPdfPreviewPane final : public QWidget {
Q_OBJECT
QPixmap m_pixmap;
double m_scaleFactor;
protected:
void paintEvent(QPaintEvent* event) override;
public:
XsheetPdfPreviewPane(QWidget* parent);
void setPixmap(QPixmap pm);
void doZoom(double d_scale);
void fitScaleTo(QSize size);
};
class XsheetPdfPreviewArea final : public QScrollArea {
Q_OBJECT
QPoint m_mousePos;
protected:
void mousePressEvent(QMouseEvent* e) override;
void mouseMoveEvent(QMouseEvent* e) override;
void contextMenuEvent(QContextMenuEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
public:
XsheetPdfPreviewArea(QWidget* parent) : QScrollArea(parent) {}
protected slots:
void fitToWindow();
};
//-----------------------------------------------------------------------------
class ExportXsheetPdfPopup final : public DVGui::Dialog {
Q_OBJECT
XsheetPdfPreviewPane* m_previewPane;
XsheetPdfPreviewArea* m_previewArea;
DVGui::FileField* m_pathFld;
QLineEdit* m_fileNameFld;
QComboBox *m_templateCombo, *m_exportAreaCombo;
DVGui::ColorField* m_lineColorFld;
QCheckBox *m_addDateTimeCB, *m_addScenePathCB, *m_drawSoundCB,
*m_addSceneNameCB, *m_serialFrameNumberCB, *m_levelNameOnBottomCB;
QFontComboBox *m_templateFontCB, *m_contentsFontCB;
QTextEdit* m_memoEdit;
QLabel* m_pageInfoLbl;
QRadioButton *m_logoTxtRB, *m_logoImgRB;
QLineEdit *m_logoTextEdit, *m_sceneNameEdit;
DVGui::FileField* m_logoImgPathField;
QLineEdit* m_currentPageEdit;
int m_totalPageCount;
QPushButton *m_prev, *m_next;
// column and column name (if manually specified)
QList<QPair<TXshLevelColumn*, QString>> m_columns;
QList<TXshSoundColumn*> m_soundColumns;
int m_duration;
XSheetPDFTemplate* m_currentTmpl;
// enum XSheetTemplateId { XSheetTemplate_B4_6sec = 0, XSheetTemplate_B4_3sec
// };
void initialize();
void saveSettings();
void loadSettings();
void onExportFinished(const TFilePath&);
void loadPresetItems();
protected:
void showEvent(QShowEvent* event) override { initialize(); }
void closeEvent(QCloseEvent* event) override { saveSettings(); }
public:
ExportXsheetPdfPopup();
~ExportXsheetPdfPopup();
protected slots:
void onExport();
void onExportPNG();
void initTemplate();
void setInfo();
void updatePreview();
void onLogoModeToggled();
void onLogoImgPathChanged();
void onPrev();
void onNext();
};
#endif

View file

@ -1784,6 +1784,10 @@ void MainWindow::defineActions() {
"shortcuts", tr("Change the shortcuts of Tahoma2D."));
createMenuFileAction(MI_PrintXsheet, QT_TR_NOOP("&Print Xsheet"), "",
"printer", tr("Print the scene's exposure sheet."));
createMenuFileAction(MI_ExportXsheetPDF, QT_TR_NOOP("&Export Xsheet to PDF"),
"");
createMenuFileAction(
MI_ExportXDTS,
QT_TRANSLATE_NOOP("MainWindow",

View file

@ -344,6 +344,7 @@ void TopBar::loadMenubar() {
addMenuItem(exportMenu, MI_ExportCurrentScene);
addMenuItem(exportMenu, MI_SoundTrack);
addMenuItem(exportMenu, MI_ExportXDTS);
addMenuItem(exportMenu, MI_ExportXsheetPDF);
addMenuItem(exportMenu, MI_StopMotionExportImageSequence);
addMenuItem(exportMenu, MI_ExportTvpJson);
}

View file

@ -469,6 +469,7 @@
#define MI_ExportXDTS "MI_ExportXDTS"
#define MI_ExportTvpJson "MI_ExportTvpJson"
#define MI_ExportXsheetPDF "MI_ExportXsheetPDF"
#define MI_ToggleAutoCreate "MI_ToggleAutoCreate"
#define MI_ToggleCreationInHoldCells "MI_ToggleCreationInHoldCells"