/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2010-2012 University of Bonn. All rights reserved.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MoleCuilder 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MoleCuilder. If not, see .
*/
/*
* BoxQtQuery.cpp
*
* Created on: Oct 25, 2010
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
#include
//#include "CodePatterns/MemDebug.hpp"
#include "UIElements/Qt4/Query/QtQuery.hpp"
#include "LinearAlgebra/RealSpaceMatrix.hpp"
#include "World.hpp"
QtDialog::RealSpaceMatrixQtQuery::RealSpaceMatrixQtQuery(Parameter &_param, const std::string &_title, const std::string &_description,QBoxLayout *_parent,Dialog *_dialog) :
QtQuery(_param, _title, _description),
parent(_parent),
dialog(_dialog)
{
thisLayout = new QHBoxLayout();
titleLabel = new QLabel(QString(getTitle().c_str()));
titleLabel->setToolTip(QString(getDescription().c_str()));
// init input table
inputTable = new QTableWidget(3,3);
QStringList CoordinateList;
CoordinateList << "x" << "y" << "z";
inputTable->setHorizontalHeaderLabels(CoordinateList);
inputTable->setVerticalHeaderLabels(CoordinateList);
// fill the box with current matrix
const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();
for (int i=0;i<3;i++)
for (int j=0;j<3;j++) {
QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(domain.at(i,j)));
inputTable->setItem(i,j,newItem);
onUpdate(i,j);
}
parent->addLayout(thisLayout);
thisLayout->addWidget(titleLabel);
thisLayout->addWidget(inputTable);
connect(inputTable,SIGNAL(cellChanged(int,int)),this,SLOT(onUpdate(int,int)));
}
QtDialog::RealSpaceMatrixQtQuery::~RealSpaceMatrixQtQuery()
{
}
void QtDialog::RealSpaceMatrixQtQuery::onUpdate(int row, int column)
{
temp.at(row, column) = inputTable->item(row, column)->text().toDouble();
QtQuery::handle();
dialog->update();
}