Modified Preview Canvas

- Now the Preview can show free space around the image (the image's
corner will coincide with the center of the preview area)
- Editing objects can now be manipulated in this free space
- The editing mechanism has been split : it was completely handled in
rtengine before, now rtengine still handle the pipette's data provider,
but rtgui now handle the objects data provider.
- Bugfix: when using coarse rotate in the Editor panel, the Gradient
widgets are now correctly displayed
This commit is contained in:
Hombre
2016-01-29 22:09:56 +01:00
parent 8c3e6eab95
commit 4665b88788
22 changed files with 1413 additions and 848 deletions

View File

@@ -31,7 +31,7 @@ namespace rtengine
extern const Settings* settings;
Crop::Crop (ImProcCoordinator* parent, EditDataProvider *editDataProvider, bool isDetailWindow)
: EditBuffer(editDataProvider), origCrop(NULL), laboCrop(NULL), labnCrop(NULL),
: PipetteBuffer(editDataProvider), origCrop(NULL), laboCrop(NULL), labnCrop(NULL),
cropImg(NULL), cbuf_real(NULL), cshmap(NULL), transCrop(NULL), cieCrop(NULL), cbuffer(NULL),
updating(false), newUpdatePending(false), skip(10),
cropx(0), cropy(0), cropw(-1), croph(-1),
@@ -77,7 +77,7 @@ void Crop::setListener (DetailedCropListener* il)
EditUniqueID Crop::getCurrEditID()
{
EditSubscriber *subscriber = EditBuffer::dataProvider ? EditBuffer::dataProvider->getCurrSubscriber() : NULL;
EditSubscriber *subscriber = PipetteBuffer::dataProvider ? PipetteBuffer::dataProvider->getCurrSubscriber() : NULL;
return subscriber ? subscriber->getEditID() : EUID_None;
}
@@ -90,32 +90,25 @@ void Crop::setEditSubscriber(EditSubscriber* newSubscriber)
MyMutex::MyLock lock(cropMutex);
// At this point, editCrop.dataProvider->currSubscriber is the old subscriber
EditSubscriber *oldSubscriber = EditBuffer::dataProvider ? EditBuffer::dataProvider->getCurrSubscriber() : NULL;
EditSubscriber *oldSubscriber = PipetteBuffer::dataProvider ? PipetteBuffer::dataProvider->getCurrSubscriber() : NULL;
if (newSubscriber == NULL || (oldSubscriber != NULL && oldSubscriber->getEditBufferType() != newSubscriber->getEditBufferType())) {
if (EditBuffer::imgFloatBuffer != NULL) {
delete EditBuffer::imgFloatBuffer;
EditBuffer::imgFloatBuffer = NULL;
if (newSubscriber == NULL || (oldSubscriber != NULL && oldSubscriber->getPipetteBufferType() != newSubscriber->getPipetteBufferType())) {
if (PipetteBuffer::imgFloatBuffer != NULL) {
delete PipetteBuffer::imgFloatBuffer;
PipetteBuffer::imgFloatBuffer = NULL;
}
if (EditBuffer::LabBuffer != NULL) {
delete EditBuffer::LabBuffer;
EditBuffer::LabBuffer = NULL;
if (PipetteBuffer::LabBuffer != NULL) {
delete PipetteBuffer::LabBuffer;
PipetteBuffer::LabBuffer = NULL;
}
if (EditBuffer::singlePlaneBuffer.getW() != -1) {
EditBuffer::singlePlaneBuffer.flushData();
if (PipetteBuffer::singlePlaneBuffer.getW() != -1) {
PipetteBuffer::singlePlaneBuffer.flushData();
}
}
if (newSubscriber == NULL && oldSubscriber != NULL && oldSubscriber->getEditingType() == ET_OBJECTS) {
printf("Free object buffers\n");
EditBuffer::resize(0, 0); // This will delete the objects buffer
} else if (newSubscriber && newSubscriber->getEditingType() == ET_OBJECTS) {
EditBuffer::resize(cropw, croph, newSubscriber);
}
// If oldSubscriber == NULL && newSubscriber != NULL -> the image will be allocated when necessary
// If oldSubscriber == NULL && newSubscriber != NULL && newSubscriber->getEditingType() == ET_PIPETTE-> the image will be allocated when necessary
}
void Crop::update (int todo)
@@ -984,7 +977,7 @@ void Crop::update (int todo)
}
// all pipette buffer processing should be finished now
EditBuffer::setReady();
PipetteBuffer::setReady();
// switch back to rgb
parent->ipf.lab2monitorRgb (labnCrop, cropImg);
@@ -1085,7 +1078,7 @@ void Crop::freeAll ()
cshmap = NULL;
}
EditBuffer::flush();
PipetteBuffer::flush();
}
cropAllocated = false;
@@ -1157,6 +1150,15 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte
printf ("setsizes starts (%d, %d, %d, %d, %d, %d)\n", orW, orH, trafw, trafh, cw, ch);
}
EditType editType = ET_PIPETTE;
EditDataProvider *editProvider = PipetteBuffer::getDataProvider();
if (editProvider) {
EditSubscriber *editSubscriber = editProvider->getCurrSubscriber();
if (editSubscriber) {
editType = editSubscriber->getEditingType();
}
}
if (cw != cropw || ch != croph || orW != trafw || orH != trafh) {
cropw = cw;
@@ -1223,7 +1225,11 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte
cshmap = new SHMap (cropw, croph, true);
}
EditBuffer::resize(cropw, croph);
if (editType == ET_PIPETTE) {
PipetteBuffer::resize(cropw, croph);
} else if (PipetteBuffer::bufferCreated()) {
PipetteBuffer::flush();
}
cropAllocated = true;
@@ -1235,7 +1241,12 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte
trafx = orx;
trafy = ory;
if (settings->verbose) {
if (changed) {
printf("new crop size: cropx=%d, cropy=%d, cropw=%d, croph=%d / rqcropx=%d, rqcropy=%d, rqcropw=%d, rqcroph=%d / leftBorder=%d, upperBorder=%d\n",
cropx, cropy, cropw, croph, rqcropx, rqcropy, rqcropw, rqcroph, leftBorder, upperBorder);
}
printf ("setsizes ends\n");
}