Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

#assistants: TAssistantsImage

Ivan Mahonin71b43d4d52f4
diff --git a/toonz/sources/common/tassistantsimage/tassistantsimage.cpp b/toonz/sources/common/tassistantsimage/tassistantsimage.cpp
new file mode 100644
index 000000000..79bf506cc
--- /dev/null
+++ b/toonz/sources/common/tassistantsimage/tassistantsimage.cpp
@@ -0,0 +1,33 @@
+
+
+#include "tassistantsimage.h"
+
+//---------------------------------------------------------
+
+TAssistantsImage::TAssistantsImage()
+ { }
+
+//---------------------------------------------------------
+
+TAssistantsImage::TAssistantsImage(const TAssistantsImage &other):
+ m_assistants(*Reader(other))
+ { }
+
+//---------------------------------------------------------
+
+TAssistantsImage::~TAssistantsImage()
+ { }
+
+//---------------------------------------------------------
+
+TImage*
+TAssistantsImage::cloneImage() const
+ { return new TAssistantsImage(*this); }
+
+//---------------------------------------------------------
+
+TRectD
+TAssistantsImage::getBBox() const
+ { return TRectD(); }
+
+//---------------------------------------------------------
diff --git a/toonz/sources/include/tassistantsimage.h b/toonz/sources/include/tassistantsimage.h
new file mode 100644
index 000000000..6848556a1
--- /dev/null
+++ b/toonz/sources/include/tassistantsimage.h
@@ -0,0 +1,101 @@
+#pragma once
+
+#ifndef TASSISTANTSIMAGE_INCLUDED
+#define TASSISTANTSIMAGE_INCLUDED
+
+#include "timage.h"
+#include "tthreadmessage.h"
+
+#include <QReadLocker>
+#include <QWriteLocker>
+#include <QReadWriteLock>
+
+#include <string>
+
+#undef DVAPI
+#undef DVVAR
+#ifdef TASSISTANTSIMAGE_EXPORTS
+#define DVAPI DV_EXPORT_API
+#define DVVAR DV_EXPORT_VAR
+#else
+#define DVAPI DV_IMPORT_API
+#define DVVAR DV_IMPORT_VAR
+#endif
+
+//-------------------------------------------------------------------
+
+class TAssistantDesc;
+typedef std::vector<TAssistantDesc> TAssistantDescList;
+
+//-------------------------------------------------------------------
+
+class TAssistantDesc {
+public:
+ std::string type;
+ std::vector<TPointD> points;
+ TSmartObjectP handler;
+};
+
+//-------------------------------------------------------------------
+
+//! An image containing an assistants for painting.
+
+class DVAPI TAssistantsImage final : public TImage {
+public:
+ class Reader: public QReadLocker {
+ private:
+ const TAssistantsImage &m_image;
+ public:
+ Reader(const TAssistantsImage &image):
+ QReadLocker(&image.m_rwLock), m_image(image) { }
+ const TAssistantsImage& image() const
+ { return m_image; }
+ const TAssistantDescList& get() const
+ { return m_image.m_assistants; }
+ const TAssistantDescList& operator*() const
+ { return get(); }
+ const TAssistantDescList* operator->() const
+ { return &get(); }
+ };
+
+ class Writer: public QWriteLocker {
+ private:
+ TAssistantsImage &m_image;
+ public:
+ Writer(TAssistantsImage &image):
+ QWriteLocker(&image.m_rwLock), m_image(image) { }
+ TAssistantsImage& image() const
+ { return m_image; }
+ TAssistantDescList& get() const
+ { return m_image.m_assistants; }
+ TAssistantDescList& operator*() const
+ { return get(); }
+ TAssistantDescList* operator->() const
+ { return &get(); }
+ };
+
+private:
+ mutable QReadWriteLock m_rwLock;
+ TAssistantDescList m_assistants;
+
+public:
+ TAssistantsImage();
+ ~TAssistantsImage();
+
+private:
+ //! not implemented
+ TAssistantsImage(const TAssistantsImage &other);
+ TAssistantsImage &operator=(const TAssistantsImage &) { return *this; }
+
+public:
+ //! Return the image type
+ TImage::Type getType() const override { return TImage::ASSISTANTS; }
+
+ //! Return a clone of image
+ TImage* cloneImage() const override;
+
+ //! Return the bbox of the image
+ TRectD getBBox() const override;
+};
+
+#endif
diff --git a/toonz/sources/include/timage.h b/toonz/sources/include/timage.h
index f11660dbb..63aeff06a 100644
--- a/toonz/sources/include/timage.h
+++ b/toonz/sources/include/timage.h
@@ -49,7 +49,8 @@ lines, curves, and shapes or polygon(s),
RASTER = 1, //!< A fullcolor raster image.
VECTOR = 2, //!< A vector image.
TOONZ_RASTER = 3, //!< A colormap raster image.
- MESH = 4 //!< A textured mesh image.
+ MESH = 4, //!< A textured mesh image.
+ ASSISTANTS = 5 //!< An assistants for painting image.
};
/*!
diff --git a/toonz/sources/include/tsmartpointer.h b/toonz/sources/include/tsmartpointer.h
index 1f68dc703..ed1e3fce4 100644
--- a/toonz/sources/include/tsmartpointer.h
+++ b/toonz/sources/include/tsmartpointer.h
@@ -182,4 +182,8 @@ public:
}
};
+//=========================================================
+
+typedef TSmartPointerT<TSmartObject> TSmartObjectP;
+
#endif
diff --git a/toonz/sources/tnzcore/CMakeLists.txt b/toonz/sources/tnzcore/CMakeLists.txt
index e1cdaa26d..0ee1d7444 100644
--- a/toonz/sources/tnzcore/CMakeLists.txt
+++ b/toonz/sources/tnzcore/CMakeLists.txt
@@ -120,6 +120,7 @@ set(HEADERS ${MOC_HEADERS}
../include/tmeshimage.h
../include/tgldisplaylistsmanager.h
../include/tversion.h
+ ../include/tassistantsimage.h
)
set(SOURCES
@@ -242,6 +243,7 @@ set(SOURCES
../common/tmeshimage/tmeshimage.cpp
../common/tmsgcore.cpp
../common/tvrender/tfont_qt.cpp
+ ../common/tassistantsimage/tassistantsimage.cpp
)
if(BUILD_TARGET_WIN)
@@ -282,6 +284,7 @@ add_definitions(
-DTSOUND_EXPORTS
-DTIMAGE_IO_EXPORTS
-DTRASTERIMAGE_EXPORTS
+ -DTASSISTANTSIMAGE_EXPORTS
-DTVRENDER_EXPORTS
-DTFLASH_EXPORTS
-DTROP_EXPORTS