mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-16 05:10:32 +02:00
fixed history tool
This commit is contained in:
@@ -6,17 +6,9 @@
|
|||||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||||
: IntelliImage(width, height, fastRendererOn){
|
: IntelliImage(width, height, fastRendererOn){
|
||||||
TypeOfImage = ImageType::RASTERIMAGE;
|
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(){
|
IntelliRasterImage::~IntelliRasterImage(){
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
IntelliRasterImage(int width, int height, bool fastRendererOn);
|
IntelliRasterImage(int width, int height, bool fastRendererOn);
|
||||||
|
|
||||||
IntelliRasterImage* copy(const IntelliRasterImage& image);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief An Destructor.
|
* \brief An Destructor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,14 +7,6 @@
|
|||||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||||
: IntelliRasterImage(width, height, fastRendererOn){
|
: IntelliRasterImage(width, height, fastRendererOn){
|
||||||
TypeOfImage = ImageType::SHAPEDIMAGE;
|
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(){
|
IntelliShapedImage::~IntelliShapedImage(){
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
IntelliShapedImage(int width, int height, bool fastRendererOn);
|
IntelliShapedImage(int width, int height, bool fastRendererOn);
|
||||||
|
|
||||||
IntelliShapedImage* copy(const IntelliShapedImage& image);
|
|
||||||
/*!
|
/*!
|
||||||
* \brief An Destructor.
|
* \brief An Destructor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){
|
|||||||
}
|
}
|
||||||
Canvas->setRenderSettings(static_cast<bool>(rendersetting));
|
Canvas->setRenderSettings(static_cast<bool>(rendersetting));
|
||||||
openFile.close();
|
openFile.close();
|
||||||
Canvas->historyadd();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -509,46 +509,25 @@ void PaintingArea::updateTools(){
|
|||||||
|
|
||||||
void PaintingArea::historyadd(){
|
void PaintingArea::historyadd(){
|
||||||
|
|
||||||
|
history.erase(history.begin()+historyPresent+1,history.end());
|
||||||
historyPresent++;
|
historyPresent++;
|
||||||
if (historyPresent == 100) {
|
history.push_back(layerBundle);
|
||||||
historyPresent = 0;
|
|
||||||
}
|
|
||||||
historyMaxFuture = historyPresent;
|
|
||||||
if (historyPresent == historyMaxPast) {
|
|
||||||
historyMaxPast++;
|
|
||||||
if (historyMaxPast == 100) {
|
|
||||||
historyMaxPast = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
history[static_cast<size_t>(historyPresent)] = layerBundle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::historyGoBack(){
|
void PaintingArea::historyGoBack(){
|
||||||
if (historyPresent != historyMaxPast) {
|
historyPresent--;
|
||||||
if (--historyPresent == -1)
|
if( historyPresent<0){
|
||||||
historyPresent = 99;
|
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)];
|
|
||||||
}
|
}
|
||||||
|
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||||
this->guiReference->UpdateGui();
|
this->guiReference->UpdateGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::historyGoForward(){
|
void PaintingArea::historyGoForward(){
|
||||||
if (historyPresent != historyMaxFuture) {
|
historyPresent++;
|
||||||
if (++historyPresent == 100)
|
if(historyPresent>=static_cast<int>(history.size())){
|
||||||
historyPresent = 0;
|
historyPresent=history.size()-1;
|
||||||
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)];
|
|
||||||
}
|
}
|
||||||
|
layerBundle = history[static_cast<size_t>(historyPresent)];
|
||||||
this->guiReference->UpdateGui();
|
this->guiReference->UpdateGui();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -459,17 +459,7 @@ void updateTools();
|
|||||||
/*!
|
/*!
|
||||||
* \brief history - an array out of containers to save history actions.
|
* \brief history - an array out of containers to save history actions.
|
||||||
*/
|
*/
|
||||||
std::vector<LayerObject> history[100] = {layerBundle};
|
std::vector<std::vector<LayerObject>> history = {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;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief historyPresent a indicator where the present is.
|
* \brief historyPresent a indicator where the present is.
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ void IntelliTool::onMouseLeftReleased(int x, int y){
|
|||||||
this->mergeToolLayer();
|
this->mergeToolLayer();
|
||||||
this->deleteToolLayer();
|
this->deleteToolLayer();
|
||||||
activeLayer->image->calculateVisiblity();
|
activeLayer->image->calculateVisiblity();
|
||||||
|
Area->historyadd();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +91,6 @@ void IntelliTool::mergeToolLayer(){
|
|||||||
activeLayer->image->setPolygon(Canvas->image->getPolygonData());
|
activeLayer->image->setPolygon(Canvas->image->getPolygonData());
|
||||||
}
|
}
|
||||||
Area->guiReference->UpdateGui();
|
Area->guiReference->UpdateGui();
|
||||||
Area->historyadd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliTool::deleteToolLayer(){
|
void IntelliTool::deleteToolLayer(){
|
||||||
|
|||||||
Reference in New Issue
Block a user