diff --git a/mathmech/Makefile b/mathmech/Makefile index 4eac3df..f378091 100644 --- a/mathmech/Makefile +++ b/mathmech/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: mathmech -# Generated by qmake (2.01a) (Qt 4.8.5) on: ?? ??? 8 04:28:38 2013 +# Generated by qmake (2.01a) (Qt 4.8.5) on: ?? ??? 8 17:13:39 2013 # Project: mathmech.pro # Template: app # Command: /usr/lib/qt4/bin/qmake -o Makefile mathmech.pro @@ -48,22 +48,26 @@ SOURCES = main.cpp \ errorwindow.cpp \ clear_items.cpp \ start_events.cpp \ - update_fields.cpp moc_mainwindow.cpp \ + update_fields.cpp \ + atomtypeswindow.cpp moc_mainwindow.cpp \ moc_errorwindow.cpp \ moc_clear_items.cpp \ moc_start_events.cpp \ - moc_update_fields.cpp + moc_update_fields.cpp \ + moc_atomtypeswindow.cpp OBJECTS = main.o \ mainwindow.o \ errorwindow.o \ clear_items.o \ start_events.o \ update_fields.o \ + atomtypeswindow.o \ moc_mainwindow.o \ moc_errorwindow.o \ moc_clear_items.o \ moc_start_events.o \ - moc_update_fields.o + moc_update_fields.o \ + moc_atomtypeswindow.o DIST = /usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/linux.conf \ /usr/share/qt4/mkspecs/common/gcc-base.conf \ @@ -119,7 +123,7 @@ first: all all: Makefile $(TARGET) -$(TARGET): ui_mainwindow.h ui_errorwindow.h $(OBJECTS) +$(TARGET): ui_mainwindow.h ui_errorwindow.h ui_atomtypeswindow.h $(OBJECTS) $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) Makefile: mathmech.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ @@ -184,7 +188,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) .tmp/mathmech1.0.0 || $(MKDIR) .tmp/mathmech1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/mathmech1.0.0/ && $(COPY_FILE) --parents mainwindow.h errorwindow.h clear_items.h start_events.h update_fields.h .tmp/mathmech1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp errorwindow.cpp clear_items.cpp start_events.cpp update_fields.cpp .tmp/mathmech1.0.0/ && $(COPY_FILE) --parents mainwindow.ui errorwindow.ui .tmp/mathmech1.0.0/ && (cd `dirname .tmp/mathmech1.0.0` && $(TAR) mathmech1.0.0.tar mathmech1.0.0 && $(COMPRESS) mathmech1.0.0.tar) && $(MOVE) `dirname .tmp/mathmech1.0.0`/mathmech1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/mathmech1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/mathmech1.0.0/ && $(COPY_FILE) --parents mainwindow.h errorwindow.h clear_items.h start_events.h update_fields.h atomtypeswindow.h .tmp/mathmech1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp errorwindow.cpp clear_items.cpp start_events.cpp update_fields.cpp atomtypeswindow.cpp .tmp/mathmech1.0.0/ && $(COPY_FILE) --parents mainwindow.ui errorwindow.ui atomtypeswindow.ui .tmp/mathmech1.0.0/ && (cd `dirname .tmp/mathmech1.0.0` && $(TAR) mathmech1.0.0.tar mathmech1.0.0 && $(COMPRESS) mathmech1.0.0.tar) && $(MOVE) `dirname .tmp/mathmech1.0.0`/mathmech1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/mathmech1.0.0 clean:compiler_clean @@ -205,9 +209,9 @@ mocclean: compiler_moc_header_clean compiler_moc_source_clean mocables: compiler_moc_header_make_all compiler_moc_source_make_all -compiler_moc_header_make_all: moc_mainwindow.cpp moc_errorwindow.cpp moc_clear_items.cpp moc_start_events.cpp moc_update_fields.cpp +compiler_moc_header_make_all: moc_mainwindow.cpp moc_errorwindow.cpp moc_clear_items.cpp moc_start_events.cpp moc_update_fields.cpp moc_atomtypeswindow.cpp compiler_moc_header_clean: - -$(DEL_FILE) moc_mainwindow.cpp moc_errorwindow.cpp moc_clear_items.cpp moc_start_events.cpp moc_update_fields.cpp + -$(DEL_FILE) moc_mainwindow.cpp moc_errorwindow.cpp moc_clear_items.cpp moc_start_events.cpp moc_update_fields.cpp moc_atomtypeswindow.cpp moc_mainwindow.cpp: mainwindow.h /usr/lib/qt4/bin/moc $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp @@ -223,6 +227,9 @@ moc_start_events.cpp: start_events.h moc_update_fields.cpp: update_fields.h /usr/lib/qt4/bin/moc $(DEFINES) $(INCPATH) update_fields.h -o moc_update_fields.cpp +moc_atomtypeswindow.cpp: atomtypeswindow.h + /usr/lib/qt4/bin/moc $(DEFINES) $(INCPATH) atomtypeswindow.h -o moc_atomtypeswindow.cpp + compiler_rcc_make_all: compiler_rcc_clean: compiler_image_collection_make_all: qmake_image_collection.cpp @@ -230,15 +237,18 @@ compiler_image_collection_clean: -$(DEL_FILE) qmake_image_collection.cpp compiler_moc_source_make_all: compiler_moc_source_clean: -compiler_uic_make_all: ui_mainwindow.h ui_errorwindow.h +compiler_uic_make_all: ui_mainwindow.h ui_errorwindow.h ui_atomtypeswindow.h compiler_uic_clean: - -$(DEL_FILE) ui_mainwindow.h ui_errorwindow.h + -$(DEL_FILE) ui_mainwindow.h ui_errorwindow.h ui_atomtypeswindow.h ui_mainwindow.h: mainwindow.ui /usr/lib/qt4/bin/uic mainwindow.ui -o ui_mainwindow.h ui_errorwindow.h: errorwindow.ui /usr/lib/qt4/bin/uic errorwindow.ui -o ui_errorwindow.h +ui_atomtypeswindow.h: atomtypeswindow.ui + /usr/lib/qt4/bin/uic atomtypeswindow.ui -o ui_atomtypeswindow.h + compiler_yacc_decl_make_all: compiler_yacc_decl_clean: compiler_yacc_impl_make_all: @@ -254,8 +264,10 @@ main.o: main.cpp mainwindow.h mainwindow.o: mainwindow.cpp mainwindow.h \ ui_mainwindow.h \ + atomtypeswindow.h \ clear_items.h \ - start_events.h + start_events.h \ + update_fields.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp errorwindow.o: errorwindow.cpp errorwindow.h \ @@ -279,6 +291,12 @@ update_fields.o: update_fields.cpp update_fields.h \ ui_mainwindow.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o update_fields.o update_fields.cpp +atomtypeswindow.o: atomtypeswindow.cpp atomtypeswindow.h \ + ui_atomtypeswindow.h \ + errorwindow.h \ + ui_errorwindow.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o atomtypeswindow.o atomtypeswindow.cpp + moc_mainwindow.o: moc_mainwindow.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp @@ -294,6 +312,9 @@ moc_start_events.o: moc_start_events.cpp moc_update_fields.o: moc_update_fields.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_update_fields.o moc_update_fields.cpp +moc_atomtypeswindow.o: moc_atomtypeswindow.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_atomtypeswindow.o moc_atomtypeswindow.cpp + ####### Install install: FORCE diff --git a/mathmech/atomtypeswindow.cpp b/mathmech/atomtypeswindow.cpp new file mode 100644 index 0000000..0d992c8 --- /dev/null +++ b/mathmech/atomtypeswindow.cpp @@ -0,0 +1,157 @@ +#include +#include +#include +#include + +#include "atomtypeswindow.h" +#include "ui_atomtypeswindow.h" + +#include "errorwindow.h" +#include "ui_errorwindow.h" + +AtomTypesWindow::AtomTypesWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::AtomTypesWindow) +{ + ui->setupUi(this); + num_of_mol = new int[100]; + for (int i=0; i<100; i++) + { + num_of_mol[i] = 1; + atomTypes.append(QString("")); + } +} + +AtomTypesWindow::~AtomTypesWindow() +{ + delete ui; + delete num_of_mol; +} + +// ESC press event +void AtomTypesWindow::keyPressEvent(QKeyEvent *pressedKey) +{ + if (pressedKey->key() == Qt::Key_Escape) + close(); +} + +// events +void AtomTypesWindow::on_atomTypes_pushButton_output_clicked() +{ + QString filename = QFileDialog::getSaveFileName( + this, + tr("Save file as..."), + QDir::currentPath(), + tr("Atom types files (*.types);;All files (*.*)")); + if (!filename.isEmpty()) + ui->atomTypes_lineEdit_output->setText(filename); +} + +void AtomTypesWindow::on_atomTypes_pushButton_add_clicked() +{ + errorwin = new ErrorWindow(this); + QString charAtomType = ui->atomTypes_lineEdit_chType->text(); + QString intAtomType= QString::number(ui->atomTypes_spinBox_intType->value()); + + if ((charAtomType.count() != 2) || (charAtomType.split(' ', QString::SkipEmptyParts)[0] != charAtomType)) + { + errorwin->set_message(5); + errorwin->show(); + return; + } + + ui->atomTypes_listWidget->addItem(charAtomType + "=" + intAtomType); + atomTypes[ui->atomTypes_comboBox_mol->currentIndex()] = QString(""); + for (int i=0; iatomTypes_listWidget->count(); i++) + atomTypes[ui->atomTypes_comboBox_mol->currentIndex()].append(ui->atomTypes_listWidget->item(i)->text() + ","); + + delete errorwin; +} + +void AtomTypesWindow::on_atomTypes_pushButton_typeRem_clicked() +{ + int curIndex = ui->atomTypes_listWidget->currentRow(); + if (curIndex > -1) + delete ui->atomTypes_listWidget->item(curIndex); +} + +void AtomTypesWindow::on_atomTypes_pushButton_clear_clicked() +{ + for (int i=0; i<100; i++) + { + num_of_mol[i] = 1; + atomTypes[i] = QString(""); + } + ui->atomTypes_lineEdit_output->clear(); + ui->atomTypes_comboBox_mol->clear(); + ui->atomTypes_comboBox_mol->addItem(QString("1")); + ui->atomTypes_comboBox_mol->addItem(QApplication::translate("AtomTypesWindow", "Add new molecule")); +} + +void AtomTypesWindow::on_atomTypes_spinBox_numOfMol_editingFinished() +{ + num_of_mol[ui->atomTypes_comboBox_mol->currentIndex()] = ui->atomTypes_spinBox_numOfMol->value(); +} + +void AtomTypesWindow::on_atomTypes_comboBox_mol_currentIndexChanged(int index) +{ + ui->atomTypes_lineEdit_chType->clear(); + ui->atomTypes_spinBox_intType->setValue(1); + ui->atomTypes_listWidget->clear(); + if (ui->atomTypes_comboBox_mol->itemText(index) == (QApplication::translate("AtomTypesWindow", "Add new molecule"))) + { + ui->atomTypes_comboBox_mol->setItemText(index, QString::number(index+1)); + ui->atomTypes_comboBox_mol->addItem(QApplication::translate("AtomTypesWindow", "Add new molecule")); + ui->atomTypes_spinBox_numOfMol->setValue(num_of_mol[index]); + } + else if (index == -1) + return; + else + { + ui->atomTypes_spinBox_numOfMol->setValue(num_of_mol[index]); + ui->atomTypes_listWidget->addItems(atomTypes[index].split(',', QString::SkipEmptyParts)); + } +} + +void AtomTypesWindow::on_atomTypes_pushButton_create_clicked() +{ + errorwin = new ErrorWindow(this); + QString output = ui->atomTypes_lineEdit_output->text(); + QString num_mol = QString::number(ui->atomTypes_comboBox_mol->count() - 1); + + for (int i=0; iset_message(8); + errorwin->show(); + return; + } + if (output == "") + { + errorwin->set_message(4); + errorwin->show(); + return; + } + + output = QFileInfo(output).absoluteFilePath(); + QFile f_out(output); + if (!f_out.open(QIODevice::WriteOnly | QIODevice::Text)) + { + errorwin->set_message(9); + errorwin->show(); + return; + } + QTextStream out(&f_out); + out << "NUMTYPES=" << num_mol << "\n"; + for (int i=0; i + +class ErrorWindow; + +namespace Ui { + class AtomTypesWindow; +} + +class AtomTypesWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit AtomTypesWindow(QWidget *parent = 0); + ~AtomTypesWindow(); + +private slots: +// events + void on_atomTypes_pushButton_output_clicked(); + void on_atomTypes_pushButton_add_clicked(); + void on_atomTypes_pushButton_typeRem_clicked(); + void on_atomTypes_pushButton_clear_clicked(); + void on_atomTypes_spinBox_numOfMol_editingFinished(); + void on_atomTypes_comboBox_mol_currentIndexChanged(int index); + void on_atomTypes_pushButton_create_clicked(); + +private: + Ui::AtomTypesWindow *ui; + ErrorWindow *errorwin; + int *num_of_mol; + QStringList atomTypes; + +// ESC pressed event + void keyPressEvent(QKeyEvent *pressedKey); +}; + +#endif /* ATOMTYPESWINDOW_H */ diff --git a/mathmech/atomtypeswindow.ui b/mathmech/atomtypeswindow.ui new file mode 100644 index 0000000..d811c04 --- /dev/null +++ b/mathmech/atomtypeswindow.ui @@ -0,0 +1,361 @@ + + + AtomTypesWindow + + + + 0 + 0 + 468 + 320 + + + + Atom types + + + + + + + + + + 110 + 23 + + + + Output file + + + + + + + + 100 + 23 + + + + + 16777215 + 16777215 + + + + + + + + + 80 + 23 + + + + Browse + + + true + + + + + + + + + + + + 110 + 23 + + + + Molecule + + + + + + + + 0 + 0 + + + + + 130 + 23 + + + + + 1 + + + + + Add new molecule + + + + + + + + + 130 + 23 + + + + Number of molecules + + + + + + + + 60 + 23 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 999 + + + + + + + + + + + + 110 + 23 + + + + Char atom type + + + + + + + + 60 + 23 + + + + + + + + + 110 + 23 + + + + Int atom type + + + + + + + + 60 + 23 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + + + + + + 80 + 23 + + + + Add + + + true + + + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 80 + 23 + + + + Remove + + + true + + + + + + + + + + + + 80 + 23 + + + + Clear + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 80 + 23 + + + + + 16777215 + 16777215 + + + + Create + + + true + + + + + + + + 80 + 23 + + + + Close + + + true + + + + + + + + + + atomTypes_lineEdit_output + atomTypes_pushButton_output + atomTypes_comboBox_mol + atomTypes_spinBox_numOfMol + atomTypes_lineEdit_chType + atomTypes_spinBox_intType + atomTypes_pushButton_add + atomTypes_listWidget + atomTypes_pushButton_typeRem + atomTypes_pushButton_clear + atomTypes_pushButton_create + atomTypes_pushButton_close + + + + + atomTypes_pushButton_close + clicked() + AtomTypesWindow + close() + + + 388 + 294 + + + 447 + 324 + + + + + diff --git a/mathmech/errorwindow.cpp b/mathmech/errorwindow.cpp index 36b75f0..e76cb88 100644 --- a/mathmech/errorwindow.cpp +++ b/mathmech/errorwindow.cpp @@ -34,7 +34,7 @@ void ErrorWindow::set_message(int mess) message = QApplication::translate("ErrorWindow", "Output file is not set"); break; case 5: - + message = QApplication::translate("ErrorWindow", "Atom type must contain 2 characters"); break; case 6: message = QApplication::translate("ErrorWindow", "Log file is not set"); @@ -43,10 +43,10 @@ void ErrorWindow::set_message(int mess) message = QApplication::translate("ErrorWindow", "Component is not found"); break; case 8: - + message = QApplication::translate("ErrorWindow", "Atom types is not set"); break; case 9: - + message = QApplication::translate("ErrorWindow", "Something wrong"); break; case 10: message = QApplication::translate("ErrorWindow", "Interactions are not set"); @@ -59,6 +59,9 @@ void ErrorWindow::set_message(int mess) break; case 13: + break; + default: + message = QApplication::translate("ErrorWindow", "Unknown error"); break; } diff --git a/mathmech/mainwindow.cpp b/mathmech/mainwindow.cpp index 8010b95..608ad11 100644 --- a/mathmech/mainwindow.cpp +++ b/mathmech/mainwindow.cpp @@ -3,6 +3,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include "atomtypeswindow.h" #include "clear_items.h" #include "start_events.h" #include "update_fields.h" @@ -17,7 +18,9 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); statgen_crit = new float[10]; - ui->statusBar->showMessage(QString("Ready")); + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready")); + + createActions(); // TODO: read config // language = QString("eng"); @@ -522,8 +525,9 @@ void MainWindow::on_statgen_pushButton_intAdd_clicked() void MainWindow::on_stagen_pushButton_intRem_clicked() { - if (int curIndex = ui->statgen_listWidget_int->currentRow() > -1) - delete ui->statgen_listWidget_int->item(curIndex-1); + int curIndex = ui->statgen_listWidget_int->currentRow(); + if (curIndex > -1) + delete ui->statgen_listWidget_int->item(curIndex); } // start signals @@ -574,3 +578,16 @@ void MainWindow::on_tabWidget_currentChanged(int index) break; } } + +// window signals +void MainWindow::createActions() +{ + connect(ui->actionAtom_types_file, SIGNAL(triggered()), this, SLOT(createAtomTypes())); +} + +void MainWindow::createAtomTypes() +{ + AtomTypesWindow *atomTypes; + atomTypes = new AtomTypesWindow(this); + atomTypes->show(); +} diff --git a/mathmech/mainwindow.h b/mathmech/mainwindow.h index 2ddf3ab..bf8098b 100644 --- a/mathmech/mainwindow.h +++ b/mathmech/mainwindow.h @@ -73,6 +73,8 @@ private slots: void on_pdb_pushButton_start_clicked(); // completion void on_tabWidget_currentChanged(int index); +// window signals + void createAtomTypes(); private: Ui::MainWindow *ui; @@ -91,6 +93,9 @@ private: friend class Start_events; Update_fields *update_fields; friend class Update_fields; + +// window signals + void createActions(); }; #endif /* MAINWINDOW_H */ diff --git a/mathmech/mainwindow.ui b/mathmech/mainwindow.ui index ec3aa4f..033b329 100644 --- a/mathmech/mainwindow.ui +++ b/mathmech/mainwindow.ui @@ -3272,6 +3272,14 @@ Menu + + + File creator + + + + + @@ -3295,7 +3303,10 @@ - Exit + &Quit + + + Quit Ctrl+Q @@ -3303,7 +3314,7 @@ - Help + &Help F1 @@ -3314,6 +3325,16 @@ About + + + Atom &types file + + + + + &Agglomerate file + + diff --git a/mathmech/mathmech b/mathmech/mathmech index 015c507..f6e3c58 100755 Binary files a/mathmech/mathmech and b/mathmech/mathmech differ diff --git a/mathmech/mathmech.pro b/mathmech/mathmech.pro index c218915..10c3b90 100644 --- a/mathmech/mathmech.pro +++ b/mathmech/mathmech.pro @@ -12,11 +12,14 @@ HEADERS += mainwindow.h \ errorwindow.h \ clear_items.h \ start_events.h \ - update_fields.h + update_fields.h \ + atomtypeswindow.h FORMS += mainwindow.ui \ - errorwindow.ui + errorwindow.ui \ + atomtypeswindow.ui SOURCES += main.cpp mainwindow.cpp \ errorwindow.cpp \ clear_items.cpp \ start_events.cpp \ - update_fields.cpp + update_fields.cpp \ + atomtypeswindow.cpp diff --git a/mathmech/mathmech.pro.user b/mathmech/mathmech.pro.user index b327a61..103a576 100644 --- a/mathmech/mathmech.pro.user +++ b/mathmech/mathmech.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/mathmech/update_fields.cpp b/mathmech/update_fields.cpp index 28ff9d6..a89fcbf 100644 --- a/mathmech/update_fields.cpp +++ b/mathmech/update_fields.cpp @@ -6,8 +6,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include - Update_fields::Update_fields(MainWindow *wid) : parent(wid) { diff --git a/mathmech/update_fields.h b/mathmech/update_fields.h index 8f855bc..6767dfd 100644 --- a/mathmech/update_fields.h +++ b/mathmech/update_fields.h @@ -21,7 +21,6 @@ public slots: private: MainWindow *parent; - }; #endif /* UPDATE_FIELDS_H */