Seamly2D
Code documentation
vcmdexport.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vcmdexport.h
4  ** @author Alex Zaharov <alexzkhr@gmail.com>
5  ** @date 25 8, 2015
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Valentine project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2015 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D is free software: you can redistribute it and/or modify
15  ** it under the terms of the GNU General Public License as published by
16  ** the Free Software Foundation, either version 3 of the License, or
17  ** (at your option) any later version.
18  **
19  ** Seamly2D is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  ** GNU General Public License for more details.
23  **
24  ** You should have received a copy of the GNU General Public License
25  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef VCMDEXPORT_H
30 #define VCMDEXPORT_H
31 
32 #include <memory>
33 #include <vector>
34 #include <QTextStream>
35 #include <QCoreApplication>
36 #include <QCommandLineParser>
37 
38 #include "../dialogs/dialoglayoutsettings.h"
39 #include "../vmisc/vsysexits.h"
40 
41 class VCommandLine;
42 typedef std::shared_ptr<VCommandLine> VCommandLinePtr;
44 typedef std::shared_ptr<VLayoutGenerator> VLayoutGeneratorPtr;
45 
46 //@brief: class used to install export command line options and parse their values
47 //QCommandLineParser* object must exists until this object alive
49 {
50 public:
51  virtual ~VCommandLine();
52 
53  //@brief creates object and applies export related options to parser
54 
55  //@brief tests if user enabled test mode from cmd, throws exception if not exactly 1 input VAL file supplied in
56  //case test mode enabled
57  bool IsTestModeEnabled() const;
58 
59  bool IsNoScalingEnabled() const;
60 
61  //@brief tests if user enabled export from cmd, throws exception if not exactly 1 input VAL file supplied in case
62  //export enabled
63  bool IsExportEnabled() const;
64 
65  //@brief returns path to custom measure file or empty string
66  QString OptMeasurePath() const;
67 
68  //@brief returns the base name of layout files or empty string if not set
69  QString OptBaseName() const;
70 
71  //@brief returns the absolute path to output destination directory or path to application's current directory if
72  //not set
73  QString OptDestinationPath() const;
74 
75  //@brief returns export type set, defaults 0 - svg
76  int OptExportType() const;
77 
78  int IsBinaryDXF() const;
79  int isTextAsPaths() const;
80  int exportOnlyPieces() const;
81 
82  //generator creation is moved here ... because most options are for it only, so no need to create extra getters...
83  //@brief creates VLayoutGenerator
85 
86  //@brief gets filenames which should be loaded
87  QStringList OptInputFileNames() const;
88 
89  bool IsGuiEnabled()const;
90 
91  bool IsSetGradationSize() const;
92  bool IsSetGradationHeight() const;
93 
94  QString OptGradationSize() const;
95  QString OptGradationHeight() const;
96 
97 protected:
98 
99  VCommandLine();
100 
101  //@brief returns DialogLayoutSettings::PaperSizeTemplate
103  //@brief returns rotation in degrees or 0 if not set
104  int OptRotation() const;
105 
106  Cases OptGroup() const;
107 
108  //@brief: called in destructor of application, so instance destroyed and new maybe created (never happen scenario though)
109  static void Reset();
110 
111  //@brief called to create single object, by VApplication only
112  static VCommandLinePtr Get(const QCoreApplication& app);
113 
114 private:
115  Q_DISABLE_COPY(VCommandLine)
117  QCommandLineParser parser;
119  QMap<QString, int> optionsIndex;
121  friend class VApplication;
122 
123  static qreal Lo2Px(const QString& src, const DialogLayoutSettings& converter);
124  static qreal Pg2Px(const QString& src, const DialogLayoutSettings& converter);
125 
126  static void InitOptions(VCommandLineOptions &options, QMap<QString, int> &optionsIndex);
127 };
128 
129 #endif // VCMDEXPORT_H
The VApplication class reimplamentation QApplication class.
Definition: vapplication.h:73
VCommandLineOptions optionsUsed
Definition: vcmdexport.h:118
QString OptDestinationPath() const
Definition: vcmdexport.cpp:612
int OptRotation() const
Definition: vcmdexport.cpp:556
bool IsTestModeEnabled() const
Definition: vcmdexport.cpp:515
static void InitOptions(VCommandLineOptions &options, QMap< QString, int > &optionsIndex)
Definition: vcmdexport.cpp:74
QString OptGradationHeight() const
Definition: vcmdexport.cpp:692
Cases OptGroup() const
Definition: vcmdexport.cpp:574
QStringList OptInputFileNames() const
Definition: vcmdexport.cpp:653
bool isGuiEnabled
Definition: vcmdexport.h:120
static void Reset()
Definition: vcmdexport.cpp:509
static VCommandLinePtr instance
Definition: vcmdexport.h:116
QCommandLineParser parser
Definition: vcmdexport.h:117
int exportOnlyPieces() const
Definition: vcmdexport.cpp:647
QString OptBaseName() const
Definition: vcmdexport.cpp:600
bool IsExportEnabled() const
Definition: vcmdexport.cpp:533
int IsBinaryDXF() const
Definition: vcmdexport.cpp:635
DialogLayoutSettings::PaperSizeTemplate OptPaperSize() const
Definition: vcmdexport.cpp:545
int isTextAsPaths() const
Definition: vcmdexport.cpp:641
QString OptMeasurePath() const
Definition: vcmdexport.cpp:585
bool IsNoScalingEnabled() const
Definition: vcmdexport.cpp:527
static VCommandLinePtr Get(const QCoreApplication &app)
Definition: vcmdexport.cpp:487
VLayoutGeneratorPtr DefaultGenerator() const
Definition: vcmdexport.cpp:278
static qreal Lo2Px(const QString &src, const DialogLayoutSettings &converter)
Definition: vcmdexport.cpp:62
virtual ~VCommandLine()
Definition: vcmdexport.cpp:502
bool IsSetGradationHeight() const
Definition: vcmdexport.cpp:671
bool IsGuiEnabled() const
Definition: vcmdexport.cpp:659
static qreal Pg2Px(const QString &src, const DialogLayoutSettings &converter)
Definition: vcmdexport.cpp:68
QString OptGradationSize() const
Definition: vcmdexport.cpp:677
bool IsSetGradationSize() const
Definition: vcmdexport.cpp:665
QMap< QString, int > optionsIndex
Definition: vcmdexport.h:119
int OptExportType() const
Definition: vcmdexport.cpp:624
Cases
Definition: vbank.h:71
std::shared_ptr< VLayoutGenerator > VLayoutGeneratorPtr
Definition: vcmdexport.h:44
std::shared_ptr< VCommandLine > VCommandLinePtr
Definition: vcmdexport.h:41
QList< QCommandLineOption * > VCommandLineOptions
Definition: vcmdexport.h:43