diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 063f4b7..a2b0206 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -206,8 +206,8 @@ void IntelliPhotoGui::slotSetSecondColor(){ paintingArea->colorPickerSetSecondColor(); } -void IntelliPhotoGui::slotSwitchColor(){ - paintingArea->colorPickerSwitchColor(); +void IntelliPhotoGui::slotSwapColor(){ + paintingArea->colorPickerSwapColors(); } void IntelliPhotoGui::slotCreatePenTool(){ @@ -328,9 +328,9 @@ void IntelliPhotoGui::createActions(){ actionColorPickerSecondColor = new QAction(tr("&Secondary"), this); connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetSecondColor())); - actionColorSwitch = new QAction(tr("&Switch"), this); - actionColorSwitch->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); - connect(actionColorSwitch, SIGNAL(triggered()), this, SLOT(slotSwitchColor())); + actionColorSwap = new QAction(tr("&Switch"), this); + actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); + connect(actionColorSwap, SIGNAL(triggered()), this, SLOT(slotSwapColor())); //Create Tool actions down here actionCreatePlainTool = new QAction(tr("&Plain"), this); @@ -398,7 +398,7 @@ void IntelliPhotoGui::createMenus(){ colorMenu = new QMenu(tr("&Color"), this); colorMenu->addAction(actionColorPickerFirstColor); colorMenu->addAction(actionColorPickerSecondColor); - colorMenu->addAction(actionColorSwitch); + colorMenu->addAction(actionColorSwap); //Attach all Tool Options toolMenu = new QMenu(tr("&Tools"), this); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index e6acca9..e76485c 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -55,7 +55,7 @@ void slotMoveLayerDown(); // color Picker slots here void slotSetFirstColor(); void slotSetSecondColor(); -void slotSwitchColor(); +void slotSwapColor(); // tool slots here void slotCreatePenTool(); @@ -103,7 +103,7 @@ QAction*actionExit; // color Picker actions QAction*actionColorPickerFirstColor; QAction*actionColorPickerSecondColor; -QAction*actionColorSwitch; +QAction*actionColorSwap; // tool actions QAction*actionCreatePenTool; diff --git a/src/Image/IntelliImage.h b/src/Image/IntelliImage.h index 1dce011..be99c1d 100644 --- a/src/Image/IntelliImage.h +++ b/src/Image/IntelliImage.h @@ -33,10 +33,10 @@ QImage imageData; public: /*! * \brief The Construcor of the IntelliImage. Given the Image dimensions. - * \param weight - The weight of the Image. + * \param width - The width of the Image. * \param height - The height of the Image. */ -IntelliImage(int weight, int height); +IntelliImage(int width, int height); /*! * \brief An Abstract Destructor. @@ -91,7 +91,7 @@ virtual QImage getDisplayable(int alpha=255) = 0; /*! * \brief A function that copys all that returns a [allocated] Image - * \return A [allocated] Image with all the properties of the instance. + * \return An [allocated] image with all the properties of the instance. */ virtual IntelliImage* getDeepCopy() = 0; diff --git a/src/Image/IntelliRasterImage.h b/src/Image/IntelliRasterImage.h index 5a3de15..0879abb 100644 --- a/src/Image/IntelliRasterImage.h +++ b/src/Image/IntelliRasterImage.h @@ -16,10 +16,10 @@ virtual void calculateVisiblity() override; public: /*! * \brief The Construcor of the IntelliRasterImage. Given the Image dimensions. - * \param weight - The weight of the Image. + * \param width - The width of the Image. * \param height - The height of the Image. */ -IntelliRasterImage(int weight, int height); +IntelliRasterImage(int width, int height); /*! * \brief An Destructor. diff --git a/src/Image/IntelliShapedImage.h b/src/Image/IntelliShapedImage.h index fbdd22e..5d1288d 100644 --- a/src/Image/IntelliShapedImage.h +++ b/src/Image/IntelliShapedImage.h @@ -29,10 +29,10 @@ std::vector polygonData; public: /*! * \brief The Construcor of the IntelliShapedImage. Given the Image dimensions. - * \param weight - The weight of the Image. + * \param width - The width of the Image. * \param height - The height of the Image. */ -IntelliShapedImage(int weight, int height); +IntelliShapedImage(int width, int height); /*! * \brief An Destructor. diff --git a/src/IntelliHelper/IntelliColorPicker.cpp b/src/IntelliHelper/IntelliColorPicker.cpp index 534a8e5..104039b 100644 --- a/src/IntelliHelper/IntelliColorPicker.cpp +++ b/src/IntelliHelper/IntelliColorPicker.cpp @@ -9,7 +9,7 @@ IntelliColorPicker::~IntelliColorPicker(){ } -void IntelliColorPicker::switchColors(){ +void IntelliColorPicker::swapColors(){ std::swap(firstColor, secondColor); } diff --git a/src/IntelliHelper/IntelliColorPicker.h.autosave b/src/IntelliHelper/IntelliColorPicker.h.autosave new file mode 100644 index 0000000..4ea686b --- /dev/null +++ b/src/IntelliHelper/IntelliColorPicker.h.autosave @@ -0,0 +1,64 @@ +#ifndef INTELLITOOLSETCOLORTOOL_H +#define INTELLITOOLSETCOLORTOOL_H + +#include "QColor" +#include "QPoint" +#include "QColorDialog" + +/*! + * \brief The IntelliColorPicker manages the selected colors for one whole project. + */ +class IntelliColorPicker { +public: +/*! + * \brief IntelliColorPicker constructor, setting 2 preset colors, be careful, theese color may change in production. + */ +IntelliColorPicker(); + +/*! + * \brief IntelliColorPicker destructor clears up his used memory, if there is some. + */ +virtual ~IntelliColorPicker(); + +/*! + * \brief A function switching primary and secondary color. + */ +void swapColors(); + +/*! + * \brief A function to read the primary selected color. + * \return Returns the primary color. + */ +QColor getFirstColor(); + +/*! + * \brief A function to read the secondary selected color. + * \return Returns the secondary color. + */ +QColor getSecondColor(); + +/*! + * \brief A function to set the primary color. + * \param Color - The color to be set as primary. + */ +void setFirstColor(QColor Color); + +/*! + * \brief A function to set the secondary color. + * \param Color - The color to be set as secondary. + */ +void setSecondColor(QColor Color); + +private: +/*! + * \brief The primary color. + */ +QColor firstColor; + +/*! + * \brief The secondary color. + */ +QColor secondColor; +}; + +#endif // INTELLITOOLSETCOLORTOOL_H diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 4a18918..cb65271 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -21,7 +21,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) : QWidget(parent){ this->Tool = nullptr; - this->setUp(maxWidth, maxHeight); + this->setLayerDimensions(maxWidth, maxHeight); this->addLayer(200,200,0,0,ImageType::Shaped_Image); layerBundle[0].image->drawPlain(QColor(0,0,255,255)); std::vector polygon; @@ -42,7 +42,7 @@ PaintingArea::~PaintingArea(){ delete Tool; } -void PaintingArea::setUp(int maxWidth, int maxHeight){ +void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){ //set standart parameter this->maxWidth = maxWidth; this->maxHeight = maxHeight; @@ -99,35 +99,35 @@ void PaintingArea::setAlphaOfLayer(int index, int alpha){ } // Used to load the image and place it in the widget -bool PaintingArea::open(const QString &fileName){ +bool PaintingArea::open(const QString &filePath){ if(this->activeLayer==-1) { return false; } IntelliImage* active = layerBundle[static_cast(activeLayer)].image; - bool open = active->loadImage(fileName); + bool open = active->loadImage(filePath); active->calculateVisiblity(); update(); return open; } // Save the current image -bool PaintingArea::save(const QString &fileName, const char*fileFormat){ +bool PaintingArea::save(const QString &filePath, const char*fileFormat){ if(layerBundle.size()==0) { return false; } - this->assembleLayers(true); + this->drawLayers(true); if(!strcmp(fileFormat,"PNG")) { QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8); fileFormat = "png"; - if (visibleImage.save(fileName, fileFormat)) { + if (visibleImage.save(filePath, fileFormat)) { return true; } else { return false; } } - if (Canvas->save(fileName, fileFormat)) { + if (Canvas->save(filePath, fileFormat)) { return true; } else { return false; @@ -151,9 +151,9 @@ void PaintingArea::movePositionActive(int x, int y){ void PaintingArea::moveActiveLayer(int idx){ if(idx==1) { - this->activateUpperLayer(); + this->selectLayerUp(); }else if(idx==-1) { - this->activateLowerLayer(); + this->selectLayerDown(); } } @@ -173,8 +173,8 @@ void PaintingArea::colorPickerSetSecondColor(){ this->colorPicker.setSecondColor(clr); } -void PaintingArea::colorPickerSwitchColor(){ - this->colorPicker.switchColors(); +void PaintingArea::colorPickerSwapColors(){ + this->colorPicker.swapColors(); } void PaintingArea::createPenTool(){ @@ -273,7 +273,7 @@ void PaintingArea::wheelEvent(QWheelEvent*event){ // The QPaintEvent is sent to widgets that need to // update themselves void PaintingArea::paintEvent(QPaintEvent*event){ - this->assembleLayers(); + this->drawLayers(); QPainter painter(this); QRect dirtyRec = event->rect(); @@ -288,25 +288,25 @@ void PaintingArea::resizeEvent(QResizeEvent*event){ update(); } -void PaintingArea::resizeImage(QImage*image_res, const QSize &newSize){ +void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){ //TODO implement } -void PaintingArea::activateUpperLayer(){ +void PaintingArea::selectLayerUp(){ if(activeLayer!=-1 && activeLayer0) { std::swap(layerBundle[activeLayer], layerBundle[activeLayer-1]); activeLayer--; } } -void PaintingArea::assembleLayers(bool forSaving){ +void PaintingArea::drawLayers(bool forSaving){ if(forSaving) { Canvas->fill(Qt::GlobalColor::transparent); }else{ diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 591f693..27812b1 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -61,14 +61,14 @@ public: * \param fileName - Path and filename which are used to determine where the to-be-opened file is stored * \return Returns a boolean variable whether the file was successfully opened or not */ - bool open(const QString &fileName); + bool open(const QString &filePath); /*! * \brief The save method is used for exporting the current project as one picture * \param fileName * \param fileFormat * \return Returns a boolean variable, true if the file was saved successfully, false if not */ - bool save(const QString &fileName, const char *fileFormat); + bool save(const QString &filePath, const char *fileFormat); /*! * \brief The addLayer adds a layer to the current project/ painting area @@ -90,7 +90,7 @@ public: * \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, ImageType type = ImageType::Raster_Image); + int addLayerAt(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image, int idx); /*! * \brief The deleteLayer method removes a layer at a given index * \param index - The index of the layer to be removed @@ -139,7 +139,7 @@ public: /*! * \brief The colorPickerSwitchColor swaps the primary color with the secondary drawing color */ - void colorPickerSwitchColor(); + void colorPickerSwapColors(); // Create tools void createPenTool(); @@ -187,9 +187,9 @@ protected: void resizeEvent(QResizeEvent *event) override; private: - void setUp(int maxWidth, int maxHeight); - void activateUpperLayer(); - void activateLowerLayer(); + void setLayerDimensions(int maxWidth, int maxHeight); + void selectLayerUp(); + void selectLayerDown(); QImage* Canvas; int maxWidth; @@ -201,12 +201,13 @@ private: std::vector layerBundle; int activeLayer=-1; - void assembleLayers(bool forSaving=false); + void drawLayers(bool forSaving=false); - void resizeImage(QImage *image_res, const QSize &newSize); + void resizeLayer(QImage *image_res, const QSize &newSize); // Helper for Tool - void createTempLayerAfter(int idx); + // TODO: Always create this layer on top and return the id here! + void createTempTopLayer(int idx); }; #endif diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index e83fef9..5fdd6d2 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -48,7 +48,7 @@ void IntelliTool::onWheelScrolled(int value){ } void IntelliTool::createToolLayer(){ - Area->createTempLayerAfter(Area->activeLayer); + Area->createTempTopLayer(Area->activeLayer); this->Active=&Area->layerBundle[Area->activeLayer]; this->Canvas=&Area->layerBundle[Area->activeLayer+1]; }