mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-19 06:40:31 +02:00
Updated it works kinda
TOdo: fix BUGS
This commit is contained in:
@@ -27,6 +27,9 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliShapedImage::calculateVisiblity(){
|
void IntelliShapedImage::calculateVisiblity(){
|
||||||
|
if(polygonData.size()<2){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(fastRenderering) {
|
if(fastRenderering) {
|
||||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||||
}
|
}
|
||||||
@@ -91,6 +94,19 @@ void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
|
|||||||
this->polygonData.push_back(QPoint(element.x(), element.y()));
|
this->polygonData.push_back(QPoint(element.x(), element.y()));
|
||||||
}
|
}
|
||||||
triangles = IntelliTriangulation::calculateTriangles(polygonData);
|
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();
|
calculateVisiblity();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ void PaintingArea::setLayerAlpha(int idx, int alpha){
|
|||||||
void PaintingArea::setPolygon(int idx){
|
void PaintingArea::setPolygon(int idx){
|
||||||
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
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()==IntelliImage::ImageType::SHAPEDIMAGE){
|
||||||
qDebug() << "Todo Implement here set Polygon";
|
delete this->Tool;
|
||||||
|
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,5 +439,20 @@ IntelliImage* PaintingArea::getImageOfActiveLayer(){
|
|||||||
if(activeLayer<0) {
|
if(activeLayer<0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return layerBundle[activeLayer].image;
|
return layerBundle[static_cast<size_t>(activeLayer)].image;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage PaintingArea::getImageDataOfActiveLayer(){
|
||||||
|
QImage returnImage;
|
||||||
|
if(activeLayer<0) {
|
||||||
|
returnImage = QImage(QSize(10,10),QImage::Format_ARGB32);
|
||||||
|
returnImage.fill(QColor(255,255,255,255));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
returnImage = layerBundle[static_cast<size_t>(activeLayer)].image->getImageData();
|
||||||
|
if(renderSettings.isFastRenderering()){
|
||||||
|
returnImage = returnImage.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnImage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,6 +182,12 @@ int getNumberOfActiveLayer();
|
|||||||
|
|
||||||
IntelliImage* getImageOfActiveLayer();
|
IntelliImage* getImageOfActiveLayer();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief getImageDataOfActiveLayer used to get the currents active imageData (if there isn't any active layer it return a 10*10 white picture)
|
||||||
|
* \return return the image as an rgba32bit qImage
|
||||||
|
*/
|
||||||
|
QImage getImageDataOfActiveLayer();
|
||||||
|
|
||||||
IntelliToolsettings Toolsettings;
|
IntelliToolsettings Toolsettings;
|
||||||
IntelliColorPicker colorPicker;
|
IntelliColorPicker colorPicker;
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void IntelliTool::mergeToolLayer(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
activeLayer->image->setImageData(updatedImage);
|
activeLayer->image->setImageData(updatedImage);
|
||||||
if(Canvas->image->getPolygonData().size() != 0){
|
if(Canvas->image->getPolygonData().size() > 0){
|
||||||
activeLayer->image->setPolygon(Canvas->image->getPolygonData());
|
activeLayer->image->setPolygon(Canvas->image->getPolygonData());
|
||||||
}
|
}
|
||||||
Area->DummyGui->UpdateGui();
|
Area->DummyGui->UpdateGui();
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
|
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings, bool isSettingPolygon)
|
||||||
: IntelliTool(Area, colorPicker, Toolsettings){
|
: IntelliTool(Area, colorPicker, Toolsettings){
|
||||||
isPointNearStart = false;
|
isPointNearStart = false;
|
||||||
isDrawing = false;
|
isDrawing = false;
|
||||||
isInside = false;
|
isInside = false;
|
||||||
|
this->isSettingPolygon = isSettingPolygon;
|
||||||
this->ActiveType = Tooltype::POLYGON;
|
this->ActiveType = Tooltype::POLYGON;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +24,9 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
|||||||
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
|
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
|
||||||
QPoint Point(x,y);
|
QPoint Point(x,y);
|
||||||
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
|
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
|
||||||
|
if(isSettingPolygon){
|
||||||
|
isInside = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
|
||||||
isInside = true;
|
isInside = true;
|
||||||
@@ -36,13 +40,17 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
|||||||
QPointList.push_back(drawingPoint);
|
QPointList.push_back(drawingPoint);
|
||||||
|
|
||||||
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||||
|
if(!isSettingPolygon){
|
||||||
this->Canvas->image->calculateVisiblity();
|
this->Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(isDrawing && isNearStart(x,y,QPointList.front())) {
|
else if(isDrawing && isNearStart(x,y,QPointList.front())) {
|
||||||
if(QPointList.size() > 2) {
|
if(QPointList.size() > 2) {
|
||||||
isPointNearStart = true;
|
isPointNearStart = true;
|
||||||
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||||
|
if(!isSettingPolygon){
|
||||||
this->Canvas->image->calculateVisiblity();
|
this->Canvas->image->calculateVisiblity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
isInside = false;
|
isInside = false;
|
||||||
@@ -56,8 +64,10 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
|||||||
QPoint drawingPoint(x,y);
|
QPoint drawingPoint(x,y);
|
||||||
QPointList.push_back(drawingPoint);
|
QPointList.push_back(drawingPoint);
|
||||||
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||||
|
if(!isSettingPolygon){
|
||||||
this->Canvas->image->calculateVisiblity();
|
this->Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolPolygon::onMouseRightPressed(int x, int y){
|
void IntelliToolPolygon::onMouseRightPressed(int x, int y){
|
||||||
@@ -73,7 +83,7 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
|||||||
isInside = false;
|
isInside = false;
|
||||||
isPointNearStart = false;
|
isPointNearStart = false;
|
||||||
isDrawing = false;
|
isDrawing = false;
|
||||||
if(false){
|
if(!isSettingPolygon){
|
||||||
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
|
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
|
||||||
QPoint Point;
|
QPoint Point;
|
||||||
QColor colorTwo(colorPicker->getSecondColor());
|
QColor colorTwo(colorPicker->getSecondColor());
|
||||||
@@ -94,6 +104,7 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Canvas->image->setPolygon(QPointList);
|
Canvas->image->setPolygon(QPointList);
|
||||||
|
Canvas->image->setImageData(Area->getImageDataOfActiveLayer());
|
||||||
}
|
}
|
||||||
IntelliTool::onMouseLeftReleased(x,y);
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
QPointList.clear();
|
QPointList.clear();
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ bool isDrawing;
|
|||||||
*/
|
*/
|
||||||
bool isInside;
|
bool isInside;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief isSettingPolygon is the flag for calling the setPolygon method.
|
||||||
|
*/
|
||||||
|
bool isSettingPolygon;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief PointIsNearStart true, when last click near startpoint, else false.
|
* \brief PointIsNearStart true, when last click near startpoint, else false.
|
||||||
*/
|
*/
|
||||||
@@ -43,8 +48,9 @@ public:
|
|||||||
* \brief A constructor setting the general paintingArea and colorPicker.
|
* \brief A constructor setting the general paintingArea and colorPicker.
|
||||||
* \param Area - The general paintingArea used by the project.
|
* \param Area - The general paintingArea used by the project.
|
||||||
* \param colorPicker - The general colorPicker used by the project.
|
* \param colorPicker - The general colorPicker used by the project.
|
||||||
|
* \param isSettingPolygon - The flag for the set polygon method, standart is false
|
||||||
*/
|
*/
|
||||||
IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
|
IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings, bool isSettingPolygon = false);
|
||||||
/*!
|
/*!
|
||||||
* \brief A Destructor.
|
* \brief A Destructor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user