[8df74d] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[8df74d] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
| 9 | * BoxQtQuery.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: Oct 25, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | #include <Qt/qboxlayout.h>
|
---|
| 21 | #include <Qt/qlabel.h>
|
---|
| 22 | #include <Qt/qtablewidget.h>
|
---|
| 23 |
|
---|
[ad011c] | 24 | #include "CodePatterns/MemDebug.hpp"
|
---|
[8df74d] | 25 |
|
---|
[308aa4] | 26 | #include "UIElements/Qt4/Query/QtQuery.hpp"
|
---|
[8df74d] | 27 |
|
---|
[cca9ef] | 28 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[8df74d] | 29 | #include "World.hpp"
|
---|
| 30 |
|
---|
[7dfd07] | 31 | QtDialog::RealSpaceMatrixQtQuery::RealSpaceMatrixQtQuery(Parameter<RealSpaceMatrix> &_param, std::string _title,QBoxLayout *_parent,Dialog *_dialog) :
|
---|
[852ea3] | 32 | QtQuery<RealSpaceMatrix>(_param, _title),
|
---|
[7c9921] | 33 | parent(_parent),
|
---|
| 34 | dialog(_dialog)
|
---|
[8df74d] | 35 | {
|
---|
| 36 | thisLayout = new QHBoxLayout();
|
---|
| 37 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 38 |
|
---|
| 39 | // init input table
|
---|
[7dfd07] | 40 | inputTable = new QTableWidget(3,3);
|
---|
[8df74d] | 41 | QStringList CoordinateList;
|
---|
| 42 | CoordinateList << "x" << "y" << "z";
|
---|
| 43 | inputTable->setHorizontalHeaderLabels(CoordinateList);
|
---|
| 44 | inputTable->setVerticalHeaderLabels(CoordinateList);
|
---|
| 45 |
|
---|
| 46 | // fill the box with current matrix
|
---|
[cca9ef] | 47 | const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();
|
---|
[8df74d] | 48 | for (int i=0;i<3;i++)
|
---|
| 49 | for (int j=0;j<3;j++) {
|
---|
| 50 | QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(domain.at(i,j)));
|
---|
| 51 | inputTable->setItem(i,j,newItem);
|
---|
[7dfd07] | 52 | onUpdate(i,j);
|
---|
[8df74d] | 53 | }
|
---|
| 54 |
|
---|
| 55 | parent->addLayout(thisLayout);
|
---|
| 56 | thisLayout->addWidget(titleLabel);
|
---|
| 57 | thisLayout->addWidget(inputTable);
|
---|
| 58 |
|
---|
[7c9921] | 59 | connect(inputTable,SIGNAL(cellChanged(int,int)),this,SLOT(onUpdate(int,int)));
|
---|
[8df74d] | 60 | }
|
---|
| 61 |
|
---|
[7d9416] | 62 | QtDialog::RealSpaceMatrixQtQuery::~RealSpaceMatrixQtQuery()
|
---|
[8df74d] | 63 | {
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[7c9921] | 66 | void QtDialog::RealSpaceMatrixQtQuery::onUpdate(int row, int column)
|
---|
| 67 | {
|
---|
| 68 | temp.at(row, column) = inputTable->item(row, column)->text().toDouble();
|
---|
| 69 | dialog->update();
|
---|
| 70 | }
|
---|
| 71 |
|
---|
[8df74d] | 72 |
|
---|