Commit 63b770da authored by daniel.bub's avatar daniel.bub
Browse files

Merge remote-tracking branch 'origin/sprint_5' into top2021s5/#83_unittest_WMCsvConverter

parents ac1a46ba e89d27e8
......@@ -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 )
......
......@@ -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.
*/
......
//---------------------------------------------------------------------------
//
// 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"
//---------------------------------------------------------------------------
//
// 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
......@@ -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;
......
......@@ -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
......@@ -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
......@@ -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();
}
}
......
......@@ -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 )
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -22,8 +22,8 @@
//
//---------------------------------------------------------------------------
#ifndef WMPROTONDATA_TEST_H
#define WMPROTONDATA_TEST_H
#ifndef WPROTONDATA_TEST_H
#define WPROTONDATA_TEST_H
#include <string>
#include <vector>
......@@ -155,4 +155,4 @@ public:
}
};
#endif // WMPROTONDATA_TEST_H
#endif // WPROTONDATA_TEST_H
......@@ -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();
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment