mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-15 21:00:37 +02:00
FIxed all bugs and removed dead code
my job is done here ready to be merge
This commit is contained in:
@@ -202,35 +202,6 @@ void IntelliPhotoGui::slotMoveLayerDown(){
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::slotClearActiveLayer(){
|
|
||||||
// Stores button value
|
|
||||||
bool ok1, ok2, ok3, ok4;
|
|
||||||
|
|
||||||
// "Red Input" is the title of the window
|
|
||||||
// the next tr is the text to display
|
|
||||||
// Define the standard Value, min, max, step and ok button
|
|
||||||
int red = QInputDialog::getInt(this, tr("Red Input"),
|
|
||||||
tr("Red:"),
|
|
||||||
255,0, 255,1, &ok1);
|
|
||||||
// "Green Input" is the title of the window
|
|
||||||
int green = QInputDialog::getInt(this, tr("Green Input"),
|
|
||||||
tr("Green:"),
|
|
||||||
255,0, 255, 1, &ok2);
|
|
||||||
// "Blue Input" is the title of the window
|
|
||||||
int blue = QInputDialog::getInt(this, tr("Blue Input"),
|
|
||||||
tr("Blue:"),
|
|
||||||
255,0, 255, 1, &ok3);
|
|
||||||
// "Alpha Input" is the title of the window
|
|
||||||
int alpha = QInputDialog::getInt(this, tr("Alpha Input"),
|
|
||||||
tr("Alpha:"),
|
|
||||||
255,0, 255, 1, &ok4);
|
|
||||||
if (ok1&&ok2&&ok3&&ok4)
|
|
||||||
{
|
|
||||||
paintingArea->floodFill(red, green, blue, alpha);
|
|
||||||
UpdateGui();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntelliPhotoGui::slotSetActiveLayer(){
|
void IntelliPhotoGui::slotSetActiveLayer(){
|
||||||
// Stores button value
|
// Stores button value
|
||||||
bool ok1;
|
bool ok1;
|
||||||
@@ -788,6 +759,7 @@ void IntelliPhotoGui::setIntelliStyle(){
|
|||||||
this->helpMenu->setPalette(Palette);
|
this->helpMenu->setPalette(Palette);
|
||||||
this->renderMenu->setPalette(Palette);
|
this->renderMenu->setPalette(Palette);
|
||||||
this->toolMenu->setPalette(Palette);
|
this->toolMenu->setPalette(Palette);
|
||||||
|
this->layerCreationMenu->setPalette(Palette);
|
||||||
this->layerMenu->setPalette(Palette);
|
this->layerMenu->setPalette(Palette);
|
||||||
this->colorMenu->setPalette(Palette);
|
this->colorMenu->setPalette(Palette);
|
||||||
this->toolCreationMenu->setPalette(Palette);
|
this->toolCreationMenu->setPalette(Palette);
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ void slotSave();
|
|||||||
void slotCreateNewRasterLayer();
|
void slotCreateNewRasterLayer();
|
||||||
void slotCreateNewShapedLayer();
|
void slotCreateNewShapedLayer();
|
||||||
void slotDeleteLayer();
|
void slotDeleteLayer();
|
||||||
void slotClearActiveLayer();
|
|
||||||
void slotSetActiveLayer();
|
void slotSetActiveLayer();
|
||||||
void slotSetActiveAlpha();
|
void slotSetActiveAlpha();
|
||||||
void slotSetPolygon();
|
void slotSetPolygon();
|
||||||
|
|||||||
@@ -18,24 +18,13 @@
|
|||||||
#include "Tool/IntelliToolFloodFill.h"
|
#include "Tool/IntelliToolFloodFill.h"
|
||||||
#include "Tool/IntelliToolPolygon.h"
|
#include "Tool/IntelliToolPolygon.h"
|
||||||
|
|
||||||
|
|
||||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
||||||
: QWidget(parent){
|
: QWidget(parent){
|
||||||
this->Tool = nullptr;
|
this->Tool = nullptr;
|
||||||
this->setLayerDimensions(maxWidth, maxHeight);
|
this->setLayerDimensions(maxWidth, maxHeight);
|
||||||
this->addLayer(200,200,0,0,IntelliImage::ImageType::SHAPEDIMAGE);
|
|
||||||
layerBundle[0].image->drawPlain(QColor(0,0,255,255));
|
|
||||||
std::vector<QPoint> polygon;
|
|
||||||
polygon.push_back(QPoint(100,000));
|
|
||||||
polygon.push_back(QPoint(200,100));
|
|
||||||
polygon.push_back(QPoint(100,200));
|
|
||||||
polygon.push_back(QPoint(000,100));
|
|
||||||
layerBundle[0].image->setPolygon(polygon);
|
|
||||||
|
|
||||||
this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
|
activeLayer=-1;
|
||||||
layerBundle[1].image->drawPlain(QColor(0,255,0,255));
|
|
||||||
layerBundle[1].alpha=200;
|
|
||||||
|
|
||||||
activeLayer=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintingArea::~PaintingArea(){
|
PaintingArea::~PaintingArea(){
|
||||||
@@ -64,6 +53,7 @@ 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, IntelliImage::ImageType type){
|
||||||
LayerObject newLayer;
|
LayerObject newLayer;
|
||||||
|
updateTools();
|
||||||
newLayer.width = width;
|
newLayer.width = width;
|
||||||
newLayer.height = height;
|
newLayer.height = height;
|
||||||
newLayer.widthOffset = widthOffset;
|
newLayer.widthOffset = widthOffset;
|
||||||
@@ -80,7 +70,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PaintingArea::deleteLayer(int idx){
|
void PaintingArea::deleteLayer(int idx, bool isTool){
|
||||||
|
if(!isTool){
|
||||||
|
updateTools();
|
||||||
|
}
|
||||||
if(idx<static_cast<int>(layerBundle.size())) {
|
if(idx<static_cast<int>(layerBundle.size())) {
|
||||||
this->layerBundle.erase(layerBundle.begin()+idx);
|
this->layerBundle.erase(layerBundle.begin()+idx);
|
||||||
if(activeLayer>=idx) {
|
if(activeLayer>=idx) {
|
||||||
@@ -100,7 +93,8 @@ void PaintingArea::slotDeleteActiveLayer(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::setLayerActive(int idx){
|
void PaintingArea::setLayerActive(int idx){
|
||||||
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
updateTools();
|
||||||
|
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
||||||
this->activeLayer=idx;
|
this->activeLayer=idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +109,7 @@ void PaintingArea::setPolygon(int idx){
|
|||||||
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE){
|
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE){
|
||||||
delete this->Tool;
|
delete this->Tool;
|
||||||
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
|
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
|
||||||
|
isSettingPolygon = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,36 +150,14 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color the image area with white
|
|
||||||
void PaintingArea::floodFill(int r, int g, int b, int a){
|
|
||||||
if(this->activeLayer==-1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
|
|
||||||
active->drawPlain(QColor(r, g, b, a));
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaintingArea::movePositionActive(int x, int y){
|
void PaintingArea::movePositionActive(int x, int y){
|
||||||
if(Tool!=nullptr) {
|
updateTools();
|
||||||
if(Tool->getIsDrawing()) {
|
|
||||||
IntelliTool* temp = copyActiveTool();
|
|
||||||
delete this->Tool;
|
|
||||||
this->Tool = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
|
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
|
||||||
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
|
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::moveActiveLayer(int idx){
|
void PaintingArea::moveActiveLayer(int idx){
|
||||||
if(Tool != nullptr) {
|
updateTools();
|
||||||
if(Tool->getIsDrawing()) {
|
|
||||||
IntelliTool* temp = copyActiveTool();
|
|
||||||
delete this->Tool;
|
|
||||||
this->Tool = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(idx==1) {
|
if(idx==1) {
|
||||||
this->selectLayerUp();
|
this->selectLayerUp();
|
||||||
}else if(idx==-1) {
|
}else if(idx==-1) {
|
||||||
@@ -193,14 +166,8 @@ void PaintingArea::moveActiveLayer(int idx){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::slotActivateLayer(int a){
|
void PaintingArea::slotActivateLayer(int a){
|
||||||
if(Tool != nullptr) {
|
updateTools();
|
||||||
if(Tool->getIsDrawing()) {
|
if(a>=0 && a < static_cast<int>(layerBundle.size())) {
|
||||||
IntelliTool* temp = copyActiveTool();
|
|
||||||
delete this->Tool;
|
|
||||||
this->Tool = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(a>=0 && a < static_cast<int>(layerBundle.size())) {
|
|
||||||
this->setLayerActive(a);
|
this->setLayerActive(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,7 +310,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize the image to slightly larger then the main window
|
//TODOJ Resize the image to slightly larger then the main window
|
||||||
// to cut down on the need to resize the image
|
// to cut down on the need to resize the image
|
||||||
void PaintingArea::resizeEvent(QResizeEvent*event){
|
void PaintingArea::resizeEvent(QResizeEvent*event){
|
||||||
//TODO wait till tool works
|
//TODO wait till tool works
|
||||||
@@ -355,14 +322,16 @@ void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::selectLayerUp(){
|
void PaintingArea::selectLayerUp(){
|
||||||
if(activeLayer!=-1 && static_cast<unsigned long long>(activeLayer)<layerBundle.size()-1) {
|
updateTools();
|
||||||
|
if(activeLayer!=-1 && static_cast<unsigned long long>(activeLayer)<layerBundle.size()-1) {
|
||||||
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer+1)]);
|
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer+1)]);
|
||||||
activeLayer++;
|
activeLayer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::selectLayerDown(){
|
void PaintingArea::selectLayerDown(){
|
||||||
if(activeLayer!=-1 && activeLayer>0) {
|
updateTools();
|
||||||
|
if(activeLayer!=-1 && activeLayer>0) {
|
||||||
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer-1)]);
|
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer-1)]);
|
||||||
activeLayer--;
|
activeLayer--;
|
||||||
}
|
}
|
||||||
@@ -456,3 +425,18 @@ QImage PaintingArea::getImageDataOfActiveLayer(){
|
|||||||
}
|
}
|
||||||
return returnImage;
|
return returnImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaintingArea::updateTools(){
|
||||||
|
if(Tool!=nullptr) {
|
||||||
|
if(Tool->getIsDrawing()){
|
||||||
|
IntelliTool* temp = copyActiveTool();
|
||||||
|
delete this->Tool;
|
||||||
|
this->Tool = temp;
|
||||||
|
}
|
||||||
|
if(isSettingPolygon){
|
||||||
|
delete this->Tool;
|
||||||
|
this->Tool = nullptr;
|
||||||
|
isSettingPolygon = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -102,8 +102,9 @@ int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffs
|
|||||||
/*!
|
/*!
|
||||||
* \brief The deleteLayer method removes a layer at a given idx
|
* \brief The deleteLayer method removes a layer at a given idx
|
||||||
* \param idx - The index of the layer to be removed
|
* \param idx - The index of the layer to be removed
|
||||||
|
* \param isTool - Is the flag for when a tool uses this function.
|
||||||
*/
|
*/
|
||||||
void deleteLayer(int idx);
|
void deleteLayer(int idx, bool isTool = false);
|
||||||
/*!
|
/*!
|
||||||
* \brief The setLayerToActive method marks a specific layer as active
|
* \brief The setLayerToActive method marks a specific layer as active
|
||||||
* \param idx - The index of the layer to be active
|
* \param idx - The index of the layer to be active
|
||||||
@@ -120,14 +121,6 @@ void setLayerAlpha(int idx, int alpha);
|
|||||||
* \param idx - represents the number of the layer with should be transformed
|
* \param idx - represents the number of the layer with should be transformed
|
||||||
*/
|
*/
|
||||||
void setPolygon(int idx);
|
void setPolygon(int idx);
|
||||||
/*!
|
|
||||||
* \brief The floodFill method fills a the active layer with a given color
|
|
||||||
* \param r - Red value of the color the layer should be filled with
|
|
||||||
* \param g - Green value of the color the layer should be filled with
|
|
||||||
* \param b - Blue value of the color the layer should be filled with
|
|
||||||
* \param a - Alpha value of the color the layer should be filled with
|
|
||||||
*/
|
|
||||||
void floodFill(int r, int g, int b, int a);
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The movePositionActive method moves the active layer to certain position
|
* \brief The movePositionActive method moves the active layer to certain position
|
||||||
* \param x - The x value the new center of the layer should be at
|
* \param x - The x value the new center of the layer should be at
|
||||||
@@ -226,6 +219,8 @@ QImage* Canvas;
|
|||||||
int maxWidth;
|
int maxWidth;
|
||||||
int maxHeight;
|
int maxHeight;
|
||||||
|
|
||||||
|
bool isSettingPolygon = false;
|
||||||
|
|
||||||
IntelliRenderSettings renderSettings;
|
IntelliRenderSettings renderSettings;
|
||||||
IntelliTool* Tool;
|
IntelliTool* Tool;
|
||||||
IntelliPhotoGui* DummyGui;
|
IntelliPhotoGui* DummyGui;
|
||||||
@@ -239,6 +234,9 @@ void resizeLayer(QImage*image_res, const QSize &newSize);
|
|||||||
|
|
||||||
// Helper for Tool
|
// Helper for Tool
|
||||||
bool createTempTopLayer(int idx);
|
bool createTempTopLayer(int idx);
|
||||||
|
|
||||||
|
//this function is needed to avoid errors in inputhandeling if a layer has changed
|
||||||
|
void updateTools();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,10 +32,11 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
|
|||||||
|
|
||||||
void IntelliTool::onMouseLeftReleased(int x, int y){
|
void IntelliTool::onMouseLeftReleased(int x, int y){
|
||||||
if(isDrawing) {
|
if(isDrawing) {
|
||||||
isDrawing=false;
|
isDrawing=false;
|
||||||
this->mergeToolLayer();
|
this->mergeToolLayer();
|
||||||
this->deleteToolLayer();
|
this->deleteToolLayer();
|
||||||
activeLayer->image->calculateVisiblity();
|
activeLayer->image->calculateVisiblity();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +88,7 @@ void IntelliTool::mergeToolLayer(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliTool::deleteToolLayer(){
|
void IntelliTool::deleteToolLayer(){
|
||||||
Area->deleteLayer(Area->activeLayer+1);
|
Area->deleteLayer(Area->activeLayer+1, true);
|
||||||
this->Canvas=nullptr;
|
this->Canvas=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,14 @@ IntelliToolPolygon::~IntelliToolPolygon(){
|
|||||||
|
|
||||||
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||||
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||||
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
|
if(Area->getPolygonDataOfRealLayer().size()>2){
|
||||||
QPoint Point(x,y);
|
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
|
||||||
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
|
QPoint Point(x,y);
|
||||||
|
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
isInside = true;
|
||||||
|
}
|
||||||
if(isSettingPolygon){
|
if(isSettingPolygon){
|
||||||
isInside = true;
|
isInside = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user