Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
73ee0ba2
Commit
73ee0ba2
authored
May 04, 2010
by
ledig
Browse files
[ADD] gui for walnut.cfg, small tut will follow
parent
7c657e28
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1963 additions
and
16 deletions
+1963
-16
src/common/WPropertyVariable.h
src/common/WPropertyVariable.h
+28
-9
src/gui/qt4/CMakeLists.txt
src/gui/qt4/CMakeLists.txt
+1
-0
src/gui/qt4/WCfgOperations.cpp
src/gui/qt4/WCfgOperations.cpp
+378
-0
src/gui/qt4/WCfgOperations.h
src/gui/qt4/WCfgOperations.h
+77
-0
src/gui/qt4/WMainWindow.cpp
src/gui/qt4/WMainWindow.cpp
+23
-0
src/gui/qt4/WMainWindow.h
src/gui/qt4/WMainWindow.h
+7
-0
src/gui/qt4/WQtConfigWidget.cpp
src/gui/qt4/WQtConfigWidget.cpp
+1265
-0
src/gui/qt4/WQtConfigWidget.h
src/gui/qt4/WQtConfigWidget.h
+137
-0
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp
+21
-3
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
src/gui/qt4/datasetbrowser/WQtDSBWidget.h
+1
-1
src/kernel/WModuleFactory.cpp
src/kernel/WModuleFactory.cpp
+5
-0
src/kernel/WModuleFactory.h
src/kernel/WModuleFactory.h
+10
-1
src/modules/hud/WMHud.cpp
src/modules/hud/WMHud.cpp
+10
-2
No files found.
src/common/WPropertyVariable.h
View file @
73ee0ba2
...
...
@@ -184,6 +184,21 @@ public:
static
boost
::
shared_ptr
<
PropertyConstraint
>
create
(
PROPERTYCONSTRAINT_TYPE
type
);
};
/**
* The Container datatype to copy the constraints
*/
typedef
std
::
set
<
boost
::
shared_ptr
<
PropertyConstraint
>
>
constraintContainer
;
/**
* A set of constraints applied on this property.
*/
constraintContainer
m_constraints
;
/**
* The iterator used to go through the set
*/
typedef
typename
constraintContainer
::
const_iterator
constraintIterator
;
/**
* Alias for min constraints. It is an alias for convenience.
*/
...
...
@@ -211,6 +226,13 @@ public:
*/
boost
::
shared_ptr
<
PropertyConstraint
>
addConstraint
(
PROPERTYCONSTRAINT_TYPE
constraint
);
/**
* Returns all the current constraints of a WPropertyVariable for copy purpose
*
* \return the condition.
*/
constraintContainer
getConstraints
();
/**
* Gets the condition, which gets notified whenever the list of constraints changes. It is notified AFTER the write lock has been released so
* a read lock can be acquired in the callback.
...
...
@@ -317,15 +339,6 @@ protected:
*/
virtual
void
updateType
();
/**
* A set of constraints applied on this property.
*/
std
::
set
<
boost
::
shared_ptr
<
PropertyConstraint
>
>
m_constraints
;
/**
* The iterator used to go through the set
*/
typedef
typename
std
::
set
<
boost
::
shared_ptr
<
PropertyConstraint
>
>::
const_iterator
constraintIterator
;
/**
* boost mutex object for thread safety of updating of m_propertyConstraints.
...
...
@@ -356,6 +369,12 @@ protected:
private:
};
template
<
typename
T
>
typename
WPropertyVariable
<
T
>::
constraintContainer
WPropertyVariable
<
T
>::
getConstraints
()
{
return
m_constraints
;
}
template
<
typename
T
>
WPropertyVariable
<
T
>::
WPropertyVariable
(
std
::
string
name
,
std
::
string
description
,
const
T
&
initial
)
:
WFlag
<
T
>
(
new
WCondition
(),
initial
),
...
...
src/gui/qt4/CMakeLists.txt
View file @
73ee0ba2
...
...
@@ -12,6 +12,7 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
# add here all classes that inherit from QObject
SET
(
GUI_QT4_MOC_HDRS
WMainWindow.h
WQtConfigWidget.h
WQtNavGLWidget.h
guiElements/WQtPushButton.h
guiElements/WQtApplyModulePushButton.h
...
...
src/gui/qt4/WCfgOperations.cpp
0 → 100644
View file @
73ee0ba2
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <Qt/qstring.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "../../common/WStringUtils.h"
#include "WCfgOperations.h"
std
::
vector
<
std
::
string
>
WCfgOperations
::
readCfg
(
const
std
::
string
fileName
)
{
std
::
ifstream
ifs
(
fileName
.
c_str
(),
std
::
ifstream
::
in
);
std
::
vector
<
std
::
string
>
lines
;
std
::
string
line
;
while
(
!
ifs
.
eof
()
)
{
getline
(
ifs
,
line
);
lines
.
push_back
(
std
::
string
(
line
)
);
}
ifs
.
close
();
return
lines
;
}
void
WCfgOperations
::
writeCfg
(
const
std
::
string
fileName
,
const
std
::
vector
<
std
::
string
>
lines
)
{
std
::
ofstream
ofs
(
fileName
.
c_str
(),
std
::
ofstream
::
out
);
std
::
stringstream
mendl
;
mendl
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
lines
.
size
();
++
i
)
{
ofs
<<
lines
[
i
];
// if there is no newline character add it
if
(
(
lines
[
i
]).
find
(
mendl
.
str
()
)
==
std
::
string
::
npos
)
{
ofs
<<
std
::
endl
;
}
}
ofs
.
close
();
}
bool
WCfgOperations
::
isComment
(
const
std
::
string
line
)
{
if
(
line
.
length
()
==
0
)
{
return
false
;
}
return
string_utils
::
lTrim
(
line
)[
0
]
==
'#'
;
}
bool
WCfgOperations
::
isAssignment
(
const
std
::
string
line
)
{
if
(
line
.
length
()
==
0
)
{
return
false
;
}
// a comment is never an Assignment
if
(
isComment
(
line
)
)
{
return
false
;
}
// no equals sign means no assignment
if
(
line
.
find
(
'='
)
==
std
::
string
::
npos
)
{
return
false
;
}
// left and right from equals there has to be at least one none whitespace char
bool
hasLeftChar
=
false
;
bool
hasRightChar
=
false
;
std
::
string
toTest
=
removeComment
(
line
);
size_t
p
=
toTest
.
find
(
'='
);
size_t
i
;
for
(
i
=
0
;
i
<
p
-
1
;
++
i
)
{
if
(
toTest
[
i
]
!=
' '
)
{
hasLeftChar
=
true
;
}
}
for
(
i
=
p
+
1
;
i
<
toTest
.
length
();
++
i
)
{
if
(
toTest
[
i
]
!=
' '
)
{
hasRightChar
=
true
;
}
}
return
hasLeftChar
&&
hasRightChar
;
}
std
::
string
WCfgOperations
::
removeComment
(
const
std
::
string
line
)
{
std
::
string
lineWithoutComment
=
line
;
size_t
p
=
lineWithoutComment
.
find
(
'#'
);
if
(
p
==
std
::
string
::
npos
)
{
return
lineWithoutComment
;
}
lineWithoutComment
.
erase
(
p
,
lineWithoutComment
.
length
()
-
p
);
return
lineWithoutComment
;
}
void
WCfgOperations
::
getAssignementComponents
(
const
std
::
string
line
,
std
::
string
*
left
,
std
::
string
*
right
)
{
if
(
!
isAssignment
(
line
)
)
{
return
;
}
size_t
p
=
line
.
find
(
'='
);
(
*
left
)
=
removeComment
(
line
);
left
->
erase
(
p
,
left
->
length
()
-
p
);
(
*
left
)
=
string_utils
::
trim
(
*
left
);
(
*
right
)
=
removeComment
(
line
);
right
->
erase
(
0
,
p
+
1
);
(
*
right
)
=
string_utils
::
trim
(
*
right
);
}
bool
WCfgOperations
::
isCommentedAssignment
(
const
std
::
string
line
)
{
std
::
string
toTest
=
line
;
if
(
!
isComment
(
line
)
)
{
return
false
;
}
while
(
isComment
(
toTest
)
)
{
toTest
=
string_utils
::
lTrim
(
toTest
,
"#"
);
}
return
isAssignment
(
toTest
);
}
bool
WCfgOperations
::
isSection
(
const
std
::
string
line
)
{
bool
res
=
false
;
size_t
leftB
=
line
.
find
(
'['
);
size_t
rightB
=
line
.
find
(
']'
);
size_t
comment
=
line
.
find
(
'#'
);
if
(
leftB
!=
std
::
string
::
npos
&&
rightB
!=
std
::
string
::
npos
&&
leftB
<
rightB
&&
(
comment
==
std
::
string
::
npos
||
rightB
<
comment
)
)
{
res
=
true
;
}
return
res
;
}
std
::
string
WCfgOperations
::
getSectionName
(
const
std
::
string
line
)
{
std
::
string
res
=
line
;
if
(
isSection
(
res
)
)
{
size_t
leftB
=
res
.
find
(
'['
);
res
.
erase
(
0
,
leftB
+
1
);
size_t
rightB
=
res
.
find
(
']'
);
res
.
erase
(
rightB
,
res
.
length
()
-
rightB
);
}
else
{
res
=
std
::
string
(
""
);
}
return
res
;
}
std
::
string
WCfgOperations
::
uncommentLine
(
const
std
::
string
line
)
{
std
::
string
res
=
line
;
if
(
!
isComment
(
res
)
)
{
return
res
;
}
while
(
res
.
length
()
>
0
&&
(
res
[
0
]
==
'#'
||
res
[
0
]
==
'\t'
||
res
[
0
]
==
' '
)
)
{
res
.
erase
(
0
,
1
);
}
return
res
;
}
bool
WCfgOperations
::
isBool
(
const
std
::
string
line
)
{
bool
res
=
false
;
if
(
line
==
std
::
string
(
"yes"
)
||
line
==
std
::
string
(
"no"
)
)
{
res
=
true
;
}
return
res
;
}
bool
WCfgOperations
::
getAsBool
(
const
std
::
string
line
)
{
bool
res
=
false
;
if
(
line
==
std
::
string
(
"yes"
)
)
{
res
=
true
;
}
return
res
;
}
bool
WCfgOperations
::
isInt
(
const
std
::
string
line
)
{
bool
res
=
false
;
QString
l2
=
QString
::
fromStdString
(
line
);
l2
.
toInt
(
&
res
);
return
res
;
}
int
WCfgOperations
::
getAsInt
(
const
std
::
string
line
)
{
bool
ok
=
false
;
QString
l2
=
QString
::
fromStdString
(
line
);
int
res
=
l2
.
toInt
(
&
ok
);
if
(
!
ok
)
{
res
=
0
;
}
return
res
;
}
bool
WCfgOperations
::
isDouble
(
const
std
::
string
line
)
{
bool
res
=
false
;
QString
l2
=
QString
::
fromStdString
(
line
);
l2
.
toDouble
(
&
res
);
return
res
;
}
double
WCfgOperations
::
getAsDouble
(
const
std
::
string
line
)
{
bool
ok
=
false
;
QString
l2
=
QString
::
fromStdString
(
line
);
double
res
=
l2
.
toDouble
(
&
ok
);
if
(
!
ok
)
{
res
=
0.0
;
}
return
res
;
}
bool
WCfgOperations
::
isString
(
const
std
::
string
line
)
{
bool
res
=
false
;
if
(
line
.
length
()
>
1
&&
line
[
0
]
==
'\"'
&&
line
[
line
.
length
()
-
1
]
==
'\"'
)
{
res
=
true
;
}
return
res
;
}
std
::
string
WCfgOperations
::
getAsString
(
const
std
::
string
line
)
{
std
::
string
res
=
line
;
if
(
!
isString
(
line
)
)
{
return
std
::
string
(
""
);
}
res
.
erase
(
0
,
1
);
res
.
erase
(
res
.
length
()
-
1
,
1
);
return
res
;
}
std
::
string
WCfgOperations
::
getPropValAsString
(
boost
::
shared_ptr
<
WProperties
>
prop
)
{
std
::
string
result
=
""
;
switch
(
prop
->
getType
()
)
{
case
PV_STRING
:
{
result
=
"
\"
"
+
prop
->
toPropString
()
->
get
()
+
"
\"
"
;
break
;
}
case
PV_BOOL
:
{
if
(
prop
->
toPropBool
()
->
get
()
==
true
)
{
result
=
"yes"
;
}
else
{
result
=
"no"
;
}
break
;
}
case
PV_DOUBLE
:
{
result
=
boost
::
lexical_cast
<
std
::
string
>
(
prop
->
toPropDouble
()
->
get
()
);
// make sure to only have a max of 2 digits after the dot, and if there is only a 0 before the
// dot to delete that
if
(
result
[
0
]
==
'0'
&&
result
.
find
(
'.'
)
==
1
)
{
result
.
erase
(
0
,
1
);
}
size_t
digitsAfterDot
;
size_t
dotPos
=
result
.
find
(
'.'
);
if
(
dotPos
!=
std
::
string
::
npos
)
{
digitsAfterDot
=
result
.
length
()
-
dotPos
+
1
;
if
(
digitsAfterDot
>
2
)
{
result
.
erase
(
dotPos
+
3
,
result
.
length
()
-
dotPos
-
2
);
}
}
// also remove the last zeros if they are not directly after the dot
if
(
result
.
length
()
>
2
)
// at least a dot and and digit
{
while
(
result
[
result
.
length
()
-
1
]
==
'0'
)
{
dotPos
=
result
.
find
(
'.'
);
if
(
dotPos
+
2
<
result
.
length
()
)
{
result
.
erase
(
result
.
length
()
-
1
,
1
);
}
else
{
break
;
}
}
}
break
;
}
case
PV_INT
:
{
result
=
boost
::
lexical_cast
<
std
::
string
>
(
prop
->
toPropInt
()
->
get
()
);
break
;
}
default:
{
result
=
""
;
break
;
}
}
return
result
;
}
src/gui/qt4/WCfgOperations.h
0 → 100644
View file @
73ee0ba2
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WCFGOPERATIONS_H
#define WCFGOPERATIONS_H
#include <string>
#include <vector>
#include "../../common/WProperties.h"
class
WCfgOperations
{
public:
static
std
::
vector
<
std
::
string
>
readCfg
(
const
std
::
string
fileName
);
static
void
writeCfg
(
const
std
::
string
fileName
,
const
std
::
vector
<
std
::
string
>
lines
);
// determines if a line is a comment
static
bool
isComment
(
const
std
::
string
line
);
static
bool
isAssignment
(
const
std
::
string
line
);
static
std
::
string
removeComment
(
const
std
::
string
line
);
static
void
getAssignementComponents
(
const
std
::
string
line
,
std
::
string
*
left
,
std
::
string
*
right
);
static
bool
isCommentedAssignment
(
const
std
::
string
line
);
static
bool
isSection
(
const
std
::
string
line
);
static
std
::
string
getSectionName
(
const
std
::
string
line
);
static
std
::
string
uncommentLine
(
const
std
::
string
line
);
static
bool
isBool
(
const
std
::
string
line
);
static
bool
getAsBool
(
const
std
::
string
line
);
static
bool
isInt
(
const
std
::
string
line
);
static
int
getAsInt
(
const
std
::
string
line
);
static
bool
isDouble
(
const
std
::
string
line
);
static
double
getAsDouble
(
const
std
::
string
line
);
static
bool
isString
(
const
std
::
string
line
);
static
std
::
string
getAsString
(
const
std
::
string
line
);
static
std
::
string
getPropValAsString
(
boost
::
shared_ptr
<
WProperties
>
prop
);
private:
};
#endif // WCFGOPERATIONS_H
src/gui/qt4/WMainWindow.cpp
View file @
73ee0ba2
...
...
@@ -94,6 +94,7 @@ void WMainWindow::setupGUI()
m_menuBar
=
new
QMenuBar
(
this
);
QMenu
*
fileMenu
=
m_menuBar
->
addMenu
(
"File"
);
fileMenu
->
addAction
(
m_iconManager
.
getIcon
(
"load"
),
"Load"
,
this
,
SLOT
(
openLoadDialog
()
),
QKeySequence
(
"Ctrl+L"
)
);
fileMenu
->
addAction
(
"Config"
,
this
,
SLOT
(
openConfigDialog
()
),
QKeySequence
(
"Ctrl+C"
)
);
fileMenu
->
addAction
(
m_iconManager
.
getIcon
(
"quit"
),
"Quit"
,
this
,
SLOT
(
close
()
),
QKeySequence
(
"Ctrl+Q"
)
);
QMenu
*
helpMenu
=
m_menuBar
->
addMenu
(
"Help"
);
...
...
@@ -152,6 +153,19 @@ void WMainWindow::setupGUI()
{
bgColor
.
setRGB
(
r
,
g
,
b
);
m_mainGLWidget
->
setBgColor
(
bgColor
);
if
(
m_navAxial
)
{
m_navAxial
->
getGLWidget
()
->
setBgColor
(
bgColor
);
}
if
(
m_navCoronal
)
{
m_navCoronal
->
getGLWidget
()
->
setBgColor
(
bgColor
);
}
if
(
m_navSagittal
)
{
m_navSagittal
->
getGLWidget
()
->
setBgColor
(
bgColor
);
}
}
}
...
...
@@ -749,3 +763,12 @@ void WMainWindow::setFibersLoaded()
{
m_fibLoaded
=
true
;
}
void
WMainWindow
::
openConfigDialog
()
{
// boost::shared_ptr< WQtConfigWidget > configWidget = boost::shared_ptr< WQtConfigWidget >( new WQtConfigWidget );
// WQtConfigWidget *configWidget = new WQtConfigWidget;
m_configWidget
=
boost
::
shared_ptr
<
WQtConfigWidget
>
(
new
WQtConfigWidget
);
m_configWidget
->
initAndShow
();
}
src/gui/qt4/WMainWindow.h
View file @
73ee0ba2
...
...
@@ -41,6 +41,7 @@
#include <QtGui/QCloseEvent>
#include "WQtNavGLWidget.h"
#include "WQtConfigWidget.h"
#include "ribbonMenu/WQtRibbonMenu.h"
#include "WQtCustomDockWidget.h"
#include "WQtToolBar.h"
...
...
@@ -206,6 +207,10 @@ public slots:
*/
void
setFibersLoaded
();
/**
* gets called when menu option or toolbar button load is activated
*/
void
openConfigDialog
();
private:
/**
* Sets up the permanent tool bar.
...
...
@@ -235,6 +240,8 @@ private:
boost
::
shared_ptr
<
WQtNavGLWidget
>
m_navSagittal
;
//!< the sgittal view widget GL widget of the GUI
QDockWidget
*
m_dummyWidget
;
//!< The dummywidget serves as spacer in the dockwidget area;
boost
::
shared_ptr
<
WQtConfigWidget
>
m_configWidget
;
bool
m_fibLoaded
;
//!< Indicates whether a fiber data set is already loaded.
/**
...
...
src/gui/qt4/WQtConfigWidget.cpp
0 → 100644
View file @
73ee0ba2
This diff is collapsed.
Click to expand it.
src/gui/qt4/WQtConfigWidget.h
0 → 100644
View file @
73ee0ba2
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the