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
8d52cfe2
Commit
8d52cfe2
authored
Mar 18, 2021
by
daniel.bub
Browse files
[ADD
#132
] add multiple types for column property
parent
ed245f90
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
37 deletions
+60
-37
src/modules/filterProtonData/WDataType.cpp
src/modules/filterProtonData/WDataType.cpp
+1
-1
src/modules/filterProtonData/WProtonData.cpp
src/modules/filterProtonData/WProtonData.cpp
+15
-8
src/modules/filterProtonData/WProtonData.h
src/modules/filterProtonData/WProtonData.h
+2
-1
src/modules/filterProtonData/WSingleSelectorName.cpp
src/modules/filterProtonData/WSingleSelectorName.cpp
+28
-7
src/modules/filterProtonData/WSingleSelectorName.h
src/modules/filterProtonData/WSingleSelectorName.h
+1
-1
src/modules/filterProtonData/propertyHandler/WColumnPropertyHandler.cpp
...lterProtonData/propertyHandler/WColumnPropertyHandler.cpp
+9
-15
src/modules/filterProtonData/propertyHandler/WColumnPropertyHandler.h
...filterProtonData/propertyHandler/WColumnPropertyHandler.h
+4
-4
No files found.
src/modules/filterProtonData/WDataType.cpp
View file @
8d52cfe2
...
...
@@ -44,4 +44,4 @@ std::string WDataType::getString()
std
::
string
WDataType
::
getDefault
()
{
return
"default"
;
}
\ No newline at end of file
}
src/modules/filterProtonData/WProtonData.cpp
View file @
8d52cfe2
...
...
@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <regex>
#include <list>
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
...
...
@@ -155,14 +156,17 @@ std::string WProtonData::determineColumnTypeByString( std::string cellValue )
if
(
std
::
regex_search
(
cellValue
,
regexInt
)
)
{
std
::
cout
<<
cellValue
<<
"
\t
INT"
<<
std
::
endl
;
return
WDataType
::
getInt
();
}
else
if
(
std
::
regex_search
(
cellValue
,
regexDouble
)
)
{
std
::
cout
<<
cellValue
<<
"
\t
DOUBLE"
<<
std
::
endl
;
return
WDataType
::
getDouble
();
}
else
{
std
::
cout
<<
cellValue
<<
"
\t
STRING"
<<
std
::
endl
;
return
WDataType
::
getString
();
}
}
...
...
@@ -186,22 +190,25 @@ bool WProtonData::checkIfDoubleColumnCanBeInteger( int columnNumber )
return
true
;
}
std
::
vector
<
std
::
string
>
WProtonData
::
getHeaderFromType
(
std
::
string
typeName
)
std
::
vector
<
std
::
string
>
WProtonData
::
getHeaderFromType
(
std
::
list
<
std
::
string
>
typeName
s
)
{
std
::
vector
<
std
::
string
>
header
=
m_csvHeader
->
at
(
0
);
std
::
vector
<
std
::
string
>
columnTypes
=
*
m_columnTypes
;
std
::
vector
<
std
::
string
>
filterHeader
;
if
(
typeName
==
WDataType
::
getDefault
()
)
{
return
header
;
}
for
(
size_t
i
=
0
;
i
<
columnTypes
.
size
();
i
++
)
{
if
(
columnTypes
[
i
]
==
typeName
)
for
(
std
::
string
type
:
typeName
s
)
{
filterHeader
.
push_back
(
header
[
i
]
);
if
(
type
==
WDataType
::
getDefault
()
)
{
return
header
;
}
if
(
columnTypes
[
i
]
==
type
)
{
filterHeader
.
push_back
(
header
[
i
]
);
}
}
}
...
...
src/modules/filterProtonData/WProtonData.h
View file @
8d52cfe2
...
...
@@ -26,6 +26,7 @@
#define WPROTONDATA_H
#include <regex>
#include <list>
#include <map>
#include <string>
#include <vector>
...
...
@@ -128,7 +129,7 @@ public:
* \param type Type of filter
* \return Return a vector of filtered Headers
*/
std
::
vector
<
std
::
string
>
getHeaderFromType
(
std
::
string
typeName
);
std
::
vector
<
std
::
string
>
getHeaderFromType
(
std
::
list
<
std
::
string
>
typeName
s
);
private:
/**
...
...
src/modules/filterProtonData/WSingleSelectorName.cpp
View file @
8d52cfe2
...
...
@@ -69,7 +69,10 @@ WSingleSelectorName::NameDescriptionSearchTyp WSingleSelectorName::getXwithDescr
getX
(),
"Choose the column which should be used to determine the x coordinate."
,
"posX"
,
WDataType
::
getDouble
()
);
std
::
list
<
std
::
string
>
{
WDataType
::
getInt
(),
WDataType
::
getDouble
()
}
);
}
WSingleSelectorName
::
NameDescriptionSearchTyp
WSingleSelectorName
::
getYwithDescription
()
...
...
@@ -78,7 +81,10 @@ WSingleSelectorName::NameDescriptionSearchTyp WSingleSelectorName::getYwithDescr
getY
(),
"Choose the column which should be used to determine the y coordinate."
,
"posY"
,
WDataType
::
getDouble
()
);
std
::
list
<
std
::
string
>
{
WDataType
::
getInt
(),
WDataType
::
getDouble
()
}
);
}
WSingleSelectorName
::
NameDescriptionSearchTyp
WSingleSelectorName
::
getZwithDescription
()
...
...
@@ -87,7 +93,10 @@ WSingleSelectorName::NameDescriptionSearchTyp WSingleSelectorName::getZwithDescr
getZ
(),
"Choose the column which should be used to determine the z coordinate."
,
"posZ"
,
WDataType
::
getDefault
()
);
std
::
list
<
std
::
string
>
{
WDataType
::
getInt
(),
WDataType
::
getDouble
()
}
);
}
WSingleSelectorName
::
NameDescriptionSearchTyp
WSingleSelectorName
::
getPDGwithDescription
()
...
...
@@ -96,7 +105,10 @@ WSingleSelectorName::NameDescriptionSearchTyp WSingleSelectorName::getPDGwithDes
getPDG
(),
"Choose the column which should be used to determine the particle data group."
,
"PDGEncoding"
,
WDataType
::
getInt
()
);
std
::
list
<
std
::
string
>
{
WDataType
::
getInt
()
}
);
}
WSingleSelectorName
::
NameDescriptionSearchTyp
WSingleSelectorName
::
getEdepWithDescription
()
...
...
@@ -105,7 +117,10 @@ WSingleSelectorName::NameDescriptionSearchTyp WSingleSelectorName::getEdepWithDe
getEdep
(),
"Choose the column which should be used to determine the energy deposition."
,
"edep"
,
WDataType
::
getDouble
()
);
std
::
list
<
std
::
string
>
{
WDataType
::
getInt
(),
WDataType
::
getDouble
()
}
);
}
WSingleSelectorName
::
NameDescriptionSearchTyp
WSingleSelectorName
::
getEventIdWithDescription
()
...
...
@@ -115,7 +130,10 @@ WSingleSelectorName::NameDescriptionSearchTyp WSingleSelectorName::getEventIdWit
"Choose the column which should be used to determine the event id."
"Tracks will be drawn based on the the event id, all particles with the same event id will be connected."
,
"eventID"
,
WDataType
::
getInt
()
);
std
::
list
<
std
::
string
>
{
WDataType
::
getInt
()
}
);
}
WSingleSelectorName
::
NameDescriptionSearchTyp
WSingleSelectorName
::
getParentIdWithDescription
()
...
...
@@ -126,7 +144,10 @@ WSingleSelectorName::NameDescriptionSearchTyp WSingleSelectorName::getParentIdWi
"Primaries and secondaries filtering is based on that id, if a "
"particle has the parent id 0 it is a primary otherwise it is a secondary."
,
"parentID"
,
WDataType
::
getInt
()
);
std
::
list
<
std
::
string
>
{
WDataType
::
getInt
()
}
);
}
std
::
list
<
WSingleSelectorName
::
NameDescriptionSearchTyp
>
WSingleSelectorName
::
getListOfSelectorContent
()
...
...
src/modules/filterProtonData/WSingleSelectorName.h
View file @
8d52cfe2
...
...
@@ -44,7 +44,7 @@ public:
* 2. Desciption of single-selector,
* 3. Value that is searched for in the csv header
*/
typedef
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
string
>
NameDescriptionSearchTyp
;
typedef
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
list
<
std
::
string
>
>
NameDescriptionSearchTyp
;
/**
* getter
...
...
src/modules/filterProtonData/propertyHandler/WColumnPropertyHandler.cpp
View file @
8d52cfe2
...
...
@@ -46,8 +46,8 @@ void WColumnPropertyHandler::createProperties()
m_columnSelectionGroup
=
m_properties
->
addPropertyGroup
(
"Select columns"
,
"Select the columns which should be used"
);
std
::
list
<
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
string
>
>
names
=
WSingleSelectorName
::
getListOfSelectorContent
();
for
(
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
string
>
selectorElement
:
names
)
std
::
list
<
WColumnPropertyHandler
::
NameDescriptionSearchTyp
>
names
=
WSingleSelectorName
::
getListOfSelectorContent
();
for
(
WColumnPropertyHandler
::
NameDescriptionSearchTyp
selectorElement
:
names
)
{
std
::
string
columnName
=
std
::
get
<
0
>
(
selectorElement
);
...
...
@@ -66,11 +66,11 @@ void WColumnPropertyHandler::updateProperty()
{
}
boost
::
shared_ptr
<
WItemSelection
>
WColumnPropertyHandler
::
I
nitializeSelectionItem
(
std
::
string
typeName
)
boost
::
shared_ptr
<
WItemSelection
>
WColumnPropertyHandler
::
i
nitializeSelectionItem
(
std
::
list
<
std
::
string
>
typeName
s
)
{
boost
::
shared_ptr
<
WItemSelection
>
possibleSelectionsUsingTypes
=
WItemSelection
::
SPtr
(
new
WItemSelection
()
);
std
::
vector
<
std
::
string
>
header
=
m_protonData
->
getHeaderFromType
(
typeName
);
std
::
vector
<
std
::
string
>
header
=
m_protonData
->
getHeaderFromType
(
typeName
s
);
for
(
std
::
vector
<
std
::
string
>::
iterator
colName
=
header
.
begin
();
colName
!=
header
.
end
();
colName
++
)
{
...
...
@@ -82,7 +82,7 @@ boost::shared_ptr< WItemSelection > WColumnPropertyHandler::InitializeSelectionI
return
possibleSelectionsUsingTypes
;
}
int
WColumnPropertyHandler
::
get
f
ilterIndex
(
int
index
,
std
::
string
typeName
)
int
WColumnPropertyHandler
::
get
F
ilterIndex
(
int
index
,
std
::
list
<
std
::
string
>
typeName
)
{
std
::
vector
<
std
::
string
>
headerToSearch
=
m_protonData
->
getCSVHeader
()
->
at
(
0
);
...
...
@@ -110,23 +110,17 @@ WPropSelection WColumnPropertyHandler::addHeaderProperty( WColumnPropertyHandler
std
::
string
columnName
=
std
::
get
<
0
>
(
ndst
);
std
::
string
description
=
std
::
get
<
1
>
(
ndst
);
std
::
string
defName
=
std
::
get
<
2
>
(
ndst
);
std
::
string
type
=
std
::
get
<
3
>
(
ndst
);
std
::
list
<
std
::
string
>
type
=
std
::
get
<
3
>
(
ndst
);
int
index
=
m_protonData
->
getColumnIndex
(
defName
);
int
indexSingleSelector
=
index
<
0
?
-
1
:
getfilterIndex
(
index
,
type
);
if
(
indexSingleSelector
<
0
)
{
indexSingleSelector
=
index
;
type
=
WDataType
::
getDefault
();
}
int
indexSingleSelector
=
index
<
0
?
-
1
:
getFilterIndex
(
index
,
type
);
m_protonData
->
setStateIndex
(
columnName
,
index
);
boost
::
shared_ptr
<
WItemSelection
>
possibleSelectionsUsingTypes
=
I
nitializeSelectionItem
(
type
);
boost
::
shared_ptr
<
WItemSelection
>
possibleSelectionsUsingTypes
=
i
nitializeSelectionItem
(
type
);
WItemSelector
selector
=
index
<
0
?
possibleSelectionsUsingTypes
->
getSelectorLast
()
:
WItemSelector
selector
=
index
<
0
?
possibleSelectionsUsingTypes
->
getSelectorLast
()
:
possibleSelectionsUsingTypes
->
getSelector
(
indexSingleSelector
);
WPropSelection
selection
=
m_columnSelectionGroup
->
addProperty
(
...
...
src/modules/filterProtonData/propertyHandler/WColumnPropertyHandler.h
View file @
8d52cfe2
...
...
@@ -53,7 +53,7 @@ public:
* 2. Desciption of single-selector,
* 3. Value that is searched for in the csv header
*/
typedef
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
string
>
NameDescriptionSearchTyp
;
typedef
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
list
<
std
::
string
>
>
NameDescriptionSearchTyp
;
/**
* Function variables for updating the data
...
...
@@ -152,15 +152,15 @@ private:
* \param typeName Type of column.
* \return content of WItemSelection
*/
boost
::
shared_ptr
<
WItemSelection
>
I
nitializeSelectionItem
(
std
::
string
typeName
);
boost
::
shared_ptr
<
WItemSelection
>
i
nitializeSelectionItem
(
std
::
list
<
std
::
string
>
typeName
);
/**
* converts the index to the filtered index
* \param index index to search.
* \param typeName
Type
of column.
* \param typeName
List
of column
types
.
* \return filterd index
*/
int
get
f
ilterIndex
(
int
index
,
std
::
string
typeName
);
int
get
F
ilterIndex
(
int
index
,
std
::
list
<
std
::
string
>
typeName
);
};
#endif // WCOLUMNPROPERTYHANDLER_H
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