mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
fixed history tool
This commit is contained in:
@@ -125,7 +125,7 @@ void IntelliPhotoGui::slotCreateNewShapedLayer(){
|
||||
// Create New Layer
|
||||
if (ok1&&ok2) {
|
||||
paintingArea->addLayer(width, height, 0, 0,255, ImageType::SHAPEDIMAGE);
|
||||
paintingArea->historyadd();
|
||||
paintingArea->historyadd();
|
||||
UpdateGui();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,9 @@
|
||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
TypeOfImage = ImageType::RASTERIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
|
||||
IntelliRasterImage* IntelliRasterImage::copy(const IntelliRasterImage& image){
|
||||
this->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
return raster;
|
||||
}
|
||||
|
||||
|
||||
IntelliRasterImage::~IntelliRasterImage(){
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ public:
|
||||
*/
|
||||
IntelliRasterImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
IntelliRasterImage* copy(const IntelliRasterImage& image);
|
||||
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
*/
|
||||
|
||||
@@ -5,16 +5,8 @@
|
||||
#include <QDebug>
|
||||
|
||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
IntelliShapedImage* IntelliShapedImage::copy(const IntelliShapedImage& image){
|
||||
this->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
return shaped;
|
||||
}
|
||||
|
||||
IntelliShapedImage::~IntelliShapedImage(){
|
||||
|
||||
@@ -38,7 +38,6 @@ public:
|
||||
*/
|
||||
IntelliShapedImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
IntelliShapedImage* copy(const IntelliShapedImage& image);
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
*/
|
||||
|
||||
@@ -94,7 +94,6 @@ bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){
|
||||
}
|
||||
Canvas->setRenderSettings(static_cast<bool>(rendersetting));
|
||||
openFile.close();
|
||||
Canvas->historyadd();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ LayerObject::LayerObject(){
|
||||
|
||||
LayerObject::LayerObject(const LayerObject& layer){
|
||||
if(layer.image->getTypeOfImage()==ImageType::RASTERIMAGE) {
|
||||
this->image = new IntelliRasterImage(*dynamic_cast<IntelliRasterImage*>(layer.image));
|
||||
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->image = new IntelliShapedImage(*dynamic_cast<IntelliShapedImage*>(layer.image));
|
||||
}
|
||||
this->width = layer.width;
|
||||
this->height = layer.height;
|
||||
@@ -130,7 +130,7 @@ void PaintingArea::slotDeleteActiveLayer(){
|
||||
this->layerBundle.erase(layerBundle.begin() + activeLayer);
|
||||
activeLayer--;
|
||||
}
|
||||
historyadd();
|
||||
historyadd();
|
||||
}
|
||||
|
||||
void PaintingArea::setLayerActive(int idx){
|
||||
@@ -205,7 +205,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();
|
||||
historyadd();
|
||||
}
|
||||
|
||||
void PaintingArea::moveActiveLayer(int idx){
|
||||
@@ -216,7 +216,7 @@ void PaintingArea::moveActiveLayer(int idx){
|
||||
this->selectLayerDown();
|
||||
}
|
||||
guiReference->UpdateGui();
|
||||
historyadd();
|
||||
historyadd();
|
||||
}
|
||||
|
||||
void PaintingArea::slotActivateLayer(int a){
|
||||
@@ -509,46 +509,25 @@ void PaintingArea::updateTools(){
|
||||
|
||||
void PaintingArea::historyadd(){
|
||||
|
||||
historyPresent++;
|
||||
if (historyPresent == 100) {
|
||||
historyPresent = 0;
|
||||
}
|
||||
historyMaxFuture = historyPresent;
|
||||
if (historyPresent == historyMaxPast) {
|
||||
historyMaxPast++;
|
||||
if (historyMaxPast == 100) {
|
||||
historyMaxPast = 0;
|
||||
}
|
||||
}
|
||||
history[static_cast<size_t>(historyPresent)] = layerBundle;
|
||||
history.erase(history.begin()+historyPresent+1,history.end());
|
||||
historyPresent++;
|
||||
history.push_back(layerBundle);
|
||||
}
|
||||
|
||||
void PaintingArea::historyGoBack(){
|
||||
if (historyPresent != historyMaxPast) {
|
||||
if (--historyPresent == -1)
|
||||
historyPresent = 99;
|
||||
if (activeLayer == -1)
|
||||
activeLayer = 0;
|
||||
if (layerBundle.size() > history[static_cast<size_t>(historyPresent)].size())
|
||||
activeLayer = static_cast<int>(history[static_cast<size_t>(historyPresent)].size()) - 1;
|
||||
if (history[static_cast<size_t>(historyPresent)].size() == 0)
|
||||
activeLayer = -1;
|
||||
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||
}
|
||||
this->guiReference->UpdateGui();
|
||||
historyPresent--;
|
||||
if( historyPresent<0){
|
||||
historyPresent=0;
|
||||
}
|
||||
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||
this->guiReference->UpdateGui();
|
||||
}
|
||||
|
||||
void PaintingArea::historyGoForward(){
|
||||
if (historyPresent != historyMaxFuture) {
|
||||
if (++historyPresent == 100)
|
||||
historyPresent = 0;
|
||||
if (activeLayer == -1)
|
||||
activeLayer = 0;
|
||||
if (layerBundle.size() > history[static_cast<size_t>(historyPresent)].size())
|
||||
activeLayer = static_cast<int>(history[static_cast<size_t>(historyPresent)].size()) - 1;
|
||||
if (history[static_cast<size_t>(historyPresent)].size() == 0)
|
||||
activeLayer = -1;
|
||||
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||
}
|
||||
historyPresent++;
|
||||
if(historyPresent>=static_cast<int>(history.size())){
|
||||
historyPresent=history.size()-1;
|
||||
}
|
||||
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||
this->guiReference->UpdateGui();
|
||||
}
|
||||
|
||||
@@ -459,17 +459,7 @@ void updateTools();
|
||||
/*!
|
||||
* \brief history - an array out of containers to save history actions.
|
||||
*/
|
||||
std::vector<LayerObject> history[100] = {layerBundle};
|
||||
|
||||
/*!
|
||||
* \brief historyMaxPast a indicator how many steps you can go into the past.
|
||||
*/
|
||||
int historyMaxPast = 0;
|
||||
|
||||
/*!
|
||||
* \brief historyMaxPast a indicator how many steps you can go into the future.
|
||||
*/
|
||||
int historyMaxFuture = 0;
|
||||
std::vector<std::vector<LayerObject>> history = {layerBundle};
|
||||
|
||||
/*!
|
||||
* \brief historyPresent a indicator where the present is.
|
||||
|
||||
@@ -40,6 +40,7 @@ void IntelliTool::onMouseLeftReleased(int x, int y){
|
||||
this->mergeToolLayer();
|
||||
this->deleteToolLayer();
|
||||
activeLayer->image->calculateVisiblity();
|
||||
Area->historyadd();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -90,7 +91,6 @@ void IntelliTool::mergeToolLayer(){
|
||||
activeLayer->image->setPolygon(Canvas->image->getPolygonData());
|
||||
}
|
||||
Area->guiReference->UpdateGui();
|
||||
Area->historyadd();
|
||||
}
|
||||
|
||||
void IntelliTool::deleteToolLayer(){
|
||||
|
||||
Reference in New Issue
Block a user