25 #include "colourref.h" 
   26 #include "pencilerror.h" 
   27 #include "pencildef.h" 
   28 #include "objectdata.h" 
   30 class QProgressDialog;
 
   37 #define ProgressCallback std::function<void(float)> 
   65     QProgressDialog* progress;
 
   76     Object( QObject* parent = 
nullptr );
 
   80     void createWorkingDir();
 
   81     void deleteWorkingDir() 
const;
 
   83     QString filePath()
 const { 
return mFilePath; }
 
   84     void    setFilePath( QString strFileName ) { mFilePath = strFileName; }
 
   86     QString workingDir()
 const { 
return mWorkingDirPath; }
 
   89     QString dataDir()
 const { 
return mDataDirPath; }
 
   90     void    setDataDir( QString dirPath ) { mDataDirPath = dirPath; }
 
   92     QString mainXMLFile()
 const { 
return mMainXMLFile; }
 
   93     void    setMainXMLFile( QString file ){ mMainXMLFile = file; }
 
   95     QDomElement saveXML( QDomDocument& doc );
 
   96     bool loadXML( QDomElement element, ProgressCallback progress = [] (
float){} );
 
   98     void paintImage( QPainter& painter, 
int frameNumber, 
bool background, 
bool antialiasing ) 
const;
 
  100     QString copyFileToDataFolder( QString strFilePath );
 
  104     void setColour( 
int index, QColor newColour )
 
  106         Q_ASSERT( index >= 0 );
 
  107         mPalette[ index ].colour = newColour;
 
  109     void addColour( QColor );
 
  110     void addColour( 
ColourRef newColour ) { mPalette.append( newColour ); }
 
  111     bool removeColour( 
int index );
 
  112     void renameColour( 
int i, QString text );
 
  113     int getColourCount() { 
return mPalette.size(); }
 
  114     bool importPalette( QString filePath );
 
  115     bool exportPalette( QString filePath );
 
  116     bool savePalette( QString filePath );
 
  118     void loadDefaultPalette();
 
  125     int  getLayerCount() 
const ;
 
  127     Layer* getLayer( 
int i ) 
const;
 
  128     Layer* findLayerByName( QString strName, Layer::LAYER_TYPE type = Layer::UNDEFINED ) 
const;
 
  130     bool moveLayer( 
int i, 
int j );
 
  131     void deleteLayer( 
int i );
 
  132     void deleteLayer( 
Layer* );
 
  134     template< 
typename T >
 
  135     std::vector< T* > getLayersByType()
 const 
  137         std::vector< T* > result;
 
  138         for ( 
Layer* layer : mLayers )
 
  140             T* t = 
dynamic_cast<T*
>( layer );
 
  143                 result.push_back( t );
 
  150     bool exportFrames( 
int frameStart, 
int frameEnd, 
Layer* currentLayer, QSize exportSize, QString filePath, 
const char* format, 
int quality, 
bool transparency, 
bool antialiasing, QProgressDialog* progress, 
int progressMax );
 
  151     bool exportX( 
int frameStart, 
int frameEnd, QTransform view, QSize exportSize, QString filePath, 
bool antialiasing );
 
  152     bool exportIm(
int frameStart, 
int frameEnd, QTransform view, QSize exportSize, QString filePath, QString format, 
bool antialiasing , 
bool transparency);
 
  154     void modification() { modified = 
true; }
 
  155     bool isModified() { 
return modified; }
 
  156     void setModified( 
bool b ) { modified = b; }
 
  158     int getUniqueLayerID();
 
  163     void setLayerUpdated(
int layerId);
 
  166     void layerChanged( 
int layerId );
 
  172     QString mWorkingDirPath; 
 
  173     QString mDataDirPath;    
 
  174     QString mMainXMLFile;    
 
  177     bool modified = 
false;
 
  181     std::unique_ptr< ObjectData > mEditorState;