Skip to content
Snippets Groups Projects
Commit 9e97d2c3 authored by Lars Bilke's avatar Lars Bilke
Browse files

Filecompares should be working again

git-svn-id: https://svn.ufz.de/svn/ogs/trunk/sources@7043 3895a583-e809-0410-9bb6-aa9463026377
parents
No related branches found
No related tags found
No related merge requests found
Showing
with 1560 additions and 0 deletions
# Source files
set( SOURCES
ColorTableModel.cpp
ColorTableView.cpp
ConditionModel.cpp
DataViewWidget.cpp
DBConnectionDialog.cpp
FEMCondition.cpp
GEOModels.cpp
LinesModel.cpp
LineTabWidget.cpp
DataView.cpp
Model.cpp
MshEditDialog.cpp
MshItem.cpp
MshLayerMapper.cpp
MshModel.cpp
MshTabWidget.cpp
PntsModel.cpp
PntTabWidget.cpp
SHPImportDialog.cpp
StationTabWidget.cpp
SurfaceModel.cpp
SurfaceTabWidget.cpp
VisPrefsDialog.cpp
VisualizationWidget.cpp
)
# Moc Header files
set( MOC_HEADERS
ColorTableModel.h
ColorTableView.h
ConditionModel.h
DataView.h
DataViewWidget.h
DBConnectionDialog.h
GEOModels.h
LinesModel.h
LineTabWidget.h
Model.h
MshEditDialog.h
MshModel.h
MshTabWidget.h
PntsModel.h
PntTabWidget.h
SHPImportDialog.h
StationTabWidget.h
SurfaceModel.h
SurfaceTabWidget.h
VisPrefsDialog.h
VisualizationWidget.h
)
# Header files
set( HEADERS
CondItem.h
FEMCondition.h
MshItem.h
MshLayerMapper.h
)
# UI files
set( UIS
DataViewWidgetBase.ui
DBConnection.ui
LineTabWidgetBase.ui
MshEdit.ui
MshTabWidgetBase.ui
PntTabWidgetBase.ui
StationTabWidgetBase.ui
SurfaceTabWidgetBase.ui
VisPrefs.ui
VisualizationWidgetBase.ui
)
# Run Qts user interface compiler uic on .ui files
qt4_wrap_ui( UI_HEADERS ${UIS} )
# Run Qts meta object compiler moc on header files
qt4_wrap_cpp( MOC_SOURCES ${MOC_HEADERS} )
# Include the headers which are generated by uic and moc
# and include additional header
include_directories(
.
${CMAKE_BINARY_DIR}/Qt/Base
${CMAKE_BINARY_DIR}/Qt/DataView
${CMAKE_BINARY_DIR}/Qt/StationView/DiagramView
${CMAKE_BINARY_DIR}/Qt/StationView
../../Base
../../MathLib
../../GEO
../../MSH
../../FEM
../../FileIO
../Base
../StationView
../StationView/DiagramView
../VtkVis
../VtkAct
${CMAKE_SOURCE_DIR}
${Shapelib_INCLUDE_DIR}
)
if (OGS_COMPILE_QVTK)
include_directories(${CMAKE_BINARY_DIR}/Qt/QVTK ../QVTK)
endif (OGS_COMPILE_QVTK)
IF(VRPN_FOUND)
INCLUDE_DIRECTORIES( ../Vrpn ${VRPN_INCLUDE_DIRS} )
ENDIF()
IF (OGS_USE_OPENSG)
INCLUDE_DIRECTORIES( ${OpenSG_INCLUDE_DIRS} )
ENDIF (OGS_USE_OPENSG)
# Put moc files in a project folder
source_group("UI Files" REGULAR_EXPRESSION "\\w*\\.ui")
source_group("Moc Files" REGULAR_EXPRESSION "moc_.*")
# Create the library
add_library( QtDataView STATIC
${SOURCES}
${HEADERS}
${MOC_HEADERS}
${MOC_SOURCES}
#${UI_HEADERS}
${UIS}
)
# Link Qt library
target_link_libraries( QtDataView
${QT_LIBRARIES}
GEO
FileIO
MSH
QtBase
DiagramView
StationView
${Shapelib_LIBRARIES}
)
/**
* \file ColorTableModel.cpp
* 24/9/2009 LB Initial implementation
* 05/05/2010 KR 2d graphic functionality removed and various layout changes
*
* Implementation of PolylinesModel
*/
#include "ColorTableModel.h"
ColorTableModel::ColorTableModel( const std::map<std::string, GEOLIB::Color*> &colorLookupTable, QObject* parent /*= 0*/ )
{
Q_UNUSED(parent)
this->buildTable(colorLookupTable);
}
ColorTableModel::~ColorTableModel()
{
}
int ColorTableModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const
{
Q_UNUSED(parent)
return 2;
}
QVariant ColorTableModel::headerData( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/ ) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation == Qt::Horizontal)
{
switch (section)
{
case 0: return "Name";
case 1: return "Colour";
default: return QVariant();
}
}
else
return QString("Row %1").arg(section);
}
QVariant ColorTableModel::data( const QModelIndex& index, int role ) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= _listOfPairs.size() || index.row()<0)
return QVariant();
if (role == Qt::DisplayRole)
{
QPair<QString, QColor> pair = _listOfPairs.at(index.row());
switch (index.column())
{
case 0:
return pair.first;
case 1:
return pair.second;
default:
return QVariant();
}
}
return QVariant();
}
bool ColorTableModel::buildTable(const std::map<std::string, GEOLIB::Color*> &colorLookupTable)
{
int count = 0;
beginInsertRows(QModelIndex(), 0, colorLookupTable.size()-1);
for (std::map<std::string, GEOLIB::Color*>::const_iterator it=colorLookupTable.begin(); it !=colorLookupTable.end(); ++it)
{
QColor color((*(it->second))[0], (*(it->second))[1], (*(it->second))[2]);
QString name(QString::fromStdString(it->first));
/* Saudi Arabia strat names *
if (it->first.compare("1")==0) name="Buweib";
if (it->first.compare("2")==0) name="Wasia";
if (it->first.compare("3")==0) name="Aruma";
if (it->first.compare("4")==0) name="Umm Er Radhuma";
if (it->first.compare("5")==0) name="Rus";
if (it->first.compare("6")==0) name="Dammam";
if (it->first.compare("7")==0) name="Neogene";
*/
QPair<QString, QColor> pair(name, color);
_listOfPairs.insert(count++, pair);
}
endInsertRows();
return true;
}
/**
* \file ColorTableModel.h
* 17/06/2010 KR Initial implementation
*/
#ifndef COLORTABLEMODEL_H
#define COLORTABLEMODEL_H
#include <QAbstractTableModel>
#include <QColor>
#include "Color.h"
/**
* The PolylinesModel is a Qt model which represents Polylines.
*/
class ColorTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
ColorTableModel( const std::map<std::string, GEOLIB::Color*> &colorLookupTable, QObject* parent = 0 );
~ColorTableModel();
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data( const QModelIndex& index, int role ) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const
{
Q_UNUSED (parent);
return _listOfPairs.size();
}
QVariant headerData( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/ ) const;
private:
bool buildTable( const std::map<std::string, GEOLIB::Color*> &colorLookupTable );
QList< QPair<QString, QColor> > _listOfPairs;
};
#endif // COLORTABLEMODEL_H
/**
* \file ColorTableView.cpp
* 17/06/2010 KR Initial implementation
*
*/
#include <QHeaderView>
#include <QPainter>
#include "ColorTableView.h"
ColorTableView::ColorTableView( QWidget* parent /*= 0*/ ) : QTableView(parent)
{
this->verticalHeader()->hide();
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->resizeColumnsToContents();
this->resizeRowsToContents();
}
void ColorTableViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QColor val;
if (index.column() == 1)
{
if (qVariantCanConvert<QColor>(index.data()))
{
val = qVariantValue<QColor>(index.data());
QBrush brush(val);
painter->fillRect(option.rect, brush);
}
}
else
QItemDelegate::paint(painter, option, index);
}
QSize ColorTableViewDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
QSize s = QItemDelegate::sizeHint(option, index);
if( s.isValid() ) s.setHeight((int)(0.5*s.height()));
return s;
}
/**
* \file ColorTableView.h
* 17/06/2010 KR Initial implementation
*/
#ifndef COLORTABLEVIEW_H
#define COLORTABLEVIEW_H
#include <QTableView>
#include <QItemDelegate>
/**
* A QTableView to display colour lookup tables.
*/
class ColorTableView : public QTableView
{
Q_OBJECT
public:
/// Constructor
ColorTableView(QWidget* parent = 0);
};
/**
* A delegate class to manage properties of ColorTableView.
*/
class ColorTableViewDelegate : public QItemDelegate
{
Q_OBJECT
public:
/// Constructor
ColorTableViewDelegate(QWidget *parent = 0) : QItemDelegate(parent) {};
/// Overwrites the paint-method to set user-defined properties instead of the default properties.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const;
};
#endif // COLORTABLEVIEW_H
/**
* \file CondItem.h
* 20/10/2010 KR Initial implementation
*/
#ifndef CONDITEM_H
#define CONDITEM_H
#include "TreeItem.h"
#include "VtkPointsSource.h"
/**
* \brief A TreeItem containing conditions of a FEM as well as the vtk object representing these conditions.
* \sa TreeItem
*/
class CondItem : public TreeItem
{
public:
/// Constructor, automatically generates VTK object
CondItem(const QList<QVariant> &data, TreeItem *parent, const std::vector<CSourceTerm*> *sourceterms) : TreeItem(data, parent)
{
(void)sourceterms;
_vtkSource = VtkPointsSource::New();
};
~CondItem() { _vtkSource->Delete(); };
/// Returns the VTK object.
VtkPointsSource* vtkSource() const { return _vtkSource; };
private:
VtkPointsSource* _vtkSource;
};
#endif //CONDITEM_H
/**
* \file ConditionModel.cpp
* 18/10/2010 KR Initial implementation
*/
// ** INCLUDES **
#include "ConditionModel.h"
#include "CondItem.h"
#include "GEOObjects.h"
#include <QFileInfo>
//#include "rf_bc_new.h"
#include "rf_ic_new.h"
#include "rf_st_new.h"
#include "VtkPointsSource.h"
ConditionModel::ConditionModel( ProjectData &project, QObject* parent /*= 0*/ )
: TreeModel(parent), _project(project)
{
QList<QVariant> rootData;
delete _rootItem;
rootData << "FEM Conditions";
_rootItem = new TreeItem(rootData, NULL);
QList<QVariant> bcData;
bcData << "Boundary Conditions";
_bcParent = new TreeItem(bcData, _rootItem);
_rootItem->appendChild(_bcParent);
QList<QVariant> icData;
bcData << "Initial Conditions";
_bcParent = new TreeItem(icData, _rootItem);
_rootItem->appendChild(_icParent);
QList<QVariant> stData;
stData << "Source Terms";
_stParent = new TreeItem(stData, _rootItem);
_rootItem->appendChild(_stParent);
}
ConditionModel::~ConditionModel()
{
}
int ConditionModel::columnCount( const QModelIndex &parent /*= QModelIndex()*/ ) const
{
Q_UNUSED(parent)
return 1;
}
void ConditionModel::addSourceTerms(std::vector<CSourceTerm*> *sourceterms, const QString &name)
{
//std::cout << "name: " << name << std::endl;
QFileInfo fi(name);
QList<QVariant> listData;
listData << fi.baseName();
CondItem* stListItem = new CondItem(listData, _stParent, sourceterms);
_stParent->appendChild(stListItem);
for (size_t i=0; i<sourceterms->size(); i++)
{
QList<QVariant> stData;
stData << QString::fromStdString((*sourceterms)[i]->getGeoTypeAsString());
TreeItem* stItem = new TreeItem(stData, stListItem);
stListItem->appendChild(stItem);
}
if (stListItem->vtkSource())
stListItem->vtkSource()->SetName(fi.fileName());
reset();
//emit meshAdded(this, this->index(_rootItem->childCount()-1, 0, QModelIndex()));
}
const std::vector<CSourceTerm*> *ConditionModel::getSourceTerms(const QModelIndex &idx) const
{
(void)idx;
/*
if (idx.isValid())
{
MshItem* item = static_cast<MshItem*>(this->getItem(idx));
return item->getGrid();
}
std::cout << "MshModel::getMesh() - Specified index does not exist." << std::endl;
*/
return NULL;
}
/*
QVariant ConditionModel::data( const QModelIndex& index, int role ) const
{
if (!index.isValid())
return QVariant();
if ((size_t)index.row() >= _pntVec->size())
return QVariant();
GEOLIB::Point* point = (*_pntVec)[index.row()];
if (point == NULL)
return QVariant();
switch (role)
{
case Qt::DisplayRole:
switch (index.column())
{
case 0:
return index.row();
case 1:
//return (*point)[0];
return QVariant(QString::number((*point)[0],'f'));
case 2:
//return (*point)[1];
return QVariant(QString::number((*point)[1],'f'));
case 3:
//return (*point)[2];
return QVariant(QString::number((*point)[2],'f'));
default:
return QVariant();
}
break;
case Qt::ToolTipRole:
return QString("(%1, %2, %3)").arg((*point)[0]).arg((*point)[1]).arg((*point)[2]);
default:
return QVariant();
}
}
QVariant ConditionModel::headerData( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole* ) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation == Qt::Horizontal)
{
switch (section)
{
case 0: return "Id";
case 1: return "x";
case 2: return "y";
case 3: return "z";
default: return QVariant();
}
}
else
return QString("Row %1").arg(section);
}
void ConditionModel::setData(std::vector<CSourceTerm*> *objects, TreeItem* parent)
{
size_t nObjects = objects->size();
for (int j=0; j<nObjects; j++)
{
QList<QVariant> objData;
(*objects)[j]->
bool pnt = dynamic_cast
pnt << j << QString::number((*(*points)[j])[0],'f') << QString::number((*(*points)[j])[1],'f') << QString::number((*(*points)[j])[2],'f');
TreeItem* child = new TreeItem(pnt, parent);
parent->appendChild(child);
}
reset();
}
bool ConditionModel::setData( const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole* )
{
if (index.isValid() && role == Qt::EditRole)
{
GEOLIB::Point* point = (*_pntVec)[index.row()];
bool wasConversionSuccesfull = false;
double x, y, z;
switch (index.column())
{
case 0:
// id = value.toInt(&wasConversionSuccesfull);
// if (wasConversionSuccesfull)
// point->id = id;
// else
// return false;
// break;
case 1:
x = value.toDouble(&wasConversionSuccesfull);
if (wasConversionSuccesfull)
(*point)[0] = x;
else
return false;
break;
case 2:
y = value.toDouble(&wasConversionSuccesfull);
if (wasConversionSuccesfull)
(*point)[1] = y;
else
return false;
break;
case 3:
z = value.toDouble(&wasConversionSuccesfull);
if (wasConversionSuccesfull)
(*point)[2] = z;
else
return false;
break;
default:
return false;
}
emit dataChanged(index, index);
return true;
}
return false;
}
void ConditionModel::updateData()
{
clearData();
Model::updateData();
}
*/
/**
* \file ConditionModel.h
* 18/10/2010 KR Initial implementation
*/
#ifndef CONDITIONMODEL_H
#define CONDITIONMODEL_H
// ** INCLUDES **
#include "TreeModel.h"
#include "ProjectData.h"
#include <QVector>
class CSourceTerm;
/**
* The ConditionModel handels conditions such as ICs, BCs and STs on geometric objects
*/
class ConditionModel : public TreeModel
{
Q_OBJECT
public:
ConditionModel(ProjectData &project, QObject* parent = 0);
~ConditionModel();
int columnCount(const QModelIndex& parent = QModelIndex()) const;
//QVariant data(const QModelIndex& index, int role) const;
//QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
//bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
public slots:
/// Adds new source terms
void addSourceTerms(std::vector<CSourceTerm*> *sourceterms, const QString &name);
/// Returns the mesh with the given index.
const std::vector<CSourceTerm*> *getSourceTerms(const QModelIndex &idx) const;
/// Reloads all items.
//void updateData();
private:
//void setData(std::vector<GEOLIB::GeoObject*> *points, TreeItem* parent);
ProjectData& _project;
TreeItem* _bcParent;
TreeItem* _icParent;
TreeItem* _stParent;
};
#endif // CONDITIONMODEL_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DBConnectionDialog</class>
<widget class="QDialog" name="DBConnectionDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>388</width>
<height>215</height>
</rect>
</property>
<property name="windowTitle">
<string>Database Connection Settings</string>
</property>
<widget class="QDialogButtonBox" name="dbButtonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>170</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
<widget class="QComboBox" name="driverBox">
<property name="geometry">
<rect>
<x>170</x>
<y>20</y>
<width>201</width>
<height>22</height>
</rect>
</property>
<item>
<property name="text">
<string>QDB2 (IBM DB2)</string>
</property>
</item>
<item>
<property name="text">
<string>QIBASE (Borland Interbase)</string>
</property>
</item>
<item>
<property name="text">
<string>QMYSQL (MySQL)</string>
</property>
</item>
<item>
<property name="text">
<string>QOCI (Oracle Call Interface)</string>
</property>
</item>
<item>
<property name="text">
<string>QODBC (ODBC / MS SQL Server)</string>
</property>
</item>
<item>
<property name="text">
<string>QPSQL (PostgreSQL)</string>
</property>
</item>
<item>
<property name="text">
<string>QSQLITE (SQLite v.3 or above)</string>
</property>
</item>
<item>
<property name="text">
<string>QSQLITE2 (SQLite v.2)</string>
</property>
</item>
<item>
<property name="text">
<string>QTDS (Sybase Adaptive Server)</string>
</property>
</item>
</widget>
<widget class="QLabel" name="driverLine">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Database Driver:</string>
</property>
</widget>
<widget class="QLabel" name="hostnameLabel">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Hostname:</string>
</property>
</widget>
<widget class="QLabel" name="dbnameLabel">
<property name="geometry">
<rect>
<x>20</x>
<y>80</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Database Name:</string>
</property>
</widget>
<widget class="QLabel" name="usernameLabel">
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Username:</string>
</property>
</widget>
<widget class="QLabel" name="passwordLabel">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Password (optional):</string>
</property>
</widget>
<widget class="QLineEdit" name="hostnameLine">
<property name="geometry">
<rect>
<x>170</x>
<y>50</y>
<width>201</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="dbnameLine">
<property name="geometry">
<rect>
<x>170</x>
<y>80</y>
<width>201</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="usernameLine">
<property name="geometry">
<rect>
<x>170</x>
<y>110</y>
<width>201</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="passwordLine">
<property name="geometry">
<rect>
<x>170</x>
<y>140</y>
<width>201</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>dbButtonBox</sender>
<signal>accepted()</signal>
<receiver>DBConnectionDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>dbButtonBox</sender>
<signal>rejected()</signal>
<receiver>DBConnectionDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/**
* \file DBConnectionDialog.cpp
* KR Initial implementation
*/
#include <QSettings>
#include "DBConnectionDialog.h"
/// Constructor
DBConnectionDialog::DBConnectionDialog(QDialog* parent) : QDialog(parent)
{
setupUi(this);
int idx=0;
QSettings settings("UFZ", "OpenGeoSys-5");
if (!settings.value("DBProtocol", "").toString().isEmpty())
{
for (int i=0; i<driverBox->count(); i++)
{
if (driverBox->itemText(i).startsWith(settings.value("DBProtocol", "").toString()))
idx = i;
}
}
driverBox->setCurrentIndex(idx);
hostnameLine->setText(settings.value("DBHost", "").toString());
dbnameLine->setText(settings.value("DBName", "").toString());
usernameLine->setText(settings.value("DBUser", "").toString());
passwordLine->setText(settings.value("DBPass", "").toString());
}
DBConnectionDialog::~DBConnectionDialog()
{
}
/// Instructions if the OK-Button has been pressed.
void DBConnectionDialog::accept()
{
QString protocol = (driverBox->currentText()).left((driverBox->currentText()).indexOf(" "));
QString hostname = hostnameLine->text();
QString dbname = dbnameLine->text();
QString user = usernameLine->text();
QString pass = passwordLine->text();
emit connectionRequested(protocol, hostname, dbname, user, pass);
this->done(QDialog::Accepted);
}
/// Instructions if the Cancel-Button has been pressed.
void DBConnectionDialog::reject()
{
this->done(QDialog::Rejected);
}
/**
* \file DBConnectionDialog.h
* KR Initial implementation
*/
#ifndef DBCONNECTIONDIALOG_H
#define DBCONNECTIONDIALOG_H
#include <QtGui/QMainWindow>
#include <QSqlQueryModel>
#include "ui_DBConnection.h"
/**
* \brief A dialog window for settung up a database connection
*/
class DBConnectionDialog : public QDialog, private Ui_DBConnectionDialog
{
Q_OBJECT
public:
DBConnectionDialog(QDialog* parent = 0);
~DBConnectionDialog(void);
private slots:
void accept();
void reject();
signals:
void connectionRequested(QString, QString, QString, QString, QString);
};
#endif //DBCONNECTIONDIALOG_H
/**
* \file DataView.cpp
* 24/9/2009 LB Initial implementation
*
* Implementation of DataView
*/
#include "DataView.h"
#include <QHeaderView>
DataView::DataView( QWidget* parent /*= 0*/ )
: QTreeView(parent)
{
//verticalHeader()->hide();
//resizeColumnsToContents();
//resizeRowsToContents();
}
void DataView::updateView()
{
setAlternatingRowColors(true);
size_t nColumns = (this->model() != NULL) ? this->model()->columnCount() : 0;
for (size_t i=0; i<nColumns; i++)
resizeColumnToContents(i);
}
/* Selection/Deselection-Functionality -- currently not implemented
QModelIndexList DataView::selectedIndexes() const
{
return QTreeView::selectedIndexes();
}
void DataView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
emit itemSelectionChanged(selected, deselected);
return QTreeView::selectionChanged(selected, deselected);
}
void DataView::selectionChangedFromOutside( const QItemSelection &selected, const QItemSelection &deselected )
{
QItemSelectionModel* selModel = this->selectionModel();
Q_ASSERT(selModel);
selModel->blockSignals(true);
selModel->select(deselected, QItemSelectionModel::Deselect);
selModel->select(selected, QItemSelectionModel::Select);
selModel->blockSignals(false);
Model* model = static_cast<Model*>(this->model());
//model->setSelectionFromOutside(selected, deselected);
return QTreeView::selectionChanged(selected, deselected);
}
void DataView::clearSelection()
{
selectionModel()->clearSelection();
}
*/
/**
* \file DataView.h
* 24/9/2009 LB Initial implementation
*/
#ifndef DATAVIEW_H
#define DATAVIEW_H
#include <QTreeView>
/**
* The DataView is table view which acts as a base class for displaying
* several OSG data formats.
*/
class DataView : public QTreeView
{
Q_OBJECT
public:
DataView(QWidget* parent = 0);
void updateView();
/// Returns the selected indexes. Overwritten from QTableView to make it public.
//QModelIndexList selectedIndexes() const;
protected slots:
/// Is called when the selection of this view changes. Emits a the signal
/// itemSelectionChanged()
//void selectionChanged(const QItemSelection &selected,
// const QItemSelection &deselected);
/// Selects items without sending signals.
//void selectionChangedFromOutside(const QItemSelection &selected,
// const QItemSelection &deselected);
/// Clears the selection
//void clearSelection();
private:
signals:
void itemSelectionChanged(const QItemSelection &selected,
const QItemSelection &deselected);
void itemSelectionChangedFromOutside(const QItemSelection &selected,
const QItemSelection &deselected);
};
#endif // DATAVIEW_H
######################################################################
# Automatically generated by qmake (2.01a) So 30. Aug 01:50:40 2009
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += Enums.h \
Q2DGraphicsView.h \
QOgs2DCoordinateOriginGraphicsItem.h \
QOgs2DGraphicsItem.h \
QOgs2DPntGraphicsItem.h \
QOgs2DViewWidget.h \
QOgsGeoViewsWidget.h \
QOgsGraphicsScene.h \
QOgsPntsModel.h \
QOgsPntsView.h
FORMS += qogs2dviewwidgetbase.ui qogsgeoviewswidgetbase.ui
SOURCES += Q2DGraphicsView.cpp \
QOgs2DCoordinateOriginGraphicsItem.cpp \
QOgs2DGraphicsItem.cpp \
QOgs2DPntGraphicsItem.cpp \
QOgs2DViewWidget.cpp \
QOgsGeoViewsWidget.cpp \
QOgsGraphicsScene.cpp \
QOgsPntsModel.cpp \
QOgsPntsView.cpp
/**
* \file DataViewWidget.cpp
* 11/2/2010 LB Initial implementation
*
* Implementation of DataViewWidget
*/
// ** INCLUDES **
#include "DataViewWidget.h"
#include "Model.h"
DataViewWidget::DataViewWidget( QWidget* parent /*= 0*/ )
: QWidget(parent)
{
setupUi(this);
dataView->setSelectionMode(QAbstractItemView::ExtendedSelection);
dataView->setSelectionBehavior(QAbstractItemView::SelectRows);
connect(this->modelSelectComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(changeActiveModel(int)));
connect(this->removeAllPushButton, SIGNAL(clicked()), this, SLOT(emitRequestModelClear()));
}
void DataViewWidget::addModel( Model* model )
{
this->modelSelectComboBox->addItem(model->name());
_models.push_back(model);
this->modelSelectComboBox->setCurrentIndex(-1); // hack for the first inserted model
this->modelSelectComboBox->setCurrentIndex(_models.size() - 1);
}
void DataViewWidget::removeModel( Model* model )
{
int index = 0;
for (std::vector<Model*>::iterator it = _models.begin();
it != _models.end(); ++it)
{
if (*it == model)
{
if (dataView->model() == model)
dataView->setModel(NULL);
_models.erase(it);
modelSelectComboBox->removeItem(index);
return;
}
index++;
}
}
void DataViewWidget::changeActiveModel( int index )
{
size_t numModels = _models.size() ;
if (numModels == 0)
return;
if ((unsigned int)index > _models.size() - 1)
return;
dataView->setModel(_models[index]);
}
void DataViewWidget::emitRequestModelClear()
{
std::string modelName = this->modelSelectComboBox->currentText().toStdString();
emit requestModelClear(modelName);
}
/**
* \file DataViewWidget.h
* 11/2/2010 LB Initial implementation
*
*/
#ifndef DATAVIEWWIDGET_H
#define DATAVIEWWIDGET_H
// ** INCLUDES **
#include "ui_DataViewWidgetBase.h"
class Model;
/**
* DataViewWidget
*/
class DataViewWidget : public QWidget, public Ui_DataViewWidgetBase
{
Q_OBJECT
public:
DataViewWidget(QWidget* parent = 0);
public slots:
void addModel(Model* model);
void removeModel(Model* model);
private slots:
void changeActiveModel(int index);
void emitRequestModelClear();
signals:
void requestModelClear(const std::string &name);
private:
std::vector<Model*> _models;
};
#endif // DATAVIEWWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DataViewWidgetBase</class>
<widget class="QWidget" name="DataViewWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>259</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QComboBox" name="modelSelectComboBox"/>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="DataView" name="dataView"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="visibleCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Visible</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeAllPushButton">
<property name="text">
<string>Remove All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeSelectedPushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove Selected</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>DataView</class>
<extends>QTableView</extends>
<header>DataView.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
/**
* \file FEMCondition.cpp
* 25/11/2010 KR inital implementation
*
*/
#include "FEMCondition.h"
/**
* \file FEMCondition.h
* 25/11/2010 KR inital implementation
*
*/
#ifndef FEMCONDITION_H
#define FEMCONDITION_H
#include "GeoInfo.h"
#include "ProcessInfo.h"
#include "DistributionInfo.h"
/**
* \brief Adapter class for handling Initial Conditions in the user Interface
*/
class FEMCondition : public GeoInfo, public ProcessInfo, public DistributionInfo
{
public:
FEMCondition() {};
~FEMCondition() {};
};
/**
* \brief Adapter class for handling Boundary Conditions in the user Interface
*/
class BoundaryCondition : public FEMCondition
{
public:
BoundaryCondition() : _tim_type(0) {};
~BoundaryCondition() {};
size_t getTimType() {return _tim_type; };
void setTimType(size_t value) { _tim_type = value; };
private:
size_t _tim_type;
};
/**
* \brief Adapter class for handling Source Terms in the user Interface
*/
class InitialCondition : public FEMCondition
{
public:
InitialCondition() {};
~InitialCondition() {};
};
/**
* \brief Adapter class for handling FEM Conditions in the user Interface
*/
class SourceTerm : public FEMCondition
{
public:
SourceTerm() : _tim_type(0) {};
~SourceTerm() {};
size_t getTimType() {return _tim_type; };
void setTimType(size_t value) { _tim_type = value; };
private:
size_t _tim_type;
};
#endif //FEMCONDITION_H
/**
* \file GEOModels.cpp
* 9/2/2010 LB Initial implementation
*
* Implementation of GEOModels
*/
// ** INCLUDES **
#include "GEOModels.h"
#include "Model.h"
#include "PntsModel.h"
#include "StationTreeModel.h"
#include "LinesModel.h"
#include "SurfaceModel.h"
GEOModels::GEOModels( QObject* parent /*= 0*/ ) :
QObject (parent)
{
_stationModel = new StationTreeModel();
}
GEOModels::~GEOModels()
{
delete _stationModel;
}
void GEOModels::addPointVec( std::vector<GEOLIB::Point*> *points, std::string &name, std::map<std::string, size_t>* name_pnt_id_map )
{
GEOObjects::addPointVec(points, name, name_pnt_id_map);
PntsModel* model = new PntsModel(QString::fromStdString(name), this->getPointVecObj(name), this);
_pntModels.push_back(model);
emit pointModelAdded(model);
}
bool GEOModels::appendPointVec(const std::vector<GEOLIB::Point*> &points, std::string &name)
{
bool ret (GEOLIB::GEOObjects::appendPointVec (points, name));
// search model
QString qname (name.c_str());
bool nfound (true);
std::vector<PntsModel*>::iterator it(_pntModels.begin());
while (nfound && it != _pntModels.end()) {
if (((*it)->name()).contains (qname)) nfound = false;
}
if (nfound) std::cerr << "Model not found" << std::endl;
else (*it)->updateData ();
return ret;
}
bool GEOModels::removePointVec( const std::string &name )
{
if (! isPntVecUsed(name)) {
for (std::vector<PntsModel*>::iterator it = _pntModels.begin(); it
!= _pntModels.end(); ++it) {
if ((*it)->name().toStdString() == name) {
emit pointModelRemoved(*it);
delete *it;
_pntModels.erase(it);
break;
}
}
return GEOObjects::removePointVec(name);
}
std::cout << "GEOModels::removePointVec() - There are still Polylines or Surfaces depending on these points." << std::endl;
return false;
}
void GEOModels::addStationVec( std::vector<GEOLIB::Point*> *stations, std::string &name, const GEOLIB::Color* const color )
{
GEOObjects::addStationVec(stations, name, color);
_stationModel->addStationList(QString::fromStdString(name), stations);
emit stationVectorAdded(_stationModel, name);
}
void GEOModels::filterStationVec(const std::string &name, const std::vector<PropertyBounds> &bounds)
{
emit stationVectorRemoved(_stationModel, name);
const std::vector<GEOLIB::Point*> *stations (GEOObjects::getStationVec(name));
_stationModel->filterStations(name, stations, bounds);
emit stationVectorAdded(_stationModel, name);
}
bool GEOModels::removeStationVec( const std::string &name )
{
emit stationVectorRemoved(_stationModel, name);
_stationModel->removeStationList(name);
return GEOObjects::removeStationVec(name);
}
void GEOModels::addPolylineVec( std::vector<GEOLIB::Polyline*> *lines, const std::string &name, std::map<std::string,size_t>* ply_names )
{
GEOObjects::addPolylineVec(lines, name, ply_names);
if (lines->empty()) return;
PolylinesModel* model = new PolylinesModel(QString::fromStdString(name), this->getPolylineVecObj(name), this);
_lineModels.push_back(model);
emit polylineModelAdded(model);
}
bool GEOModels::removePolylineVec( const std::string &name )
{
for (std::vector<PolylinesModel*>::iterator it = _lineModels.begin();
it != _lineModels.end(); ++it) {
if ((*it)->name().toStdString() == name) {
emit polylineModelRemoved(*it);
delete *it;
_lineModels.erase(it);
return GEOObjects::removePolylineVec (name);
}
}
return false;
}
void GEOModels::addSurfaceVec( std::vector<GEOLIB::Surface*> *surfaces, const std::string &name, std::map<std::string,size_t>* sfc_names )
{
GEOObjects::addSurfaceVec(surfaces, name, sfc_names);
if (surfaces->empty()) return;
SurfaceModel* model = new SurfaceModel(QString::fromStdString(name), this->getSurfaceVecObj(name), this);
_surfaceModels.push_back(model);
emit surfaceModelAdded(model);
}
bool GEOModels::removeSurfaceVec( const std::string &name )
{
for (std::vector<SurfaceModel*>::iterator it = _surfaceModels.begin();
it != _surfaceModels.end(); ++it) {
if ((*it)->name().toStdString() == name) {
emit surfaceModelRemoved(*it);
delete *it;
_surfaceModels.erase(it);
return GEOObjects::removeSurfaceVec (name);
}
}
return false;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment