mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
start of history
This commit is contained in:
@@ -82,7 +82,7 @@ void IntelliPhotoGui::slotCreateNewRasterLayer(){
|
||||
|
||||
// Create New Layer
|
||||
if (ok1&&ok2) {
|
||||
paintingArea->addLayer(width,height,0,0,IntelliImage::ImageType::RASTERIMAGE);
|
||||
paintingArea->addLayer(width,height,0,0,ImageType::RASTERIMAGE);
|
||||
UpdateGui();
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ void IntelliPhotoGui::slotCreateNewShapedLayer(){
|
||||
|
||||
// Create New Layer
|
||||
if (ok1&&ok2) {
|
||||
paintingArea->addLayer(width, height, 0, 0, IntelliImage::ImageType::SHAPEDIMAGE);
|
||||
paintingArea->addLayer(width, height, 0, 0, ImageType::SHAPEDIMAGE);
|
||||
UpdateGui();
|
||||
}
|
||||
}
|
||||
@@ -327,6 +327,14 @@ void IntelliPhotoGui::slotSetInnerAlpha(){
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::slotGoBack(){
|
||||
paintingArea->historyGoBack();
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::slotGoForward(){
|
||||
paintingArea->historyGoForward();
|
||||
}
|
||||
|
||||
// Define menu actions that call functions
|
||||
void IntelliPhotoGui::createActions(){
|
||||
// Get a list of the supported file formats
|
||||
@@ -525,6 +533,14 @@ void IntelliPhotoGui::createActions(){
|
||||
actionSetInnerAlpha = new QAction(tr("&Set Inner Alpha"),this);
|
||||
actionSetInnerAlpha->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A));
|
||||
connect(actionSetInnerAlpha, SIGNAL(triggered()), this, SLOT(slotSetInnerAlpha()));
|
||||
|
||||
actionGoBack = new QAction(tr("&Go back"),this);
|
||||
actionGoBack->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
|
||||
connect(actionGoBack, SIGNAL(triggered()), this, SLOT(slotGoBack()));
|
||||
|
||||
actionGoForward = new QAction(tr("&Go forward"),this);
|
||||
actionGoForward->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y));
|
||||
connect(actionGoForward, SIGNAL(triggered()), this, SLOT(slotGoForward()));
|
||||
}
|
||||
|
||||
// Create the menubar
|
||||
@@ -597,6 +613,8 @@ void IntelliPhotoGui::createMenus(){
|
||||
|
||||
// Attach all actions to Options
|
||||
optionMenu = new QMenu(tr("&Options"), this);
|
||||
optionMenu->addAction(actionGoBack);
|
||||
optionMenu->addAction(actionGoForward);
|
||||
optionMenu->addMenu(layerMenu);
|
||||
optionMenu->addMenu(toolMenu);
|
||||
optionMenu->addSeparator();
|
||||
|
||||
@@ -95,6 +95,9 @@ void slotSetInnerAlpha();
|
||||
|
||||
void slotResetTools();
|
||||
|
||||
void slotGoBack();
|
||||
void slotGoForward();
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
@@ -195,12 +198,16 @@ QAction* actionMovePositionRight;
|
||||
QAction* actionMoveLayerUp;
|
||||
QAction* actionMoveLayerDown;
|
||||
|
||||
// Actions tied to specific file formats
|
||||
// actions tied to specific file formats
|
||||
QList<QAction*> actionSaveAs;
|
||||
|
||||
QAction* actionSetWidth;
|
||||
QAction* actionSetInnerAlpha;
|
||||
|
||||
// history actions
|
||||
QAction* actionGoBack;
|
||||
QAction* actionGoForward;
|
||||
|
||||
// main GUI elements
|
||||
QWidget* centralGuiWidget;
|
||||
QGridLayout* mainLayout;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <QSize>
|
||||
#include <QPainter>
|
||||
|
||||
IntelliImage::IntelliImage(int width, int height, bool fastRendererOn)
|
||||
IntelliImage:: IntelliImage(int width, int height, bool fastRendererOn)
|
||||
: imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){
|
||||
if(fastRendererOn) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
@@ -15,6 +15,7 @@ IntelliImage::IntelliImage(int width, int height, bool fastRendererOn)
|
||||
|
||||
}
|
||||
|
||||
|
||||
IntelliImage::~IntelliImage(){
|
||||
|
||||
}
|
||||
@@ -158,3 +159,15 @@ void IntelliImage::updateRendererSetting(bool fastRendererOn){
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
}
|
||||
|
||||
int IntelliImage::getWidth() const{
|
||||
return imageData.width();
|
||||
}
|
||||
|
||||
int IntelliImage::getHeight() const{
|
||||
return imageData.height();
|
||||
}
|
||||
|
||||
bool IntelliImage::isFastRendering() const{
|
||||
return this->fastRenderering;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,14 @@ class UnitTest;
|
||||
|
||||
class IntelliTool;
|
||||
|
||||
/*!
|
||||
* \brief The Types, which an Image can be.
|
||||
*/
|
||||
enum class ImageType {
|
||||
RASTERIMAGE,
|
||||
SHAPEDIMAGE
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief An abstract class which manages the basic IntelliImage operations.
|
||||
*/
|
||||
@@ -24,13 +32,6 @@ friend UnitTest;
|
||||
friend IntelliTool;
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief The Types, which an Image can be.
|
||||
*/
|
||||
enum class ImageType {
|
||||
RASTERIMAGE,
|
||||
SHAPEDIMAGE
|
||||
};
|
||||
|
||||
protected:
|
||||
void resizeImage(QImage*image, const QSize &newSize);
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
*/
|
||||
IntelliImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief An Abstract Destructor.
|
||||
*/
|
||||
@@ -170,6 +172,12 @@ virtual QImage getImageData();
|
||||
*/
|
||||
virtual void setImageData(const QImage& newData);
|
||||
|
||||
virtual int getWidth() const;
|
||||
|
||||
virtual int getHeight() const;
|
||||
|
||||
virtual bool isFastRendering() const;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,18 +5,28 @@
|
||||
|
||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
|
||||
TypeOfImage = ImageType::RASTERIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
/*
|
||||
IntelliRasterImage::IntelliRasterImage(const IntelliRasterImage& image)
|
||||
: IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
IntelliRasterImage::~IntelliRasterImage(){
|
||||
|
||||
}
|
||||
|
||||
IntelliImage* IntelliRasterImage::getDeepCopy(){
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.fill(Qt::transparent);
|
||||
raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
|
||||
raster->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
return raster;
|
||||
}
|
||||
|
||||
|
||||
61
src/Image/IntelliRasterImage.cpp.autosave
Normal file
61
src/Image/IntelliRasterImage.cpp.autosave
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "Image/IntelliRasterImage.h"
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
|
||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
TypeOfImage = ImageType::RASTERIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
|
||||
IntelliRasterImage::Copy(const IntelliRasterImage& image)
|
||||
: IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
|
||||
|
||||
|
||||
IntelliRasterImage::~IntelliRasterImage(){
|
||||
|
||||
}
|
||||
|
||||
IntelliImage* IntelliRasterImage::getDeepCopy(){
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.fill(Qt::transparent);
|
||||
raster->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
return raster;
|
||||
}
|
||||
|
||||
void IntelliRasterImage::calculateVisiblity(){
|
||||
// not used in raster image
|
||||
}
|
||||
|
||||
QImage IntelliRasterImage::getDisplayable(int alpha){
|
||||
return getDisplayable(imageData.size(), alpha);
|
||||
}
|
||||
|
||||
QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
QImage copy = imageData;
|
||||
if(fastRenderering) {
|
||||
copy = copy.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<copy.height(); y++) {
|
||||
for(int x = 0; x<copy.width(); x++) {
|
||||
QColor clr = copy.pixelColor(x,y);
|
||||
clr.setAlpha(std::min(alpha, clr.alpha()));
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
void IntelliRasterImage::setPolygon(const std::vector<QPoint>& polygonData){
|
||||
return;
|
||||
}
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
*/
|
||||
IntelliRasterImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
//IntelliRasterImage(const IntelliRasterImage& image);
|
||||
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
*/
|
||||
|
||||
@@ -6,10 +6,19 @@
|
||||
|
||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
|
||||
TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
/*
|
||||
IntelliShapedImage::IntelliShapedImage(const IntelliShapedImage& image)
|
||||
: IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
*/
|
||||
|
||||
IntelliShapedImage::~IntelliShapedImage(){
|
||||
|
||||
}
|
||||
@@ -19,10 +28,10 @@ QImage IntelliShapedImage::getDisplayable(int alpha){
|
||||
}
|
||||
|
||||
IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false);
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->setPolygon(this->polygonData);
|
||||
shaped->imageData.fill(Qt::transparent);
|
||||
shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
|
||||
shaped->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
return shaped;
|
||||
}
|
||||
|
||||
|
||||
120
src/Image/IntelliShapedImage.cpp.autosave
Normal file
120
src/Image/IntelliShapedImage.cpp.autosave
Normal file
@@ -0,0 +1,120 @@
|
||||
#include "Image/IntelliShapedImage.h"
|
||||
#include "IntelliHelper/IntelliTriangulation.h"
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
|
||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
IntelliShapedImage::Copy(const IntelliShapedImage& image)
|
||||
: IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
|
||||
IntelliShapedImage::~IntelliShapedImage(){
|
||||
|
||||
}
|
||||
|
||||
QImage IntelliShapedImage::getDisplayable(int alpha){
|
||||
return getDisplayable(imageData.size(),alpha);
|
||||
}
|
||||
|
||||
IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->setPolygon(this->polygonData);
|
||||
shaped->imageData.fill(Qt::transparent);
|
||||
shaped->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
return shaped;
|
||||
}
|
||||
|
||||
void IntelliShapedImage::calculateVisiblity(){
|
||||
if(polygonData.size()<2) {
|
||||
return;
|
||||
}
|
||||
if(fastRenderering) {
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
|
||||
if(polygonData.size()<=2) {
|
||||
QColor clr;
|
||||
for(int y = 0; y<imageData.height(); y++) {
|
||||
for(int x = 0; x<imageData.width(); x++) {
|
||||
clr = imageData.pixel(x,y);
|
||||
clr.setAlpha(255);
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return;
|
||||
}
|
||||
QColor clr;
|
||||
for(int y = 0; y<imageData.height(); y++) {
|
||||
for(int x = 0; x<imageData.width(); x++) {
|
||||
QPoint ptr(x,y);
|
||||
clr = imageData.pixelColor(x,y);
|
||||
bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);
|
||||
if(isInPolygon) {
|
||||
clr.setAlpha(std::min(255, clr.alpha()));
|
||||
}else{
|
||||
clr.setAlpha(0);
|
||||
}
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
QImage copy = imageData;
|
||||
if(fastRenderering) {
|
||||
copy = copy.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<copy.height(); y++) {
|
||||
for(int x = 0; x<copy.width(); x++) {
|
||||
QColor clr = copy.pixelColor(x,y);
|
||||
clr.setAlpha(std::min(alpha,clr.alpha()));
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
|
||||
if(polygonData.size()<3) {
|
||||
this->polygonData.clear();
|
||||
}else{
|
||||
this->polygonData.clear();
|
||||
for(auto element:polygonData) {
|
||||
this->polygonData.push_back(QPoint(element.x(), element.y()));
|
||||
}
|
||||
triangles = IntelliTriangulation::calculateTriangles(polygonData);
|
||||
if(fastRenderering) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<imageData.height(); y++) {
|
||||
for(int x = 0; x<imageData.width(); x++) {
|
||||
QColor clr = imageData.pixelColor(x,y);
|
||||
clr.setAlpha(255);
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
calculateVisiblity();
|
||||
return;
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
*/
|
||||
IntelliShapedImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
//IntelliShapedImage(const IntelliShapedImage& image);
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,22 @@
|
||||
#include "Tool/IntelliToolFloodFill.h"
|
||||
#include "Tool/IntelliToolPolygon.h"
|
||||
|
||||
LayerObject::LayerObject(){
|
||||
|
||||
}
|
||||
|
||||
LayerObject::LayerObject(const LayerObject& layer){
|
||||
if(layer.image->getTypeOfImage()==ImageType::RASTERIMAGE){
|
||||
this->image = new IntelliRasterImage(*dynamic_cast<IntelliRasterImage*>(layer.image));
|
||||
}else if(layer.image->getTypeOfImage()==ImageType::SHAPEDIMAGE){
|
||||
this->image = new IntelliShapedImage(*dynamic_cast<IntelliShapedImage*>(layer.image));
|
||||
}
|
||||
this->width = layer.width;
|
||||
this->height = layer.height;
|
||||
this->widthOffset = layer.widthOffset;
|
||||
this->heightOffset = layer.heightOffset;
|
||||
this->alpha = layer.alpha;
|
||||
}
|
||||
|
||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
||||
: QWidget(parent){
|
||||
@@ -59,21 +75,22 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
||||
|
||||
}
|
||||
|
||||
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, IntelliImage::ImageType type){
|
||||
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){
|
||||
LayerObject newLayer;
|
||||
updateTools();
|
||||
newLayer.width = width;
|
||||
newLayer.height = height;
|
||||
newLayer.widthOffset = widthOffset;
|
||||
newLayer.heightOffset = heightOffset;
|
||||
if(type==IntelliImage::ImageType::RASTERIMAGE) {
|
||||
if(type==ImageType::RASTERIMAGE) {
|
||||
newLayer.image = new IntelliRasterImage(width,height,renderSettings.isFastRenderering());
|
||||
}else if(type==IntelliImage::ImageType::SHAPEDIMAGE) {
|
||||
}else if(type==ImageType::SHAPEDIMAGE) {
|
||||
newLayer.image = new IntelliShapedImage(width, height, renderSettings.isFastRenderering());
|
||||
}
|
||||
newLayer.alpha = 255;
|
||||
this->layerBundle.push_back(newLayer);
|
||||
activeLayer = static_cast<int>(layerBundle.size()) - 1;
|
||||
historyadd();
|
||||
return activeLayer;
|
||||
}
|
||||
|
||||
@@ -98,6 +115,7 @@ void PaintingArea::slotDeleteActiveLayer(){
|
||||
this->layerBundle.erase(layerBundle.begin() + activeLayer);
|
||||
activeLayer--;
|
||||
}
|
||||
historyadd();
|
||||
}
|
||||
|
||||
void PaintingArea::setLayerActive(int idx){
|
||||
@@ -116,7 +134,7 @@ void PaintingArea::setLayerAlpha(int idx, int alpha){
|
||||
}
|
||||
void PaintingArea::setPolygon(int idx){
|
||||
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
||||
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE) {
|
||||
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==ImageType::SHAPEDIMAGE) {
|
||||
delete this->Tool;
|
||||
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
|
||||
isSettingPolygon = true;
|
||||
@@ -165,6 +183,7 @@ void PaintingArea::movePositionActive(int x, int y){
|
||||
updateTools();
|
||||
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
|
||||
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
|
||||
historyadd();
|
||||
}
|
||||
|
||||
void PaintingArea::moveActiveLayer(int idx){
|
||||
@@ -175,6 +194,7 @@ void PaintingArea::moveActiveLayer(int idx){
|
||||
this->selectLayerDown();
|
||||
}
|
||||
DummyGui->UpdateGui();
|
||||
historyadd();
|
||||
}
|
||||
|
||||
void PaintingArea::slotActivateLayer(int a){
|
||||
@@ -248,7 +268,7 @@ int PaintingArea::getMaxHeight(){
|
||||
return this->maxHeight;
|
||||
}
|
||||
|
||||
IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){
|
||||
ImageType PaintingArea::getTypeOfImageRealLayer(){
|
||||
return this->layerBundle[static_cast<size_t>(activeLayer)].image->getTypeOfImage();
|
||||
}
|
||||
|
||||
@@ -449,3 +469,30 @@ void PaintingArea::updateTools(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PaintingArea::historyadd(){
|
||||
/*
|
||||
if (++historyPresent == 100) historyPresent = 0;
|
||||
historyMaxFuture = historyPresent;
|
||||
if (historyPresent == historyMaxPast) if (++historyMaxPast == 100) historyMaxPast = 0;
|
||||
history[static_cast<size_t>(historyPresent)] = layerBundle;
|
||||
|
||||
for (unsigned long long i=0;i < layerBundle.size();i++) {
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
void PaintingArea::historyGoBack(){
|
||||
if (historyPresent != historyMaxPast){
|
||||
if (--historyPresent == -1) historyPresent = 99;
|
||||
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||
}
|
||||
}
|
||||
|
||||
void PaintingArea::historyGoForward(){
|
||||
if (historyPresent != historyMaxFuture){
|
||||
if (++historyPresent == 100) historyPresent = 0;
|
||||
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ struct LayerObject {
|
||||
* \brief alpha - Stores the alpha value of the layer (default=255).
|
||||
*/
|
||||
int alpha = 255;
|
||||
|
||||
LayerObject();
|
||||
|
||||
LayerObject(const LayerObject& layer);
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -102,7 +106,7 @@ bool save(const QString &filePath, const char*fileFormat);
|
||||
* \param type - Defining the ImageType of the new layer
|
||||
* \return Returns the number of layers in the project
|
||||
*/
|
||||
int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
|
||||
int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, ImageType type = ImageType::RASTERIMAGE);
|
||||
/*!
|
||||
* \brief The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer stack
|
||||
* \param idx - Index of the position the new layer should be added
|
||||
@@ -113,7 +117,7 @@ int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, I
|
||||
* \param type - Defining the ImageType of the new layer
|
||||
* \return Returns the id of the layer position
|
||||
*/
|
||||
int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
|
||||
int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, ImageType type = ImageType::RASTERIMAGE);
|
||||
/*!
|
||||
* \brief The deleteLayer method removes a layer at a given idx
|
||||
* \param idx - The index of the layer to be removed
|
||||
@@ -184,7 +188,7 @@ int getMaxWidth();
|
||||
|
||||
int getMaxHeight();
|
||||
|
||||
IntelliImage::ImageType getTypeOfImageRealLayer();
|
||||
ImageType getTypeOfImageRealLayer();
|
||||
|
||||
std::vector<QPoint> getPolygonDataOfRealLayer();
|
||||
|
||||
@@ -201,6 +205,9 @@ QImage getImageDataOfActiveLayer();
|
||||
IntelliToolsettings Toolsettings;
|
||||
IntelliColorPicker colorPicker;
|
||||
|
||||
void historyGoBack();
|
||||
void historyGoForward();
|
||||
|
||||
public slots:
|
||||
/*!
|
||||
* \brief The slotActivateLayer method handles the event of selecting one layer as active
|
||||
@@ -245,6 +252,14 @@ void drawLayers(bool forSaving = false);
|
||||
bool createTempTopLayer(int idx);
|
||||
|
||||
void updateTools();
|
||||
|
||||
std::vector<LayerObject> history[100] = {layerBundle};
|
||||
int historyMaxPast = 0;
|
||||
int historyMaxFuture = 0;
|
||||
int historyPresent = 0;
|
||||
|
||||
void historyadd();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -89,6 +89,7 @@ void IntelliTool::mergeToolLayer(){
|
||||
activeLayer->image->setPolygon(Canvas->image->getPolygonData());
|
||||
}
|
||||
Area->DummyGui->UpdateGui();
|
||||
Area->historyadd();
|
||||
}
|
||||
|
||||
void IntelliTool::deleteToolLayer(){
|
||||
|
||||
@@ -24,7 +24,7 @@ IntelliToolPolygon::~IntelliToolPolygon(){
|
||||
}
|
||||
|
||||
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||
if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||
if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == ImageType::SHAPEDIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||
if(Area->getPolygonDataOfRealLayer().size()>2) {
|
||||
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
|
||||
QPoint Point(x,y);
|
||||
@@ -37,7 +37,7 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||
isInside = true;
|
||||
}
|
||||
}
|
||||
else if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x >= 0 && y >= 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||
else if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == ImageType::RASTERIMAGE && x >= 0 && y >= 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||
isInside = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user