fixed history tool

This commit is contained in:
Sonaion
2020-02-07 10:22:18 +01:00
parent 5787b065c5
commit 7e93e69a53
9 changed files with 23 additions and 74 deletions

View File

@@ -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(){

View File

@@ -26,8 +26,6 @@ public:
*/
IntelliRasterImage(int width, int height, bool fastRendererOn);
IntelliRasterImage* copy(const IntelliRasterImage& image);
/*!
* \brief An Destructor.
*/

View File

@@ -7,14 +7,6 @@
IntelliShapedImage::IntelliShapedImage(int width, int height, bool 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(){

View File

@@ -38,7 +38,6 @@ public:
*/
IntelliShapedImage(int width, int height, bool fastRendererOn);
IntelliShapedImage* copy(const IntelliShapedImage& image);
/*!
* \brief An Destructor.
*/

View File

@@ -94,7 +94,6 @@ bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){
}
Canvas->setRenderSettings(static_cast<bool>(rendersetting));
openFile.close();
Canvas->historyadd();
return true;
}

View File

@@ -509,46 +509,25 @@ void PaintingArea::updateTools(){
void PaintingArea::historyadd(){
history.erase(history.begin()+historyPresent+1,history.end());
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.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)];
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();
}

View File

@@ -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.

View File

@@ -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(){