Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CAMP
campvis-public
Commits
7ea361ff
Commit
7ea361ff
authored
Jan 21, 2014
by
Christian Schulte zu Berge
Browse files
Merge remote-tracking branch 'remotes/origin/dev-mahmud' into development
parents
2ef42d4e
d7513b42
Changes
10
Hide whitespace changes
Inline
Side-by-side
application/CMakeLists.txt
View file @
7ea361ff
...
...
@@ -31,6 +31,7 @@ SET(CampvisApplicationToBeMocced
gui/mainwindow.h
gui/datacontainerinspectorcanvas.h
gui/datacontainerinspectorwidget.h
gui/datacontainerfileloaderwidget.h
gui/datacontainertreewidget.h
gui/pipelinetreewidget.h
gui/qtcolortools.h
...
...
application/gui/datacontainerfileloaderwidget.cpp
0 → 100644
View file @
7ea361ff
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "datacontainerfileloaderwidget.h"
namespace
campvis
{
const
std
::
string
DataContainerFileLoaderWidget
::
loggerCat_
=
"CAMPVis.application.DataContainerFileLoaderWidget"
;
DataContainerFileLoaderWidget
::
DataContainerFileLoaderWidget
(
DataContainerInspectorWidget
*
parentDataInspector
,
QWidget
*
parent
)
:
QWidget
(
parent
)
,
_dataContainer
(
0
)
,
_layout
(
0
)
,
_pipelinePropertiesScrollArea
(
0
)
,
_propCollectionWidget
(
0
)
,
_fileName
(
"fileName"
,
"Image URL"
,
""
)
{
this
->
_parent
=
parentDataInspector
;
this
->
_dataContainer
=
this
->
_parent
->
getDataContainer
();
this
->
_imgReader
=
new
GenericImageReader
();
this
->
_imgReader
->
setVisibibility
(
".mhd"
,
true
);
setupGUI
();
}
DataContainerFileLoaderWidget
::~
DataContainerFileLoaderWidget
()
{
if
(
this
->
_dataContainer
!=
0
)
{
this
->
_dataContainer
->
s_dataAdded
.
disconnect
(
this
);
}
}
void
DataContainerFileLoaderWidget
::
setDataContainer
(
DataContainer
*
dataContainer
)
{
this
->
_dataContainer
=
dataContainer
;
}
QSize
DataContainerFileLoaderWidget
::
sizeHint
()
const
{
return
QSize
(
300
,
350
);
}
void
DataContainerFileLoaderWidget
::
setupGUI
()
{
setWindowTitle
(
tr
(
"Browse File"
));
this
->
_layout
=
new
QGridLayout
();
this
->
_layout
->
setSpacing
(
2
);
setLayout
(
_layout
);
this
->
_pipelinePropertiesScrollArea
=
new
QScrollArea
(
this
);
this
->
_pipelinePropertiesScrollArea
->
setWidgetResizable
(
true
);
this
->
_pipelinePropertiesScrollArea
->
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
this
->
_pipelinePropertiesScrollArea
->
setFrameStyle
(
QScrollArea
::
NoFrame
);
this
->
installEventFilter
(
this
);
this
->
_propCollectionWidget
=
new
PropertyCollectionWidget
(
this
->
_pipelinePropertiesScrollArea
);
this
->
_layout
->
addWidget
(
this
->
_propCollectionWidget
,
0
,
0
,
1
,
2
);
this
->
_propCollectionWidget
->
updatePropCollection
(
this
->
_imgReader
,
this
->
_dataContainer
);
this
->
_btnLoadFile
=
new
QPushButton
(
tr
(
"Load"
),
this
);
this
->
_layout
->
addWidget
(
this
->
_btnLoadFile
,
1
,
0
,
1
,
1
);
this
->
_btnCancel
=
new
QPushButton
(
tr
(
"Cancel"
),
this
);
this
->
_layout
->
addWidget
(
this
->
_btnCancel
,
1
,
1
,
1
,
1
);
qRegisterMetaType
<
QtDataHandle
>
(
"QtDataHandle"
);
connect
(
this
->
_btnCancel
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBtnCancelClicked
()));
connect
(
this
->
_btnLoadFile
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBtnLoadFileClicked
()));
}
void
DataContainerFileLoaderWidget
::
init
()
{
}
void
DataContainerFileLoaderWidget
::
deinit
()
{
delete
_imgReader
;
this
->
_imgReader
=
nullptr
;
}
void
DataContainerFileLoaderWidget
::
onBtnCancelClicked
()
{
delete
_imgReader
;
this
->
_imgReader
=
nullptr
;
this
->
close
();
}
void
DataContainerFileLoaderWidget
::
onBtnLoadFileClicked
()
{
this
->
_imgReader
->
process
(
*
_dataContainer
);
this
->
_parent
->
setDataContainer
(
_dataContainer
);
this
->
close
();
}
}
\ No newline at end of file
application/gui/datacontainerfileloaderwidget.h
0 → 100644
View file @
7ea361ff
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef DATACONTAINERFILELOADERWIDGET_H
#define DATACONTAINERFILELOADERWIDGET_H
#include "sigslot/sigslot.h"
#include "application/gui/properties/propertycollectionwidget.h"
#include "modules/io/processors/genericimagereader.h"
#include "application/gui/datacontainerinspectorwidget.h"
#include <QScrollArea>
#include <QGridLayout>
#include <QPushButton>
namespace
campvis
{
class
DataContainerFileLoaderWidget
:
public
QWidget
,
public
sigslot
::
has_slots
<>
{
Q_OBJECT
;
public:
/**
* Creates a new DataContainerFileLoaderWidget.
* \param treeModel Parent DataContainerInspectorWidget. Method Overridden to keep the widget floating.
* \param parent Parent Qt widget, may be 0 (default)
*/
explicit
DataContainerFileLoaderWidget
(
DataContainerInspectorWidget
*
treeModel
,
QWidget
*
parent
=
nullptr
);
/**
* Destructor.
*/
~
DataContainerFileLoaderWidget
();
/**
* Set the DataContainer this widget is inspecting.
* \param dataContainer The DataContainer this widget shall inspect, may be 0.
*/
void
setDataContainer
(
DataContainer
*
dataContainer
);
/**
* Size hint for the default window size
* \return QSize(300, 350)
*/
QSize
sizeHint
()
const
;
/**
* Initializes the OpenGL stuff (e.g. shaders).
* Must be called with a valid and locked OpenGL context.
*/
virtual
void
init
();
/**
* Deinitializes the OpenGL stuff (e.g. shaders).
* Must be called with a valid and locked OpenGL context.
*/
void
deinit
();
private
slots
:
/**
* Slot being called when the user clicks on the "Cancel" button.
*/
void
onBtnCancelClicked
();
/**
* Slot being called when the user clicks on the "Load File" button.
*/
void
onBtnLoadFileClicked
();
protected:
/**
* Setup the GUI stuff
*/
void
setupGUI
();
protected:
DataContainer
*
_dataContainer
;
///< The DataContainer this widget is inspecting
QGridLayout
*
_layout
;
///< Layout for the _infoWidget
QScrollArea
*
_pipelinePropertiesScrollArea
;
///< Scroll area for _pipelinePropertiesWidget
protected:
QPushButton
*
_btnCancel
;
QPushButton
*
_btnLoadFile
;
StringProperty
_fileName
;
PropertyCollectionWidget
*
_propCollectionWidget
;
///< Widget for browsing the PropertyCollection of the selected pipeline/processor
GenericImageReader
*
_imgReader
;
DataContainerInspectorWidget
*
_parent
;
static
const
std
::
string
loggerCat_
;
private:
};
}
#endif // DATACONTAINERFILELOADERWIDGET_H
application/gui/datacontainerinspectorwidget.cpp
View file @
7ea361ff
...
...
@@ -53,6 +53,8 @@
#include "application/gui/datacontainertreewidget.h"
#include "application/gui/qtdatahandle.h"
#include "application//gui/datacontainerfileloaderwidget.h"
#include "modules/io/processors/genericimagereader.h"
#include <QFileDialog>
...
...
@@ -70,6 +72,7 @@ namespace campvis {
,
_mainLayout
(
0
)
,
_infoWidget
(
0
)
,
_infoWidgetLayout
(
0
)
,
_propEditorWid
(
0
)
{
setupGUI
();
}
...
...
@@ -94,6 +97,10 @@ namespace campvis {
}
}
DataContainer
*
DataContainerInspectorWidget
::
getDataContainer
()
{
return
_dataContainer
;
}
void
DataContainerInspectorWidget
::
onDataContainerDataAdded
(
const
std
::
string
&
key
,
const
DataHandle
&
dh
)
{
// copy QtDataHandle because signal will be handled by a different thread an indefinite amount of time later:
emit
dataContainerChanged
(
QString
::
fromStdString
(
key
),
QtDataHandle
(
dh
));
...
...
@@ -160,8 +167,25 @@ namespace campvis {
_lblBounds
=
new
QLabel
(
tr
(
"World Bounds:"
),
_infoWidget
);
_infoWidgetLayout
->
addWidget
(
_lblBounds
);
QWidget
*
btnWidget
=
new
QWidget
(
this
);
QGridLayout
*
gridLayout
=
new
QGridLayout
();
btnWidget
->
setLayout
(
gridLayout
);
#ifdef CAMPVIS_HAS_MODULE_DEVIL
_btnSaveToFile
=
new
QPushButton
(
tr
(
"Save to File"
),
_infoWidget
);
_infoWidgetLayout
->
addWidget
(
_btnSaveToFile
);
gridLayout
->
addWidget
(
_btnSaveToFile
,
0
,
0
);
connect
(
_btnSaveToFile
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBtnSaveToFileClicked
()));
_btnSaveToFile
->
setDisabled
(
true
);
#endif
_btnLoadFile
=
new
QPushButton
(
tr
(
"Load File"
),
_infoWidget
);
gridLayout
->
addWidget
(
_btnLoadFile
,
0
,
1
);
_infoWidgetLayout
->
addWidget
(
btnWidget
);
_canvas
=
new
DataContainerInspectorCanvas
(
_infoWidget
);
_canvas
->
setMinimumSize
(
QSize
(
100
,
100
));
...
...
@@ -184,8 +208,8 @@ namespace campvis {
this
,
SIGNAL
(
dataContainerChanged
(
const
QString
&
,
QtDataHandle
)),
_dctWidget
->
getTreeModel
(),
SLOT
(
onDataContainerChanged
(
const
QString
&
,
QtDataHandle
)));
connect
(
_btn
SaveTo
File
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBtn
SaveTo
FileClicked
()));
_btn
Load
File
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBtn
Load
FileClicked
()));
}
void
DataContainerInspectorWidget
::
updateColor
(){
...
...
@@ -342,10 +366,25 @@ namespace campvis {
_dataContainer
=
0
;
_dctWidget
->
update
(
0
);
if
(
_propEditorWid
!=
nullptr
)
_propEditorWid
->
deinit
();
}
void
DataContainerInspectorWidget
::
onDCTWidgetSelectionModelSelectionChanged
(
const
QItemSelection
&
selected
,
const
QItemSelection
&
deselected
)
{
updateInfoWidget
();
// get the selection from the tree widget
const
QModelIndexList
&
indices
=
_dctWidget
->
selectionModel
()
->
selectedRows
();
// iterate through the indices of the selection
for
(
QModelIndexList
::
const_iterator
index
=
indices
.
begin
();
index
!=
indices
.
end
();
++
index
)
{
if
(
index
->
isValid
())
{
_btnSaveToFile
->
setDisabled
(
false
);
return
;
}
}
_btnSaveToFile
->
setDisabled
(
true
);
}
void
DataContainerInspectorWidget
::
onBtnSaveToFileClicked
()
{
...
...
@@ -442,4 +481,15 @@ namespace campvis {
}
void
DataContainerInspectorWidget
::
onBtnLoadFileClicked
()
{
// delete previous PropertyEditor, then create a new one
// the final one will be deleted with deinit()
if
(
nullptr
!=
_propEditorWid
)
_propEditorWid
->
deinit
();
_propEditorWid
=
new
DataContainerFileLoaderWidget
(
this
,
nullptr
);
_propEditorWid
->
setVisible
(
true
);
}
}
\ No newline at end of file
application/gui/datacontainerinspectorwidget.h
View file @
7ea361ff
...
...
@@ -57,6 +57,7 @@ namespace campvis {
class
DataContainer
;
class
DataContainerTreeWidget
;
class
FaceGeometry
;
class
DataContainerFileLoaderWidget
;
class
DataContainerInspectorWidget
:
public
QWidget
,
public
sigslot
::
has_slots
<>
{
Q_OBJECT
;
...
...
@@ -72,13 +73,18 @@ namespace campvis {
* Destructor.
*/
~
DataContainerInspectorWidget
();
/**
* Set the DataContainer this widget is inspecting.
* \param dataContainer The DataContainer this widget shall inspect, may be 0.
*/
void
setDataContainer
(
DataContainer
*
dataContainer
);
/**
* Get the DataContainer this widget is inspecting.
*/
DataContainer
*
getDataContainer
();
/**
* Slot called when _dataContainer has changed and emitted the s_dataAdded signal.
*/
...
...
@@ -111,7 +117,7 @@ namespace campvis {
*/
void
updateColor
();
/**
/**
* Updates depth of the info widget
*/
void
updateDepth
();
...
...
@@ -133,6 +139,12 @@ namespace campvis {
*/
void
onBtnSaveToFileClicked
();
/**
* Slot being called when the user clicks on the "Load File" button.
*/
void
onBtnLoadFileClicked
();
protected:
/**
* Setup the GUI stuff
...
...
@@ -147,7 +159,7 @@ namespace campvis {
*/
protected:
protected:
static
void
saveToFile
(
DataHandle
handle
,
std
::
string
filename
);
/**
...
...
@@ -173,19 +185,24 @@ namespace campvis {
QHBoxLayout
*
_mainLayout
;
///< Layout for this widget
QWidget
*
_infoWidget
;
///< Widget showing the information about the selected QtDataHandle
QVBoxLayout
*
_infoWidgetLayout
;
///< Layout for the _infoWidget
QLabel
*
_lblName
;
QLabel
*
_lblLocalMemoryFootprint
;
QLabel
*
_lblVideoMemoryFootprint
;
QLabel
*
_lblTimestamp
;
QLabel
*
_lblSize
;
QLabel
*
_lblBounds
;
QWidget
*
_colorWidget
;
///< The widget use to show the color value and the color in a single window
QWidget
*
_colorWidget
;
///< The widget use to show the color value and the color in a single window
QHBoxLayout
*
_colorWidgetLayout
;
///< Layout for the following widget
QLabel
*
_lblColorVal
;
///< Color Label Value in text
QWidget
*
_colorValWidget
;
///< Widget that shows the color value in color
QPalette
*
_ColorValWidgetPalette
;
///< Palette which will be used to colorize the color widget
QPushButton
*
_btnSaveToFile
;
// Added by Hossain Mahmud <mahmud@in.tum.de>
// Date: January 02, 2014
QPushButton
*
_btnLoadFile
;
DataContainerFileLoaderWidget
*
_propEditorWid
;
static
const
std
::
string
loggerCat_
;
};
...
...
application/gui/properties/stringpropertywidget.cpp
View file @
7ea361ff
...
...
@@ -41,7 +41,7 @@ namespace campvis {
addWidget
(
_lineEdit
);
if
(
!
dynamic_cast
<
DataNameProperty
*>
(
property
))
{
_btnLoadFile
=
new
QPushButton
(
tr
(
"
Load Fil
e"
),
this
);
_btnLoadFile
=
new
QPushButton
(
tr
(
"
Brows
e"
),
this
);
addWidget
(
_btnLoadFile
);
connect
(
_btnLoadFile
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
onBtnLoadFileClicked
(
bool
)));
}
...
...
@@ -52,6 +52,9 @@ namespace campvis {
StringPropertyWidget
::~
StringPropertyWidget
()
{
}
void
StringPropertyWidget
::
setButtonLabel
(
const
std
::
string
&
btnLabel
)
{
this
->
_btnLoadFile
->
setText
(
QString
(
btnLabel
.
c_str
()));
}
void
StringPropertyWidget
::
updateWidgetFromProperty
()
{
StringProperty
*
prop
=
static_cast
<
StringProperty
*>
(
_property
);
...
...
application/gui/properties/stringpropertywidget.h
View file @
7ea361ff
...
...
@@ -51,6 +51,8 @@ namespace campvis {
*/
virtual
~
StringPropertyWidget
();
void
setButtonLabel
(
const
std
::
string
&
btnLabel
);
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
...
...
modules/io/processors/abstractimagereader.h
View file @
7ea361ff
...
...
@@ -73,7 +73,7 @@ namespace campvis {
virtual
void
setTargetImageIdSharedProperty
(
DataNameProperty
*
sharedProperty
);
public:
StringProperty
p_url
;
///< URL for file to read
StringProperty
p_url
;
///< URL for file to read
DataNameProperty
p_targetImageID
;
///< image ID for read image
protected:
...
...
modules/io/processors/genericimagereader.cpp
View file @
7ea361ff
...
...
@@ -45,12 +45,16 @@ namespace campvis {
:
AbstractProcessor
()
,
p_url
(
"url"
,
"Image URL"
,
""
)
{
addProperty
(
&
p_url
);
p_url
.
s_changed
.
connect
(
this
,
&
GenericImageReader
::
onUrlPropertyChanged
);
this
->
addReader
(
new
CsvdImageReader
());
this
->
addReader
(
new
LtfImageReader
());
this
->
addReader
(
new
MhdImageReader
());
this
->
addReader
(
new
RawImageReader
());
this
->
addReader
(
new
VtkImageReader
());
this
->
_ext
=
""
;
this
->
_currentlyVisible
=
nullptr
;
}
...
...
@@ -70,13 +74,28 @@ namespace campvis {
}
void
GenericImageReader
::
updateResult
(
DataContainer
&
data
)
{
std
::
map
<
AbstractImageReader
*
,
MetaProperty
*>::
iterator
it
=
std
::
find_if
(
this
->
_readers
.
begin
(),
this
->
_readers
.
end
(),
checkExt
(
this
->
_ext
));
if
(
it
!=
this
->
_readers
.
end
())
{
if
(
this
->
_currentlyVisible
!=
it
->
second
)
{
if
(
nullptr
!=
this
->
_currentlyVisible
)
{
this
->
_currentlyVisible
->
setVisible
(
false
);
}
(
it
->
second
)
->
setVisible
(
true
);
this
->
_currentlyVisible
=
it
->
second
;
}
(
it
->
first
)
->
process
(
data
);
}
return
;
}
void
GenericImageReader
::
setVisibibility
(
const
std
::
string
&
extention
,
bool
visibility
)
{
std
::
string
_ext
=
extention
;
std
::
map
<
AbstractImageReader
*
,
MetaProperty
*>::
iterator
it
=
std
::
find_if
(
this
->
_readers
.
begin
(),
this
->
_readers
.
end
(),
checkExt
(
_ext
));
if
(
it
!=
this
->
_readers
.
end
())
{
if
(
nullptr
!=
this
->
_currentlyVisible
)
{
this
->
_currentlyVisible
->
setVisible
(
false
);
this
->
_currentlyVisible
->
setVisible
(
!
visibility
);
}
(
it
->
second
)
->
setVisible
(
true
);
(
it
->
second
)
->
setVisible
(
visibility
);
this
->
_currentlyVisible
=
it
->
second
;
(
it
->
first
)
->
process
(
data
);
//
(it->first)->process(data);
}
return
;
}
...
...
@@ -139,9 +158,38 @@ namespace campvis {
MetaProperty
*
meta
=
new
MetaProperty
(
reader
->
getName
()
+
"MetaProp"
,
reader
->
getName
());
meta
->
addPropertyCollection
(
*
reader
);
meta
->
setVisible
(
false
);
StringProperty
*
sp
=
dynamic_cast
<
StringProperty
*>
(
meta
->
getProperty
(
"url"
));
tgtAssert
(
sp
!=
0
,
"This should not happen."
);
if
(
sp
!=
0
)
{
p_url
.
addSharedProperty
(
sp
);
sp
->
setVisible
(
false
);
}
this
->
addProperty
(
meta
);
this
->
_readers
.
insert
(
std
::
pair
<
AbstractImageReader
*
,
MetaProperty
*>
(
reader
,
meta
));
return
0
;
}
void
GenericImageReader
::
onUrlPropertyChanged
(
const
AbstractProperty
*
)
{
// first set visibility of old extension to false
setVisibibility
(
_ext
,
false
);
// now update extension
const
std
::
string
&
url
=
this
->
p_url
.
getValue
();
size_t
extPos
=
url
.
rfind
(
'.'
);
if
(
extPos
!=
std
::
string
::
npos
)
{
this
->
_ext
=
url
.
substr
(
extPos
);
}
// set visibility of new extension's properties to true
setVisibibility
(
_ext
,
true
);
}
void
GenericImageReader
::
adjustToNewExtension
()
{
}
}
\ No newline at end of file
modules/io/processors/genericimagereader.h
View file @
7ea361ff
...
...
@@ -85,6 +85,11 @@ namespace campvis {
void
setTargetImageId
(
const
char
*
imageId
);
void
setTargetImageIdSharedProperty
(
DataNameProperty
*
sharedProperty
);
void
setVisibibility
(
const
std
::
string
&
extention
,
bool
visibility
);
StringProperty
p_url
;
protected:
/// \see AbstractProcessor::updateResult
virtual
void
updateResult
(
DataContainer
&
dataContainer
);
...
...
@@ -92,8 +97,11 @@ namespace campvis {
static
const
std
::
string
loggerCat_
;
private:
void
onUrlPropertyChanged
(
const
AbstractProperty
*
);
void
adjustToNewExtension
();
std
::
map
<
AbstractImageReader
*
,
MetaProperty
*>
_readers
;
StringProperty
p_url
;
std
::
string
_ext
;
MetaProperty
*
_currentlyVisible
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment