| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| 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 | 
 | 
|---|
| 24 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #include "UIElements/Qt4/Query/QtQuery.hpp"
 | 
|---|
| 27 | #include "UIElements/Qt4/Pipe/BoxQtQueryPipe.hpp"
 | 
|---|
| 28 | 
 | 
|---|
| 29 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
 | 
|---|
| 30 | #include "World.hpp"
 | 
|---|
| 31 | 
 | 
|---|
| 32 | QtDialog::BoxQtQuery::BoxQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
 | 
|---|
| 33 |     Dialog::BoxQuery(_title),
 | 
|---|
| 34 |     parent(_parent)
 | 
|---|
| 35 | {
 | 
|---|
| 36 |   thisLayout = new QHBoxLayout();
 | 
|---|
| 37 |   titleLabel = new QLabel(QString(getTitle().c_str()));
 | 
|---|
| 38 | 
 | 
|---|
| 39 |   // init input table
 | 
|---|
| 40 |   inputTable = new QTableWidget(3,3, _dialog);
 | 
|---|
| 41 |   QStringList CoordinateList;
 | 
|---|
| 42 |   CoordinateList << "x" << "y" << "z";
 | 
|---|
| 43 |   inputTable->setHorizontalHeaderLabels(CoordinateList);
 | 
|---|
| 44 |   inputTable->setVerticalHeaderLabels(CoordinateList);
 | 
|---|
| 45 | 
 | 
|---|
| 46 |   pipe = new BoxQtQueryPipe(tmp,_dialog, inputTable);
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   // fill the box with current matrix
 | 
|---|
| 49 |   const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();
 | 
|---|
| 50 |   for (int i=0;i<3;i++)
 | 
|---|
| 51 |     for (int j=0;j<3;j++) {
 | 
|---|
| 52 |       QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(domain.at(i,j)));
 | 
|---|
| 53 |       inputTable->setItem(i,j,newItem);
 | 
|---|
| 54 |       pipe->update(i,j);
 | 
|---|
| 55 |     }
 | 
|---|
| 56 | 
 | 
|---|
| 57 |   parent->addLayout(thisLayout);
 | 
|---|
| 58 |   thisLayout->addWidget(titleLabel);
 | 
|---|
| 59 |   thisLayout->addWidget(inputTable);
 | 
|---|
| 60 | 
 | 
|---|
| 61 |   connect(inputTable,SIGNAL(cellChanged(int,int)),pipe,SLOT(update(int,int)));
 | 
|---|
| 62 | }
 | 
|---|
| 63 | 
 | 
|---|
| 64 | QtDialog::BoxQtQuery::~BoxQtQuery()
 | 
|---|
| 65 | {
 | 
|---|
| 66 |   delete pipe;
 | 
|---|
| 67 | }
 | 
|---|
| 68 | 
 | 
|---|
| 69 | bool QtDialog::BoxQtQuery::handle() {
 | 
|---|
| 70 |   return true;
 | 
|---|
| 71 | }
 | 
|---|
| 72 | 
 | 
|---|
| 73 | 
 | 
|---|