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
63b770da
Commit
63b770da
authored
Mar 16, 2021
by
daniel.bub
Browse files
Merge remote-tracking branch 'origin/sprint_5' into top2021s5/#83_unittest_WMCsvConverter
parents
ac1a46ba
e89d27e8
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
188 additions
and
19 deletions
+188
-19
src/core/common/WPropertyHelper.cpp
src/core/common/WPropertyHelper.cpp
+10
-0
src/core/common/WPropertyHelper.h
src/core/common/WPropertyHelper.h
+14
-0
src/core/common/constraints/WPropertyConstraintConfirmOverwrite.cpp
...ommon/constraints/WPropertyConstraintConfirmOverwrite.cpp
+27
-0
src/core/common/constraints/WPropertyConstraintConfirmOverwrite.h
.../common/constraints/WPropertyConstraintConfirmOverwrite.h
+105
-0
src/core/common/constraints/WPropertyConstraintTypes.h
src/core/common/constraints/WPropertyConstraintTypes.h
+2
-1
src/core/dataHandler/WDataSetPointsAndFibers.h
src/core/dataHandler/WDataSetPointsAndFibers.h
+2
-3
src/core/dataHandler/test/WDataSetCSV_test.h
src/core/dataHandler/test/WDataSetCSV_test.h
+3
-1
src/modules/filterProtonData/WMFilterProtonData.cpp
src/modules/filterProtonData/WMFilterProtonData.cpp
+5
-0
src/modules/filterProtonData/WProtonData.cpp
src/modules/filterProtonData/WProtonData.cpp
+5
-3
src/modules/filterProtonData/propertyHandler/WColumnPropertyHandler.cpp
...lterProtonData/propertyHandler/WColumnPropertyHandler.cpp
+1
-3
src/modules/filterProtonData/propertyHandler/WFilterPropertyHandler.cpp
...lterProtonData/propertyHandler/WFilterPropertyHandler.cpp
+2
-0
src/modules/filterProtonData/test/WProtonData_test.h
src/modules/filterProtonData/test/WProtonData_test.h
+3
-3
src/modules/writeProtonCSV/WMWriteCSV.cpp
src/modules/writeProtonCSV/WMWriteCSV.cpp
+3
-2
src/qtgui/controlPanel/WPropertyFilenameWidget.cpp
src/qtgui/controlPanel/WPropertyFilenameWidget.cpp
+6
-3
No files found.
src/core/common/WPropertyHelper.cpp
View file @
63b770da
...
...
@@ -80,6 +80,16 @@ namespace WPropertyHelper
}
}
namespace
PC_CONFIRMOVERWRITE
{
void
addTo
(
WPropFilename
prop
)
{
prop
->
addConstraint
(
boost
::
shared_ptr
<
WPropertyConstraintConfirmOverwrite
<
WPVBaseTypes
::
PV_PATH
>
>
(
new
WPropertyConstraintConfirmOverwrite
<
WPVBaseTypes
::
PV_PATH
>
()
)
);
}
}
namespace
PC_ISVALID
{
void
addTo
(
WPropSelection
prop
)
...
...
src/core/common/WPropertyHelper.h
View file @
63b770da
...
...
@@ -34,6 +34,7 @@
#include "constraints/WPropertyConstraintIsDirectory.h"
#include "constraints/WPropertyConstraintSelectOnlyOne.h"
#include "constraints/WPropertyConstraintIsValid.h"
#include "constraints/WPropertyConstraintConfirmOverwrite.h"
/**
...
...
@@ -107,6 +108,19 @@ namespace WPropertyHelper
void
addTo
(
WPropFilename
prop
);
}
/**
* Contains functions for easily adding contraints of type PC_CONFIRMOVERWRITE to properties compatible with this constraint.
*/
namespace
PC_CONFIRMOVERWRITE
{
/**
* Add the PC_CONFIRMOVERWRITE constraint to the property.
*
* \param prop the property where to add the constraint.
*/
void
addTo
(
WPropFilename
prop
);
}
/**
* Contains functions for easily adding constraints of type PC_ISVALID to properties compatible with this constraint.
*/
...
...
src/core/common/constraints/WPropertyConstraintConfirmOverwrite.cpp
0 → 100644
View file @
63b770da
//---------------------------------------------------------------------------
//
// 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 "WPropertyConstraintConfirmOverwrite.h"
#include "../WPropertyVariable.h"
src/core/common/constraints/WPropertyConstraintConfirmOverwrite.h
0 → 100644
View file @
63b770da
//---------------------------------------------------------------------------
//
// 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 WPROPERTYCONSTRAINTCONFIRMOVERWRITE_H
#define WPROPERTYCONSTRAINTCONFIRMOVERWRITE_H
#include "../WPropertyTypes.h"
#include "WPropertyConstraintTypes.h"
/**
* This class allows constraining properties to be existing filenames. This is especially useful for WPropFilename.
*/
template
<
typename
T
>
class
WPropertyConstraintConfirmOverwrite
:
public
WPropertyVariable
<
T
>::
PropertyConstraint
{
public:
/**
* Constructor.
*/
WPropertyConstraintConfirmOverwrite
();
/**
* Destructor.
*/
virtual
~
WPropertyConstraintConfirmOverwrite
();
/**
* Checks whether the specified value is a directory or not.
*
* \param property the property whose new value should be set.
* \param value the new value to check
*
* \return true if the file/path is a directory
*/
virtual
bool
accept
(
boost
::
shared_ptr
<
WPropertyVariable
<
T
>
>
property
,
const
T
&
value
);
/**
* Allows simple identification of the real constraint type.
*
* \return the type
*/
virtual
PROPERTYCONSTRAINT_TYPE
getType
();
/**
* Method to clone the constraint and create a new one with the correct dynamic type.
*
* \return the constraint.
*/
virtual
boost
::
shared_ptr
<
typename
WPropertyVariable
<
T
>::
PropertyConstraint
>
clone
();
private:
};
template
<
typename
T
>
WPropertyConstraintConfirmOverwrite
<
T
>::
WPropertyConstraintConfirmOverwrite
()
{
}
template
<
typename
T
>
WPropertyConstraintConfirmOverwrite
<
T
>::~
WPropertyConstraintConfirmOverwrite
()
{
}
template
<
typename
T
>
bool
WPropertyConstraintConfirmOverwrite
<
T
>::
accept
(
boost
::
shared_ptr
<
WPropertyVariable
<
T
>
>
/* property */
,
const
T
&
/* value */
)
{
return
true
;
}
template
<
typename
T
>
PROPERTYCONSTRAINT_TYPE
WPropertyConstraintConfirmOverwrite
<
T
>::
getType
()
{
return
PC_CONFIRMOVERWRITE
;
}
template
<
typename
T
>
boost
::
shared_ptr
<
typename
WPropertyVariable
<
T
>::
PropertyConstraint
>
WPropertyConstraintConfirmOverwrite
<
T
>::
clone
()
{
return
boost
::
shared_ptr
<
typename
WPropertyVariable
<
T
>::
PropertyConstraint
>
(
new
WPropertyConstraintConfirmOverwrite
<
T
>
(
*
this
)
);
}
#endif // WPROPERTYCONSTRAINTCONFIRMOVERWRITE_H
src/core/common/constraints/WPropertyConstraintTypes.h
View file @
63b770da
...
...
@@ -39,7 +39,8 @@ typedef enum
PC_ISDIRECTORY
,
// type ID for WPropertyConstraintIsDirectory
PC_SELECTONLYONE
,
// type ID for WPropertyConstraintSelectOnlyOne
PC_SELECTATLEASTONE
,
// type ID for WPropertyConstraintSelectAtLeastOne
PC_ISVALID
// type ID for WPropertyConstraintIsValid
PC_ISVALID
,
// type ID for WPropertyConstraintIsValid
PC_CONFIRMOVERWRITE
// type ID for WPropertyConstraintConfirmOverwrite
}
PROPERTYCONSTRAINT_TYPE
;
...
...
src/core/dataHandler/WDataSetPointsAndFibers.h
View file @
63b770da
...
...
@@ -33,7 +33,7 @@
/**
* Dataset to store a bunch of points and Fibers.
*/
class
WDataSetPointsAndFibers
:
public
WDataSet
class
WDataSetPointsAndFibers
:
public
WDataSet
{
public:
/**
...
...
@@ -78,7 +78,6 @@ private:
* Dataset to store a bunch of Fibers.
*/
WDataSetFibers
::
SPtr
m_fibers
;
};
#endif // WDATASETPOINTSANDFIBERS_H
\ No newline at end of file
#endif // WDATASETPOINTSANDFIBERS_H
src/core/dataHandler/test/WDataSetCSV_test.h
View file @
63b770da
...
...
@@ -25,6 +25,9 @@
#ifndef WDATASETCSV_TEST_H
#define WDATASETCSV_TEST_H
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <cxxtest/TestSuite.h>
...
...
@@ -101,7 +104,6 @@ public:
{
TS_ASSERT_EQUALS
(
csvDataSet
.
getData
(),
m_data
);
}
};
#endif // WDATASETCSV_TEST_H
src/modules/filterProtonData/WMFilterProtonData.cpp
View file @
63b770da
...
...
@@ -78,6 +78,9 @@ void WMFilterProtonData::moduleMain()
continue
;
}
boost
::
shared_ptr
<
WProgress
>
progressBar
(
new
WProgress
(
"Preparing..."
)
);
m_progress
->
addSubProgress
(
progressBar
);
if
(
m_protonData
==
NULL
)
{
m_protonData
=
WProtonData
::
SPtr
(
new
WProtonData
(
m_input
->
getData
()
->
getHeader
(),
m_input
->
getData
()
->
getData
()
)
);
...
...
@@ -114,6 +117,8 @@ void WMFilterProtonData::moduleMain()
setToLoadedProperties
();
setOutputFromCSV
(
);
progressBar
->
finish
();
}
}
...
...
src/modules/filterProtonData/WProtonData.cpp
View file @
63b770da
...
...
@@ -80,17 +80,19 @@ WDataSetCSV::ContentSPtr WProtonData::getCSVHeader()
void
WProtonData
::
setStateIndex
(
std
::
string
columnName
,
int
index
)
{
m_ColumnMapSelectedIndex
[
columnName
]
=
index
;
//0 is not accepted as an index because it is the default value if no map has been created. (index + 1)
m_ColumnMapSelectedIndex
[
columnName
]
=
index
+
1
;
}
bool
WProtonData
::
isColumnAvailable
(
std
::
string
columnName
)
{
return
m_ColumnMapSelectedIndex
[
columnName
]
>
=
0
;
return
m_ColumnMapSelectedIndex
[
columnName
]
>
0
;
}
int
WProtonData
::
getColumnIndexBySelection
(
std
::
string
selectedName
)
{
return
m_ColumnMapSelectedIndex
[
selectedName
];
//to get the original index value, have to calculate minus 1
return
m_ColumnMapSelectedIndex
[
selectedName
]
-
1
;
}
int
WProtonData
::
getColumnIndex
(
std
::
string
columnName
)
...
...
src/modules/filterProtonData/propertyHandler/WColumnPropertyHandler.cpp
View file @
63b770da
...
...
@@ -137,9 +137,7 @@ void WColumnPropertyHandler::propertyNotifier( WPropertyBase::SPtr property )
{
std
::
string
selectedValue
=
selector
->
at
(
0
)
->
getAs
<
ItemType
>
()
->
getValue
();
m_protonData
->
setStateIndex
(
columnName
,
getColumnNumberByName
(
selectedValue
)
);
m_protonData
->
setStateIndex
(
columnName
,
getColumnNumberByName
(
selectedValue
)
);
m_dataUpdate
();
if
(
m_externEventMethod
!=
NULL
)
...
...
src/modules/filterProtonData/propertyHandler/WFilterPropertyHandler.cpp
View file @
63b770da
...
...
@@ -67,6 +67,7 @@ void WFilterPropertyHandler::updateProperty()
if
(
m_protonData
->
isColumnAvailable
(
WSingleSelectorName
::
getPDG
()
)
)
{
updatePDGProperties
();
m_multiSelection
->
setHidden
(
false
);
m_filteringsubGroup
->
setHidden
(
false
);
}
...
...
@@ -228,6 +229,7 @@ bool WFilterPropertyHandler::isPDGTypeSelected( int pdgType )
return
true
;
}
}
return
false
;
}
...
...
src/modules/filterProtonData/test/WProtonData_test.h
View file @
63b770da
...
...
@@ -22,8 +22,8 @@
//
//---------------------------------------------------------------------------
#ifndef W
M
PROTONDATA_TEST_H
#define W
M
PROTONDATA_TEST_H
#ifndef WPROTONDATA_TEST_H
#define WPROTONDATA_TEST_H
#include <string>
#include <vector>
...
...
@@ -155,4 +155,4 @@ public:
}
};
#endif // W
M
PROTONDATA_TEST_H
#endif // WPROTONDATA_TEST_H
src/modules/writeProtonCSV/WMWriteCSV.cpp
View file @
63b770da
...
...
@@ -107,6 +107,7 @@ void WMWriteCSV::properties()
&
WMWriteCSV
::
propertyCallback
,
this
);
m_filename
=
m_properties
->
addProperty
(
"Filename"
,
"Filename where to write the NIfTI file to."
,
WPathHelper
::
getHomePath
(),
notifier
);
WPropertyHelper
::
PC_CONFIRMOVERWRITE
::
addTo
(
m_filename
);
WModule
::
properties
();
}
...
...
@@ -194,7 +195,7 @@ std::list< std::tuple < int, int > > WMWriteCSV::getListOfPositionAndID(
}
}
if
(
listOfInternalVertex
.
size
()
<=
0
)
if
(
listOfInternalVertex
.
size
()
<=
0
)
{
break
;
}
...
...
@@ -210,7 +211,7 @@ void WMWriteCSV::writeToFile()
std
::
string
sourceFilename
=
m_filename
->
get
().
string
();
sourceFilename
=
sourceFilename
.
substr
(
0
,
sourceFilename
.
find
(
".csv"
)
);
std
::
string
outputFilename
=
sourceFilename
+
"
-edited
.csv"
;
std
::
string
outputFilename
=
sourceFilename
+
".csv"
;
WDataSetCSV
::
SeperatedRowSPtr
csvContent
=
m_CSVInput
->
getData
()
->
getRawDataSet
();
WDataSetFibers
::
SPtr
fibers
=
m_PointsAndFibersInput
->
getData
()
->
getFibers
();
...
...
src/qtgui/controlPanel/WPropertyFilenameWidget.cpp
View file @
63b770da
...
...
@@ -84,6 +84,9 @@ void WPropertyFilenameWidget::buttonReleased()
{
QString
path
;
QFileDialog
::
Option
options
=
m_fnProperty
->
countConstraint
(
PC_CONFIRMOVERWRITE
)
!=
0
?
(
QFileDialog
::
Option
)
0
:
QFileDialog
::
DontConfirmOverwrite
;
// if there is a "IsDirectory" constraint -> set a special option in the dialog
if
(
m_fnProperty
->
countConstraint
(
PC_ISDIRECTORY
)
!=
0
)
{
...
...
@@ -91,21 +94,21 @@ void WPropertyFilenameWidget::buttonReleased()
path
=
QFileDialog
::
getExistingDirectory
(
this
,
QString
::
fromStdString
(
"Select directory for "
+
m_fnProperty
->
getName
()
),
QString
::
fromStdString
(
m_fnProperty
->
get
().
string
()
),
QFileDialog
::
DontConfirmOverwrite
);
options
);
}
else
if
(
m_fnProperty
->
countConstraint
(
PC_PATHEXISTS
)
!=
0
)
{
path
=
QFileDialog
::
getOpenFileName
(
this
,
QString
::
fromStdString
(
"Select existing file for "
+
m_fnProperty
->
getName
()
),
QString
::
fromStdString
(
m_fnProperty
->
get
().
string
()
),
QString
(),
0
,
QFileDialog
::
DontConfirmOverwrite
);
options
);
}
else
{
path
=
QFileDialog
::
getSaveFileName
(
this
,
QString
::
fromStdString
(
"Select file for "
+
m_fnProperty
->
getName
()
),
QString
::
fromStdString
(
m_fnProperty
->
get
().
string
()
),
QString
(),
0
,
QFileDialog
::
DontConfirmOverwrite
);
options
);
}
// convert it back to a filename property
...
...
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