Skip to content

Commit

Permalink
hotfix compression and delete cached cubes on harddrive in streaming …
Browse files Browse the repository at this point in the history
…mode
  • Loading branch information
my-tien committed Aug 15, 2014
1 parent 1eb93d5 commit 96db29c
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 8 deletions.
1 change: 1 addition & 0 deletions eventmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ void EventModel::handleKeyRelease(QKeyEvent *event) {
state->compressionRatio = originalCompressionRatio;
}
state->viewer->changeDatasetMag(DATA_SET);
emit compressionRatioToggled();
}
}

Expand Down
1 change: 1 addition & 0 deletions eventmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class EventModel : public QObject
void nodeActivatedSignal();
void nodeRadiusChangedSignal(nodeListElement *node);
void nodePositionChangedSignal(nodeListElement *node);
void compressionRatioToggled();
};

#endif // EVENTMODEL_H
27 changes: 27 additions & 0 deletions loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,25 @@ void Loader::loadCube(loadcube_thread_struct *lts) {
if(fclose(cubeFile) != 0) {
LOG("Additionally, an error occured closing the file");
}
if(LM_FTP == state->loadMode) {
if(remove(filename) != 0) {
qDebug() << "Failed to delete cube file " << filename;
}
else {
qDebug("successful delete");
}
}
goto loadcube_fail;
} else {
fclose(cubeFile);
if(LM_FTP == state->loadMode) {
if(remove(filename) != 0) {
qDebug() << "Failed to delete cube file " << filename;
}
else {
qDebug("successful delete");
}
}
}
break;
case 1000:
Expand All @@ -598,8 +614,10 @@ void Loader::loadCube(loadcube_thread_struct *lts) {
LOG("malloc failed!\n");
goto loadcube_fail;
}

readBytes = fread(localCompressedBuf, 1, localCompressedBufSize, cubeFile);
fclose(cubeFile);

if (localCompressedBufSize != readBytes) {
LOG("fread failed for %s! (%d instead of %d)\n", filename, readBytes, localCompressedBufSize);
goto loadcube_fail;
Expand All @@ -618,6 +636,12 @@ void Loader::loadCube(loadcube_thread_struct *lts) {
LOG("tjDecompress2() failed!");
goto loadcube_fail;
}

if(LM_FTP == state->loadMode) {
if(remove((const char*)filename) != 0) {
qDebug() << "Failed to delete cube file " << filename;
}
}
#else
LOG("JPG disabled, Knossos wasn’t compiled with config »turbojpeg«.");
#endif
Expand All @@ -628,6 +652,9 @@ void Loader::loadCube(loadcube_thread_struct *lts) {
LOG("Decompression function failed!");
goto loadcube_fail;
}
if(LM_FTP == state->loadMode) {
remove(filename);
}
break;
}
goto loadcube_manage;
Expand Down
2 changes: 2 additions & 0 deletions viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,7 @@ void Viewer::rewire() {
QObject::connect(eventModel, &EventModel::setViewportOrientationSignal, vpUpperLeft, &Viewport::setOrientation);
QObject::connect(eventModel, &EventModel::setViewportOrientationSignal, vpLowerLeft, &Viewport::setOrientation);
QObject::connect(eventModel, &EventModel::setViewportOrientationSignal, vpUpperRight, &Viewport::setOrientation);
QObject::connect(eventModel, &EventModel::compressionRatioToggled, window->widgetContainer->zoomAndMultiresWidget, &ZoomAndMultiresWidget::updateCompressionRatioDisplay);
//end event handler signals
// mainwindow signals
QObject::connect(window, &MainWindow::branchPushedSignal, window->widgetContainer->annotationWidget->treeviewTab, &ToolsTreeviewTab::branchPushed);
Expand Down Expand Up @@ -2021,6 +2022,7 @@ void Viewer::rewire() {
// dataset property signals --
QObject::connect(window->widgetContainer->datasetPropertyWidget, &DatasetPropertyWidget::clearSkeletonSignalNoGUI, window, &MainWindow::clearSkeletonSlotNoGUI);
QObject::connect(window->widgetContainer->datasetPropertyWidget, &DatasetPropertyWidget::clearSkeletonSignalGUI, window, &MainWindow::clearSkeletonSlotGUI);
QObject::connect(window->widgetContainer->datasetPropertyWidget, &DatasetPropertyWidget::updateCompressionLabel, window->widgetContainer->zoomAndMultiresWidget, &ZoomAndMultiresWidget::updateCompressionRatioDisplay);
// -- end dataset property signals
// task management signals --
QObject::connect(window->widgetContainer->taskManagementWidget->mainTab, &TaskManagementMainTab::loadSkeletonSignal,
Expand Down
2 changes: 1 addition & 1 deletion widgets/datasetpropertywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,6 @@ void DatasetPropertyWidget::changeDataSet(bool isGUI) {
}

emit datasetSwitchZoomDefaults();

emit updateCompressionLabel();
this->hide();
}
1 change: 1 addition & 0 deletions widgets/datasetpropertywidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class DatasetPropertyWidget : public QDialog {
void userMoveSignal(int x, int y, int z);
void datasetSwitchZoomDefaults();
void startLoaderSignal();
void updateCompressionLabel();
public slots:
void datasetfileDialogClicked();
void supercubeEdgeSpinValueChanged(const int value);
Expand Down
49 changes: 43 additions & 6 deletions widgets/zoomandmultireswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ ZoomAndMultiresWidget::ZoomAndMultiresWidget(QWidget *parent) :
setWindowIcon(QIcon(":/images/icons/zoom-in.png"));
setWindowTitle("Zoom and Multiresolution");

// compression section
switch(state->compressionRatio) {
case 0:
compressionLabel.setText("Current compression: none (toggle with (5))");
break;
case 1000:
compressionLabel.setText("Current compression: jpg (toggle with (5))");
break;
case 1001:
compressionLabel.setText("Current compression: j2k (toggle with (5))");
break;
default:
compressionLabel.setText("Current compression: jp2 (toggle with (5))");
}

// top layout
QGridLayout *topLayout = new QGridLayout();
this->orthogonalDataViewportLabel = new QLabel(QString("Orthogonal Data Viewport (mag %1)").arg(state->magnification));
Expand All @@ -61,21 +76,27 @@ ZoomAndMultiresWidget::ZoomAndMultiresWidget(QWidget *parent) :
this->skeletonViewportSpinBox->setMinimum(0);
this->skeletonViewportSpinBox->setSuffix("\%");

topLayout->addWidget(this->orthogonalDataViewportLabel, 0, 1);
topLayout->addWidget(this->orthogonalDataViewportSpinBox, 0, 2);
QFrame *line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
topLayout->addWidget(&zoomSectionLabel, 0, 0);
topLayout->addWidget(line, 1, 0, 1, 2);
topLayout->addWidget(this->orthogonalDataViewportLabel, 2, 0);
topLayout->addWidget(this->orthogonalDataViewportSpinBox, 2, 1);

topLayout->addWidget(this->skeletonViewportLabel, 1, 1);
topLayout->addWidget(this->skeletonViewportSpinBox, 1, 2);
topLayout->addWidget(this->skeletonViewportLabel, 3, 0);
topLayout->addWidget(this->skeletonViewportSpinBox, 3, 1);

this->zoomDefaultsButton = new QPushButton("All Zoom defaults");
zoomDefaultsButton->setAutoDefault(false);
topLayout->addWidget(zoomDefaultsButton, 2, 1);
topLayout->addWidget(zoomDefaultsButton, 4, 0);

// main layout
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addWidget(&compressionLabel);
mainLayout->addLayout(topLayout);

QFrame *line = new QFrame();
line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);

Expand Down Expand Up @@ -114,6 +135,22 @@ ZoomAndMultiresWidget::ZoomAndMultiresWidget(QWidget *parent) :
this->setWindowFlags(this->windowFlags() & (~Qt::WindowContextHelpButtonHint));
}

void ZoomAndMultiresWidget::updateCompressionRatioDisplay() {
switch(state->compressionRatio) {
case 0:
compressionLabel.setText("Current compression: none (toggle with (5))");
break;
case 1000:
compressionLabel.setText("Current compression: jpg (toggle with (5))");
break;
case 1001:
compressionLabel.setText("Current compression: j2k (toggle with (5))");
break;
default:
compressionLabel.setText("Current compression: jp2 (toggle with (5))");
}
}

/**
* @brief ZoomAndMultiresWidget::orthogonalSpinBoxChanged zooms in and out of ortho viewports with constant step.
* @param value increment/decrement zoom by value
Expand Down
6 changes: 5 additions & 1 deletion widgets/zoomandmultireswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*/

#include <QDialog>
#include <QLabel>

class QLabel;
class QDoubleSpinBox;
class QCheckBox;
class QPushButton;
Expand All @@ -50,14 +50,18 @@ public slots:
void update();
void loadSettings();
void saveSettings();
void updateCompressionRatioDisplay();
protected:
/*! Necessary helper variables to enable relative (instead of constant) incrementation/decrementation of zoom spin boxes.
* Zoom steps become smaller with higher zoom levels and vice versa (smoother impression to the user).
* See the spinBoxChanged slots for more details. */
float lastZoomSkel;
bool userZoomSkel;

// compression section
QLabel compressionLabel;
// top layout
QLabel zoomSectionLabel{"Zoom Settings"};
QLabel *orthogonalDataViewportLabel;
QLabel *skeletonViewportLabel;
QDoubleSpinBox *orthogonalDataViewportSpinBox;
Expand Down

0 comments on commit 96db29c

Please sign in to comment.