/**************************************************************************** ** ** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick ** All rights reserved. ** Contact: chuebsch@moliso.de ** ** This file is part of the ShelXle ** ** This file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file COPYING included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** ****************************************************************************/ //äöüß needed to keep this file UTF8 QString::fromUtf8("»") int Revision=1551; #include "window.h" #include "scatt.h" #include "includeeditor.h" #include "exportccdlg.h" #include "deprecation.h" #include "partcolor.h" #include "highlighter.h" #include "eacDlg.h" //#include "dragdropatomsdlg.h" #include "savehistorywidget.h" #include "fcvsfo.h" #include "rename_selected.h" //QString datum=QString(__TIME__ " " __DATE__); #ifdef __x86_64__ const int BitWidth=64; #else #ifdef _WIN64 const int BitWidth=64; #else const int BitWidth=32;// "

This is a 32 bit Version.

" #endif #endif const QFileDialog::Options noneopt = QFileDialog::Options(); QString latestRev="no network available, or you disabled checking"; QString lstpatternfile=":lst_and_output_style.ini"; QString inspatternfile=":ins_res_style.ini"; QString lstpatternfile_dark=":lst_and_output_style_dark.ini"; QString inspatternfile_dark=":ins_res_style_dark.ini"; void Window::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("text/uri-list")) event->acceptProposedAction(); } void Window::toggleFullScreen(){ if (QString(PROGRAM_NAME).compare("shelXle")) return; fullscreen=!fullscreen; if (fullscreen) { showFullScreen(); updateStatusBar("+++PRESS F11 to exit full screen mode.+++PRESS F11 to exit full screen mode.+++PRESS F11 to exit full screen mode.+++PRESS F11 to exit full screen mode.+++PRESS F11 to exit full screen mode.+++"); } else showNormal(); } void Window::dropEvent(QDropEvent *event) { QList drops = event->mimeData()->urls(); QString path=drops.first().path(); #if defined Q_WS_WIN || defined Q_OS_WIN path.remove(QRegularExpression("^/")); #endif if ((path.endsWith(".res",Qt::CaseInsensitive))||(path.endsWith(".ins",Qt::CaseInsensitive))){ loadFile(path); event->acceptProposedAction(); } } void Window::qinitres() { if (!QString(PROGRAM_NAME).compare("shelXle")){ printf("init resorce: %s\n",PROGRAM_NAME); Q_INIT_RESOURCE(icons); }else{ printf("init resorce: %s\n",PROGRAM_NAME); Q_INIT_RESOURCE(bicons); Q_INIT_RESOURCE(shaders); } } Window::Window(PlayOpenGL *_chgl){ /*! \brief the constructor of the main window rather lengthy but most widgets are created and placed here. * */ fullscreen=false; setObjectName("The Main Window"); oldFileName=popel=QString(""); extraIndex = -1; wght_max_cycls = 10; calcmenu=nullptr; printf("QT_VERSION %x \n",QT_VERSION); setAcceptDrops(true); mole.mynewnameis=QString(PROGRAM_NAME); if (!QString(PROGRAM_NAME).compare("shelXle")){ theIconPath=QString(":/xle-icons/"); }else{ theIconPath=QString(":/bicons/"); } int qtmajor=(QT_VERSION&0xff0000)>>16; if (PROGRAM_NAME[0]=='s') { mole.mynewnameis= QString("%1-%2-%3").arg(PROGRAM_NAME).arg(BitWidth).arg(qtmajor);//each version should get ist new ini file because qt5 seems to be //incompatible in windows state QSettings *testset = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, mole.mynewnameis ); QSettings *oldset = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, PROGRAM_NAME); if ((!QFile::exists(testset->fileName()))&&(QFile::exists(oldset->fileName()))){ QFile::copy(oldset->fileName(),testset->fileName()); } testset->deleteLater(); oldset->deleteLater(); } einstellung = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, mole.mynewnameis ); //QFontDatabase::addApplicationFont(":/xle-icons/droid-sans-mono.ttf"); falschAtom=-1; CurrentCellString=QString(); MaxNumberOfPeaks=100; altExtraIconPath=""; calcmenu=NULL;//if not needed it will be not created. dsr=NULL; qsaPNG=nullptr; nowaste=true; focusSet=true; doNotAnnoyMe=false; #if (QT_VERSION >=0x050000) screen = QGuiApplication::screens().at(0); hhh = screen->availableGeometry().height(); #else hhh = qApp->desktop()->availableGeometry(-1).height(); #endif printf("available height %d\n",hhh); shxPath=shxOptions=NULL; machPlatz=false; char *ENUS=setlocale(LC_ALL,"C"); if (!ENUS)ENUS=setlocale(LC_ALL,"en_US.UTF-8"); //printf("%s\n",ENUS); FFTErrorString=""; range=3.0; mode=0; weight=1.0; //scroller=false; setDockNestingEnabled(true); otherOpenFiles=false; QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Bold.ttf"); QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Italic.ttf"); int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); QFont font(family); {//initialize Edidor navibox = new QGroupBox(this); nlt = new QHBoxLayout(navibox); //nlt->setMargin(0); selectPart = new QCheckBox("Select Part",navibox); selectPart->setChecked(false); spinSelectPart = new QSpinBox(navibox); spinSelectPart->setMinimum(1); spinSelectPart->setMaximum(2); spinSelectPart->setVisible(false); inculdePartNull = new QCheckBox("incl. Pt. 0",navibox); inculdePartNull->setToolTip("Include part 0 in selection"); inculdePartNull->setChecked(true); inculdePartNull->setVisible(false); QToolButton *nothing=new QToolButton(navibox); nothing->setIcon(QIcon(theIconPath+"nospell.svg")); nothing->setText("no errors"); nothing->setIconSize(QSize(22,22)); nothing->setToolButtonStyle(Qt::ToolButtonIconOnly); spellCheckact = new QToolButton(navibox); spellCheckact->setIcon(QIcon(theIconPath+"spell.svg")); spellCheckact->setText("Jump to error"); spellCheckact->setIconSize(QSize(22,22)); spellCheckact->setToolTip("Jump to first error in file."); spellCheckact->setToolButtonStyle(Qt::ToolButtonIconOnly); lineColumn = new QLabel("",navibox); nlt->addWidget(selectPart); nlt->addWidget(spinSelectPart); nlt->addWidget(inculdePartNull); connect(selectPart,SIGNAL(toggled(bool)),spinSelectPart,SLOT(setVisible(bool))); connect(selectPart,SIGNAL(toggled(bool)),inculdePartNull,SLOT(setVisible(bool))); connect(selectPart,SIGNAL(stateChanged(int)),this,SLOT(selectParts())); connect(inculdePartNull,SIGNAL(toggled(bool)),this,SLOT(selectParts())); connect(spinSelectPart,SIGNAL(valueChanged(int)),this,SLOT(selectParts())); nlt->addStretch(10); nlt->addWidget(lineColumn); navibox->setLayout(nlt); editor = new CodeEditor(this); editor->setObjectName("ShelXleEditor"); QApplication::setCursorFlashTime(700); editor->setCursorWidth(2); nlt->addWidget(editor->resiFinder); nlt->addWidget(spellCheckact); nlt->addWidget(nothing); connect(spellCheckact,SIGNAL(clicked()),editor,SLOT(jumpToError())); completer = new QCompleter(this); { QStringList keywords; keywords << "ACTA"<<"AFIX"<<"ANIS"<<"BASF"<<"BIND"<<"BLOC"<<"BOND"<< "BUMP"<<"CELL"<<"CGLS"<<"CHIV"<<"CONF"<<"CONN"<<"DAMP"<<"DANG"<< "DEFS"<<"DELU"<<"DFIX"<<"DISP"<<"EADP"<<"END "<<"EQIV"<< "EXTI"<<"EXYZ"<<"FEND"<<"FLAT"<<"FMAP"<<"FRAG"<<"FREE"<< "FVAR"<<"GRID"<<"HFIX"<<"HKLF"<<"HOPE"<<"HTAB"<<"ISOR"<< "LATT"<<"LAUE"<<"LIST"<<"L.S."<<"MERG"<<"MOLE"<< "MORE"<<"MOVE"<<"MPLA"<<"NCSY"<<"OMIT"<<"PART"<<"PLAN"<< "REM "<<"RESI"<<"RTAB"<<"SADI"<<"SAME"<<"SFAC"<<"SHEL"<< "SIMU"<<"SIZE"<<"SPEC"<<"STIR"<<"SUMP"<<"SWAT"<<"SYMM"<< "TEMP"<<"TIME"<<"TITL"<<"TWIN"<<"UNIT"<<"VECT"<< "WPDB"<<"WGHT"<<"ZERR"<< // New Shelxl commands! "XNPD"<setModel(new QStringListModel(keywords, completer)); } completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); editor->setCompleter(completer); shxEditorDock = new QDockWidget("SHELXL Editor",this,Qt::Widget);//Qt::Window//Qt::Tool shxEditorDock->setObjectName("Editor"); shxEditorDock->setFeatures( QDockWidget::DockWidgetMovable| QDockWidget::DockWidgetFloatable| QDockWidget::DockWidgetClosable); connect(shxEditorDock,SIGNAL(visibilityChanged(bool)),this,SLOT(editorIsVisible(bool))); shxMW = new QMainWindow(this); shx_group = new QWidget(this); shxMW->setCentralWidget(shx_group); shx_group->setContentsMargins(0,0,0,0); sss = new QVBoxLayout(shx_group); sss->addWidget(navibox); sss->addWidget(editor); sss->addWidget(editor->suchbox); shx_group->setLayout(sss); shxEditorDock->setWidget(shxMW); connect(shxEditorDock,SIGNAL(visibilityChanged(bool)),this,SLOT(shxActUpdate(bool))); editor->setFont(font); editor->setLineWrapMode(QPlainTextEdit::NoWrap); addDockWidget(Qt::RightDockWidgetArea, shxEditorDock ); } {//init shelx output viewer xlPutor = new CodeEditor(); xlPutor->setObjectName("shelx output viewer"); xlPutor->setReadOnly(true); xlPutor->setFont(font); xlPutor->setLineWrapMode(QPlainTextEdit::NoWrap); shxOutputDock = new QDockWidget("SHELXL output",this,Qt::Widget); shxOutputDock->setObjectName("Output"); shxOutputDock->setFeatures( QDockWidget::DockWidgetMovable| QDockWidget::DockWidgetFloatable| QDockWidget::DockWidgetClosable); shxOutputDock->hide(); connect(shxOutputDock,SIGNAL(visibilityChanged(bool)),this,SLOT(outputIsVisible(bool))); buttomLt = new QHBoxLayout(); loadRes = new QPushButton(QIcon(theIconPath+"open.svg"), "Load refinement results", this); withdraw = new QPushButton(QIcon(theIconPath+"cancel.svg"), "Discard results", this); showLst = new QPushButton("Show output listing file",this); connect(loadRes,SIGNAL(pressed()),this,SLOT(loadrefres())); connect(withdraw,SIGNAL(pressed()),this,SLOT(withdrawres())); connect(showLst,SIGNAL(pressed()),this,SLOT(loadLst())); pro7 = new QPushButton("Visualize output"); connect(pro7,SIGNAL(pressed()),this,SLOT(raiseTaff())); connect(pro7,SIGNAL(pressed()),this,SLOT(displayDisagreeableRestraints())); buttomLt->addWidget(loadRes); buttomLt->addWidget(withdraw); buttomLt->addStretch(10); buttomLt->addWidget(showLst); stoppRefinement = new QPushButton(QIcon(theIconPath+"cancel.svg"),"STOP refinement!",this); stoppRefinement->hide(); finishRefinement = new QPushButton(QIcon(theIconPath+"cancel.svg"),"Finish Gracefully.",this); finishRefinement->hide(); refineButtonBox = new QGroupBox(); refineButtonBox->setLayout(buttomLt); vlt = new QVBoxLayout(); vlt->addWidget(xlPutor); vlt->addWidget(xlPutor->suchbox); vlt->addWidget(refineButtonBox); vlt->addWidget(stoppRefinement); vlt->addWidget(finishRefinement); vlt->addWidget(pro7); refineButtonBox->hide(); pro7->hide(); gp = new QGroupBox(""); gp->setFlat(true); gp->setLayout(vlt); shxOutputDock->setWidget(gp); addDockWidget(Qt::RightDockWidgetArea, shxOutputDock); tabifyDockWidget (shxEditorDock,shxOutputDock); connect(shxOutputDock,SIGNAL(visibilityChanged(bool)),this,SLOT(shxOPTUpdate(bool))); } {//infotainment widget vis_settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, PROGRAM_NAME, mole.mynewnameis); vis_settings->beginGroup("infotaiment"); if (!vis_settings->contains("info_as_default")) { vis_settings->setValue("info_as_default", false); } vis_settings->endGroup(); infotainmentDock = new QDockWidget("Visual Refinement output",this,Qt::Widget); infotainmentDock->setObjectName("Painment"); infotainmentDock->setFeatures( QDockWidget::DockWidgetMovable| QDockWidget::DockWidgetFloatable| QDockWidget::DockWidgetClosable); infotainmentDock->hide(); resid_label = new QTextEdit(); // shows residuals from refinement output resid_label->setAlignment(Qt::AlignTop); resid_label->setStyleSheet("QLabel { background-color : white; border: 1px solid lightgray;}"); resid_label->setWordWrapMode(QTextOption::NoWrap); // prevents word wrap in the table restr_table = new QTextEdit(); restr_table->setAlignment(Qt::AlignBottom); restr_table->setReadOnly(true); resid_label->setReadOnly(true); resid_layout = new QVBoxLayout(); resid_layout->addWidget(resid_label, 4); // residuals resid_layout->addWidget(restr_table, 2); // list of most disagreeable restraints refineButtonBox2 = new QGroupBox(); loadRes2 = new QPushButton(QIcon(theIconPath+"open.svg"),"Load refinement results",this); withdraw2 = new QPushButton(QIcon(theIconPath+"cancel.svg"),"Discard results",this); connect(loadRes2,SIGNAL(pressed()),this,SLOT(loadrefres())); connect(withdraw2,SIGNAL(pressed()),this,SLOT(withdrawres())); QHBoxLayout *buttomLt2 = new QHBoxLayout(); buttomLt2->addWidget(loadRes2); buttomLt2->addWidget(withdraw2); QPushButton *arte= new QPushButton("show text output"); connect(arte,SIGNAL(pressed()),this,SLOT(raiseTaz())); refineButtonBox2->setLayout(buttomLt2); stoppRefinement2 = new QPushButton(QIcon(theIconPath+"cancel.svg"),"STOP refinement!",this); stoppRefinement2->hide(); finishRefinement2 = new QPushButton(QIcon(theIconPath+"cancel.svg"),"Finish Gracefully",this); finishRefinement2->hide(); resid_layout->addWidget(refineButtonBox2, 1); resid_layout->addWidget(stoppRefinement2, 1); resid_layout->addWidget(finishRefinement2, 1); resid_layout->addWidget(arte); refineButtonBox2->hide(); restr_table->setMinimumSize(150, 50); restr_table->setToolTip("The error of a parameter should generally not be higher than 3sigma. A higher\n" "value means that the assumption of the target value is not met. \n" "The reason for this can be either, for example, a distorted molecular geometry \n" "or systematic errors in the data.\n" "\n" "Disagreeable restraints will be highlighted in yellow if the error is above \n" "2.5sigma. They will be highlighted in red if the error is above 3.5sigma.\n"); resid_gb = new QGroupBox(""); resid_gb->setFlat(true); resid_gb->setLayout(resid_layout); infotainmentDock->setWidget(resid_gb); addDockWidget(Qt::RightDockWidgetArea, infotainmentDock); tabifyDockWidget (shxEditorDock,infotainmentDock); } dock = new QDockWidget("Information Window",this); dock->setObjectName("Info"); dock->setAllowedAreas(Qt::AllDockWidgetAreas); infoKanal = new QTextBrowser(dock); infoKanal->setLineWrapMode(QTextEdit::NoWrap); dock->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetClosable); dock->setWidget(infoKanal); dock->hide(); addDockWidget(Qt::RightDockWidgetArea, dock); // resize(qApp->desktop()->screenGeometry().width(),qApp->desktop()->screenGeometry().height()); //rename dock renamDock = new QDockWidget("Rename Mode"); renamDock->setObjectName("Rename"); enterRenameMode = renamDock->toggleViewAction (); enterRenameMode->setShortcut(Qt::ALT|Qt::Key_R); QShortcut *altplus = new QShortcut(Qt::CTRL|Qt::ALT|Qt::Key_Plus,renamDock); connect(altplus, SIGNAL(activated()),this, SLOT(incResiNr())); QShortcut *altminus = new QShortcut(Qt::CTRL|Qt::ALT|Qt::Key_Minus,renamDock); connect(altminus, SIGNAL(activated()),this, SLOT(decResiNr())); connect(enterRenameMode,SIGNAL(triggered(bool)),this,SLOT(renamUpdate(bool))); //connect(enterRenameMode,SIGNAL(triggered(bool)),enterRenameMode,SLOT(setVisible(bool))); renamDock->setFeatures( QDockWidget::DockWidgetMovable| QDockWidget::DockWidgetFloatable| QDockWidget::DockWidgetClosable); renameBox = new QGroupBox(); rnla = new QVBoxLayout(); rnla->setObjectName("Rename Layout"); nliL = new QLabel("You are in 'rename mode' now."); nliL->setFont(QFont("Helvetica",18,QFont::Bold)); spellCheckact2 = new QToolButton(renameBox); spellCheckact2->setIcon(QIcon(theIconPath+"spell.svg")); spellCheckact2->setText("Oops! I made a mistake! Sorry! Please check!"); spellCheckact2->setIconSize(QSize(22,22)); spellCheckact2->setToolTip("Jump to first error in file."); spellCheckact2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); connect(spellCheckact2,SIGNAL(clicked()),shxEditorDock,SLOT(raise())); connect(spellCheckact2,SIGNAL(clicked()),renamDock,SLOT(hide())); connect(spellCheckact2,SIGNAL(clicked()),editor,SLOT(jumpToError())); rnla->addWidget(spellCheckact2); rnla->addWidget(nliL); hintL = new QLabel("
Hint: It is wise to save often. Especially after renaming a couple of Q-Peaks. " "
Saving synchronizes the visualized structure and the editor content.
Before you start renaming and after " "you are finished renaming you should SAVE!     Click here to hide this hint for ever.
"); hintL->setWordWrap(true); rnla->addWidget(hintL); hintL->setOpenExternalLinks(true); connect(hintL,SIGNAL(linkActivated(const QString &)), this ,SLOT(hintLhide())); rufModeBox = new QCheckBox("Automatically jump to first unused label"); rufModeBox->setChecked(false); connect(rufModeBox,SIGNAL(stateChanged(int)),this,SLOT(rufmode())); partSpinL = new QLabel("Part:"); partSpin = new QSpinBox(); partSpin->setMinimum(-99); partSpin->setMaximum(99); partSpin->setValue(0); connect(partSpin,SIGNAL(valueChanged(int)),this,SLOT(updateLabel())); resiNrSpinL = new QLabel("Residue Nr:"); resiNrSpin = new QSpinBox(); resiNrSpin->setMinimum(0); resiNrSpin->setMaximum(9999); resiNrSpin->setValue(0); connect(resiNrSpin,SIGNAL(valueChanged(int)),this,SLOT(renameRNchanged(int))); resiResiClassL = new QLabel("Residue Class:"); resiResiClass = new QLineEdit(""); resiResiClass->setMaxLength(4); resiResiClass->setValidator(new QRegularExpressionValidator(QRegularExpression("^[A-Za-z]\\w{0,3}"),resiResiClass)); resiResiClass->setMinimumWidth(100); connect(resiResiClass,SIGNAL(textEdited(const QString&)),this,SLOT(grossRC(const QString&))); resiResiClass->setEnabled(false); resiResiClassCB = new QComboBox(this); resiResiClassCB->setLineEdit(resiResiClass); resiResiClassCB->setEditable(true); resiResiClassCB->setMinimumWidth(150); rhla = new QHBoxLayout(); rhla->addWidget(partSpinL); rhla->addWidget(partSpin); rhla->addWidget(resiNrSpinL); rhla->addWidget(resiNrSpin); rhla->addWidget(resiResiClassL); rhla->addWidget(resiResiClassCB); rnla->addLayout(rhla); rhla2 = new QHBoxLayout(); tieOccL = new QLabel("Tie occupancy to: "); tieOccL->setAlignment(Qt::AlignRight|Qt::AlignVCenter); tieType = new QComboBox(); tieType->addItem("its fixed value",0); tieType->addItem("fv(n)",1); tieType->addItem("1-fv(n)",-1); tieFVNrL = new QLabel("n = "); tieFVNrL->setAlignment(Qt::AlignRight|Qt::AlignVCenter); tieFVNr = new QSpinBox(); tieFVNr->setMinimum(1); tieFVNr->setMaximum(9999); tieFVNr->setValue(2); tieUsedL = new QLabel("fv(2) is 0x used"); tieFix = new QDoubleSpinBox(this); tieFix->setDecimals(1); tieFix->setMinimum(0.0); tieFix->setMaximum(1.0); tieFix->setValue(1.0); tieFix->setSingleStep(0.1); tieFix->hide(); connect(tieType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTieFreeVar())); connect(tieFVNr,SIGNAL(valueChanged(int)),this,SLOT(updateTieFreeVar())); connect(partSpin,SIGNAL(valueChanged(int)),this,SLOT(updateTieFreeVar())); rhla2->addWidget(tieOccL); rhla2->addWidget(tieType); rhla2->addWidget(tieFix); rhla2->addWidget(tieFVNrL); rhla2->addWidget(tieFVNr); rhla2->addWidget(tieUsedL); rhla2->setEnabled ( false ); rnla->addLayout(rhla2); indexla = new QHBoxLayout(); indexIncr = new QCheckBox("Increment Suffix "); indexIncr->setChecked(false); indexL = new QLabel("Number"); indexSpin = new QSpinBox(); indexSpin->setMinimum(-1); indexSpin->setMaximum(999); indexSpin->setValue(labelIndex); connect(indexSpin,SIGNAL(valueChanged(int )),this,SLOT(changeIndexofLabel(int ))); sufixBox = new QComboBox(); sufixL =new QLabel("Suffix"); QFont dlg2fnt=sufixL->font(); alpha<<"'"<<""<<"A"<<"B"<<"C"<<"D"<<"E"<<"F"<<"G"<<"H"<<"I"<<"J"<<"K" <<"L"<<"M"<<"N"<<"O"<<"P"<<"Q"<<"R"<<"S"<<"T"<<"U"<<"V"<<"W"<<"X"<<"Y"<<"Z" <<"A'"<<"B'"<<"C'"<<"D'"<<"E'"<<"F'"<<"G'"<<"H'"<<"I'"<<"J'"<<"K'"<<"L'"<<"M'" <<"N'"<<"O'"<<"P'"<<"Q'"<<"R'"<<"S'"<<"T'"<<"U'"<<"V'"<<"W'"<<"X'"<<"Y'"<<"Z'"; sufixBox->addItems(alpha); sufixBox->setCurrentIndex(1); sufixBox->setEditable(true); connect(sufixBox,SIGNAL( currentIndexChanged (int)),this,SLOT(changeSuffixofLabel(int ))); indexla->addWidget(indexL); indexla->addWidget(indexSpin); indexla->addWidget(sufixL); indexla->addWidget(sufixBox); rnla->addLayout(indexla); labelSuffix=""; nextLabel="C1"; labelIndex=1; labelPSE="C"; sfacBox = new QGroupBox("Scattering factors"); sfacBox->setFixedSize(110*52,70); sfacla = new QHBoxLayout(); dsm= new QSignalMapper(this); sfacla->addWidget(pserbt[0] = new QRadioButton("any")); /* QString pth=QDir::homePath()+"/QRadioButtonFont.txt"; FILE *frbf=fopen(pth.toStdString().c_str(),"wt"); fprintf(frbf, "%d %s\n", pserbt[0]->fontInfo().pointSize(), pserbt[0]->fontInfo().family().toStdString().c_str()); fclose(frbf); */ dlg2fnt.setPointSize(10); pserbt[0]->setFont(dlg2fnt); dsm->setMapping(pserbt[0],"any"); connect(pserbt[0], SIGNAL(clicked()), dsm, SLOT(map())); for (int i=1; i<109; i++){ sfacla->addWidget(pserbt[i] = new QRadioButton(mole.pse(i-1))); pserbt[i]->setFont(dlg2fnt); dsm->setMapping(pserbt[i],mole.pse(i-1)); connect(pserbt[i], SIGNAL(clicked()), dsm, SLOT(map())); pserbt[i]->hide(); } sfacla->addWidget(pserbt[110] = new QRadioButton("D")); pserbt[110]->setFont(dlg2fnt); dsm->setMapping(pserbt[110],"D"); connect(pserbt[110], SIGNAL(clicked()), dsm, SLOT(map())); pserbt[110]->hide(); //connect(dsm, SIGNAL(mappedString(const QString &)), this, SLOT(changeElemetofLabel(const QString &))); #if (QT_VERSION >= 0x050f00) connect(dsm, &QSignalMapper::mappedString, this, &Window::changeElemetofLabel); #else connect(dsm, SIGNAL(mapped(const QString &)), this, SLOT(changeElemetofLabel(const QString &))); #endif sfacBox->setLayout(sfacla); qsa =new QScrollArea(); qsa->setWidget(sfacBox); qsa->setMaximumHeight(100); QHBoxLayout *rufla= new QHBoxLayout(); rufla->addWidget(rufModeBox); rufla->addWidget(indexIncr); rnla->addLayout(rufla); nextNameL = new QLabel("Next Label is:
C1"); nextNameL->setFont(QFont("Helvetica",16,QFont::Bold)); rnla->addWidget(nextNameL); rnla->addWidget(qsa); psew = new PSEWidget(&mole,this); psew->selection=0; psew->setVisible(false); rnla->addWidget(psew); willpse = new QPushButton("more scattering factors"); willpse->setStyleSheet( QString( "QPushButton {" "border: 1px solid #000000;" "border-radius: 9px;" "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);" "}" "QPushButton:hover {" "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);" "}" "QPushButton:flat {" " border: none; /* no border for a flat push button */" "}" ).arg("#dedede").arg("#eeeeee").arg("#aeaeae")); connect(willpse,SIGNAL(clicked()),psew,SLOT(show())); hidwillpse=new QTimer(this); hidwillpse->setSingleShot(true); hidwillpse->setInterval(100); connect(willpse,SIGNAL(clicked()),hidwillpse,SLOT(start())); connect(hidwillpse,SIGNAL(timeout()),willpse,SLOT(hide())); connect(psew,SIGNAL(pseSelected(int, bool)),psew,SLOT(hide())); connect(psew,SIGNAL(pseSelected(int, bool)),willpse,SLOT(show())); connect(psew,SIGNAL(pseSelected(int, bool)),this,SLOT(addNewScatteringFactor(int,bool))); rnla->addWidget(willpse); buttonBoxRN = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel); buttonBoxRN->hide(); rnla->addWidget(buttonBoxRN); renameBox->setLayout(rnla); renamDock->setWidget(renameBox); addDockWidget(Qt::RightDockWidgetArea, renamDock); renamDock->hide(); tabifyDockWidget (shxEditorDock,renamDock); //rename dock // qPeakDock = new QDockWidget("Q-Peak-Legend"); qPeakDock->setObjectName("Peak"); qPeakDock->hide(); qPeakDock->setFixedWidth(50); qPeakDock->setToolTip("Click or scroll here to reduce the number of Q-peaks shown."); qPeakDock->setFeatures(QDockWidget::DockWidgetClosable); showQPeakLegend = qPeakDock->toggleViewAction (); connect(showQPeakLegend, SIGNAL(toggled(bool )),this,SLOT(setMonoQ(bool ))); showQPeakLegend->setIcon(QIcon(theIconPath+"qlegend.svg")); qpv = new QPeakView(); qPeakDock->setWidget(qpv); addDockWidget(Qt::LeftDockWidgetArea,qPeakDock); //HISTORY histDock = new QDockWidget("Refinement History"); histDock->setObjectName("History"); hw = new HistoryWidget(); qsa2 =new QScrollArea(); hwl = new QVBoxLayout(); hwl->addWidget(hw); qsa2->setLayout(hwl); qsa2->setWidget(hw); qsa2->setAlignment(Qt::AlignBottom|Qt::AlignLeft); histDock->hide(); histDock->setFeatures(QDockWidget::DockWidgetMovable| QDockWidget::DockWidgetFloatable| QDockWidget::DockWidgetClosable); histDock->setWidget(qsa2); histDock->setMinimumSize(100,150); addDockWidget(Qt::RightDockWidgetArea,histDock); connect(hw, SIGNAL(message(const QString&)), this, SLOT(updateStatusBar(const QString&))); connect(hw, SIGNAL(lofi(const QString&)), this, SLOT(loadFile(const QString&))); connect(hw, SIGNAL(saveHist()), this, SLOT(openSaveHistory())); //HISTORY scalePic=1.0; if ((Revision%666)==0) setWindowTitle(QString("%1 - A clumsy GUI for sHELLxl (Rev: %2)(easteregg) ") .arg(PROGRAM_NAME) .arg(Revision)); else setWindowTitle(QString("%1 - A Qt GUI for SHELXL (Rev: %2)(%3bit)(Qt%4)").arg(PROGRAM_NAME).arg(Revision) .arg(BitWidth) .arg(qtmajor) ); //printf("line %d %p\n", __LINE__, _chgl); chgl = new PlayOpenGL(&mole); #if defined (Q_OS_MAC) static QWidget *container = QWidget::createWindowContainer(chgl); container->setObjectName("The Main Window"); #endif //printf("line %d %p\n", __LINE__, chgl,container); chgl->setMolecule(&mole); chgl->QPeakLegend = showQPeakLegend; editor->setgl(chgl); xlPutor->setgl(chgl); connect(qpv,SIGNAL(cutOffChanged(double)),chgl,SLOT(setQpeakCutoff(double))); connect(qpv,SIGNAL(findQP(double)),chgl,SLOT(highliteQPeak(double))); connect(chgl,SIGNAL(qpfoci(double)),qpv,SLOT(qpeaksInFocus(double))); connect(renamDock,SIGNAL(visibilityChanged(bool)),chgl,SLOT(setReNaMo(bool))); connect(renamDock,SIGNAL(visibilityChanged(bool)),this,SLOT(updateLabel())); connect(renamDock,SIGNAL(visibilityChanged(bool)),this,SLOT(renamUpdate(bool))); connect(chgl,SIGNAL(message(const QString&)),this,SLOT(updateStatusBar(const QString&))); connect(chgl,SIGNAL(bigmessage(const QString&)),this,SLOT(infoKanalNews(const QString&))); connect(chgl,SIGNAL(jumpit(int)),this ,SLOT(jumpToAtom(int))); connect(chgl,SIGNAL(insertDFIX(double,double,QList,QString)), editor,SLOT(insertDFIX(double,double,QList,QString))); connect(chgl,SIGNAL(bindthem()),editor,SLOT(insertBind())); connect(chgl,SIGNAL(insertDANG(double,double,QList,QString)), editor,SLOT(insertDANG(double,double,QList,QString))); connect(chgl,SIGNAL(insertFLAT(double,QList,QString)), editor,SLOT(insertFLAT(double,QList,QString))); connect(chgl,SIGNAL(insertEXYZ(QList)), editor, SLOT(insertEXYZ(QList))); connect(chgl,SIGNAL(insertEADP(QList)), editor, SLOT(insertEADP(QList))); connect(chgl,SIGNAL(insertSADI(int)), this, SLOT(insertSADI(int))); connect(chgl,SIGNAL(insertDELU(double, double, QList,QString)), editor,SLOT(insertDELU(double,double,QList,QString))); connect(chgl,SIGNAL(insertSIMU(double,double,double,QList,QString)), editor,SLOT(insertSIMU(double,double,double,QList,QString))); connect(chgl,SIGNAL(insertISOR(double,double,QList,QString)), editor,SLOT(insertISOR(double,double,QList,QString))); connect(chgl,SIGNAL(insertRIGU(double, double, QList,QString)), editor,SLOT(insertRIGU(double,double,QList,QString))); connect(chgl,SIGNAL(insertCHIV(double, double, QList,QString)), editor,SLOT(insertCHIV(double,double,QList,QString))); connect(chgl,SIGNAL(insertANIS(QList)), editor, SLOT(insertANIS(QList))); QAction *sma =new QAction("Show matrices (for debugging)",this); sma->setShortcut(tr("Alt+F1")); connect(sma,SIGNAL(triggered()),chgl,SLOT(showMatrix())); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActs[i] = new QAction(this); recentFileActs[i]->setVisible(false); connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } fileMenu = new QMenu(tr("File"), this); //printf("line %d\n",__LINE__); chgl->sfacMenu = new QMenu(tr("Change element to...")); chgl->selSfacMenu = new QMenu(tr("Change elements of selection to...")); editMenu = new QMenu(tr("Edit"),this); dialogMenu = new QMenu(tr("Settings"), this); viewMenu = new QMenu(tr("View"), this); runMenu = new QMenu(tr("SHELX"),this); runMenu->setObjectName("SHELX"); packMenu = new QMenu(tr("Pack"),this); packMenu->setEnabled(false); QMenu *fcoMenu = new QMenu("Tools"); //printf("line %d\n",__LINE__); { QAction *a = symmElementsAct = packMenu->addAction("Show Symmetry Elements", this, SLOT(symmElements(bool))); a->setCheckable(true); a->setChecked(false); //a->setVisible(false); } extraMenu = new QMenu(tr("Extra"),this); { QAction *a; a = switch2HKLF5 = runMenu->addAction("Switch to HKLF 5 refinement.", this, SLOT(go2hklf5())); a->setVisible(false); switch2HKLF5->setObjectName("switch2HKLF5"); a = switch2HKLF4 = runMenu->addAction("Switch to HKLF 4 refinement.", this, SLOT(go2hklf4())); a->setVisible(false); a = refineAct = runMenu->addAction(QIcon(theIconPath+"refine.svg"),"Copy current file to instruction file and run shelxl",this,SLOT(runShelXL())); a->setShortcut(QKeySequence("F2")); a->setData(0); refineAct->setVisible(false); refineAct->setEnabled(false); a->setObjectName("refineAct"); a = refineActAnis = runMenu->addAction(QIcon(theIconPath+"refineanis.svg"),"Insert ANIS and run shelxl",this,SLOT(runShelXL())); a->setShortcut(QKeySequence("Alt+F2")); a->setData(1); refineActAnis->setVisible(false); refineActAnis->setEnabled(false); a->setObjectName("refineActAnis"); a = refineActActa = runMenu->addAction(QIcon(theIconPath+"refineacta.svg"),"Insert ACTA and run shelxl",this,SLOT(runShelXL())); a->setData(2); refineActActa->setVisible(false); refineActActa->setEnabled(false); a = refineActExti = runMenu->addAction("Insert EXTI and run shelxl",this,SLOT(runShelXL())); a->setData(3); refineActExti->setVisible(false); refineActExti->setEnabled(false); a = refineActConf = runMenu->addAction("Insert CONF and run shelxl",this,SLOT(runShelXL())); a->setData(4); refineActConf->setVisible(false); refineActConf->setEnabled(false); wghtRefineAct=runMenu->addAction(QIcon(theIconPath+"wghtref.svg"),QString("Try to refine until WGHT converges (max %1 runs)").arg(wght_max_cycls),this,SLOT(convergeWght())); if (canWeSqueeze()) { squeezeAct=a=fcoMenu->addAction(QIcon(theIconPath+"squeeze.svg"),"PLATON SQUEEZE this data",this,SLOT(runSqueeze())); } else squeezeAct=nullptr; QIcon icke = QIcon(theIconPath+"autohfix.svg"); a=actionHFix=runMenu->addAction(icke, tr("Automatic H-Fi&x"),this,SLOT(autoHFix())); a->setObjectName("actionHFix"); a=runMenu->addAction("DISPersion from WAVElength", editor, SLOT(dispFromWave())); a=runMenu->addAction("Replace SFAC by elastic electron atomic scattering factors",editor,SLOT(insertElectronSFACs())); a=actionUniq=runMenu->addAction("Move centers of gravity into unit cell",this,SLOT(uniq())); a->setObjectName("actionUniq"); runMenu->addAction("UNIQue ", this, SLOT(unique())); runMenu->addAction("Update UNIT instruction", editor, SLOT(updateUnit())); runMenu->addAction("Weed unused SFAC numbers ", editor, SLOT(weedEmptySfacs())); wghtAct=runMenu->addAction("Update WGHT instruction",editor,SLOT(updateWght())); wghtAct->setEnabled(false); runMenu->addAction("Invert structure", this, SLOT(invert())); runMenu->addAction("Fix some parameters", this, SLOT(fixIt())); sinaAct = runMenu->addAction(QIcon(theIconPath+"sina.svg"),"Make (selected or all) atoms isotropic (ISOT)",this,SLOT(sina())); sinaAct->setObjectName("sinaAct"); sinaAct->setData(-1); fcoMenu->addAction("Create Q-Peaks from Fo-Fc map",this, SLOT(addMoreQPeaks())); actionQPeakLimit = fcoMenu->addAction(QString("Change maximum number of created Q-peaks (%1)").arg(MaxNumberOfPeaks),this,SLOT(changeQPeakLimit())); fcoMenu->addAction("Most Disagreeable Reflections",this,SLOT(worstReflections())); fcoMenu->addAction("Split rotate molecule branch",this,SLOT(splitRotate())); a=fcoMenu->addAction("test for merohedral twinning"); twinDlg=nullptr; connect(a,SIGNAL(triggered() ),this,SLOT(testMerohedral())); runMenu->addAction(QIcon(theIconPath+"aula.svg"),"Automatic Labeling", this, SLOT(aula())); runMenu->addSeparator(); editor->sortierWeise=1; soact=runMenu->addAction("Sort atoms in file.",editor ,SLOT(sortAtoms())); runMenu->addSeparator(); a=runMenu->addAction("...find more functions in Menu->Tools"); a->setDisabled(true); runMenu->addSeparator(); runMenu->addAction("Specify SHELXL runtime options",this , SLOT(setShelxlOptions())); } { QToolBar *tb =fito= new QToolBar(this); tb->setWindowTitle(tr("File Tools")); tb->setObjectName("FileTB"); addToolBar(tb); QAction *a; openAct=a=fileMenu->addAction(QIcon(theIconPath+"open.svg"), tr("&Open..."), this, SLOT(openFile() ),QKeySequence(tr("Ctrl+O", "File|Open"))); tb->addAction(a); actionSave = new QAction(QIcon(theIconPath+"filesave.svg"),tr("&Save"), this); actionSave->setShortcut(QKeySequence::Save); connect(actionSave, SIGNAL(triggered()), this, SLOT(fileSave())); actionSave->setEnabled(false); tb->addAction(actionSave); fileMenu->addAction(actionSave); actionSaveAs = new QAction(QIcon(theIconPath+"filesave.svg"),tr("&Save as ..."), this); actionSaveAs->setShortcut(tr("Shift+Alt+S")); connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(fileSaveAs())); actionSaveAs->setEnabled(true); fileMenu->addAction(actionSaveAs); fileMenu->addAction(tr("Open save history"),this,SLOT(openSaveHistory())); fileMenu->addAction("Shred a CIF and load its res",this,SLOT(shredCIF())); fileMenu->addSeparator(); screenshotAct=a=fileMenu->addAction(QIcon(theIconPath+"diskette.svg"), tr("&ScreenShot"), this, SLOT(saveScene()), QKeySequence(tr("F7","File|ScreenShot"))); //tb->addAction(a); actionPovRay=a=fileMenu->addAction(QIcon(theIconPath+"POV-Ray.ico"),"Export Scene to Pov-Ray",this, SLOT(savePovRay())); a->setShortcut(Qt::ALT|Qt::Key_P); tb->addAction(a); objExport=a=fileMenu->addAction(QIcon(theIconPath+"obj.svg"),"Export Wafefront .obj file",this,SLOT(obj())); tb->addAction(a); a->setShortcut(Qt::ALT|Qt::Key_O); fileMenu->addAction("Export Fourier Maps",this,SLOT(exportFMaps())); fileMenu->addAction("Export visible atoms ...",this,SLOT(exportCoordinates())); actionExportCC=fileMenu->addAction("Export for computational chemistry programs",this, SLOT(exportCC())); fileMenu->addSeparator(); for (int i = 0; i < MaxRecentFiles; ++i) fileMenu->addAction(recentFileActs[i]); fileMenu->addSeparator(); fileMenu->addAction("Set default path",this,SLOT(setDefaultPath())); fileMenu->addSeparator(); a=fileMenu->addAction(QIcon(theIconPath+"cancel.svg"), tr("&Quit") , this, SLOT(close()),QKeySequence(tr("Ctrl+Q", "File|Quit"))); tb->addAction(a); } //printf("line %d\n", __LINE__); backColor = new QAction(tr("Change background color"), this); labelColor = new QAction(tr("Change label color"), this); backColor->setShortcut (tr("Shift+Alt+B")); labelColor->setShortcut(tr("Shift+Alt+T")); connect(backColor, SIGNAL (triggered ()), chgl, SLOT(changeBColor())); connect(labelColor, SIGNAL (triggered ()), chgl, SLOT(changeTColor())); dialogMenu->addAction("Change tool bar icon size",this,SLOT(changeIconSize())); QAction *adoptAct= dialogMenu->addAction("Edit tool bar is attached to Editor",this,SLOT(adoptEditToolBar(bool))); adoptAct->setCheckable(true); adoptAct->setChecked(false); dialogMenu->addAction("Change screen shot resolution",this,SLOT(changeScalefactor())); dialogMenu->addAction("Number of atoms in asymmetric unit to skip automatic distance calculation on loading",this, SLOT(setSDMLimit())); dialogMenu->addAction("Number of max cycles in WGHT refine", this ,SLOT(setMaxWGHTCycls())); separateLabelFile= dialogMenu->addAction("Render labels in a separate file"); separateLabelFile->setCheckable(true); separateLabelFile->setChecked(false); dialogMenu->addAction(backColor); dialogMenu->addAction(labelColor); dialogMenu->addAction(tr("Change label font"), this, SLOT(changeLabelFont())); dialogMenu->addAction(tr("Change editor font"), this, SLOT(changeEditorFont())); astdlg = dialogMenu->addAction(QIcon(theIconPath+"eac.svg"),"Atom Styles", this,SLOT(styleDialog()),QKeySequence("Alt+Shift+A")); dialogMenu->addAction("Save current orientation matrix",chgl,SLOT(saveOrientation())); dialogMenu->addAction("Load orientation matrix",chgl,SLOT(loadOrientation())); editMenu->addAction(enterRenameMode); { QToolBar *tb = editToolBar = new QToolBar(this); tb->setObjectName("EditTB"); tb->setWindowTitle(tr("Editor Tools")); QAction *a; actionEP=a=viewMenu->addAction(QIcon(theIconPath+"efplus.svg"), "Increase editor fontsize"); actionEP->setShortcut(QKeySequence(QKeySequence::ZoomIn)); connect(actionEP,SIGNAL(triggered()), editor, SLOT(increaseEdtiorFont())); connect(actionEP,SIGNAL(triggered()), xlPutor,SLOT(increaseEdtiorFont())); tb->addAction(a); actionEM=a=viewMenu->addAction(QIcon(theIconPath+"efminus.svg"), "Decrease editor fontsize"); actionEM->setShortcut(QKeySequence(QKeySequence::ZoomOut)); connect(actionEM,SIGNAL(triggered()), editor, SLOT(decreaseEdtiorFont())); connect(actionEM,SIGNAL(triggered()), xlPutor, SLOT(decreaseEdtiorFont())); tb->addAction(a); a = actionUndo = new QAction(QIcon( theIconPath+"editundo.svg"),tr("&Undo"), this); a->setShortcut(QKeySequence::Undo); a->setEnabled(false); tb->addAction(a); editMenu->addAction(a); a = actionRedo = new QAction(QIcon( theIconPath+"editredo.svg"),tr("&Redo"), this); a->setShortcut(QKeySequence::Redo); a->setEnabled(false); tb->addAction(a); editMenu->addAction(a); editMenu->addSeparator(); a = actionCut = new QAction(QIcon(theIconPath+"editcut.svg"),tr("Cu&t"), this); a->setShortcut(QKeySequence::Cut); a->setEnabled(false); tb->addAction(a); editMenu->addAction(a); a = actionCopy = new QAction(QIcon(theIconPath+"editcopy.svg"),tr("&Copy"), this); a->setShortcut(QKeySequence::Copy); a->setEnabled(false); tb->addAction(a); editMenu->addAction(a); a = actionPaste = new QAction(QIcon(theIconPath+"editpaste.svg"),tr("&Paste"), this); a->setShortcut(QKeySequence::Paste); a->setEnabled(false); tb->addAction(a); editMenu->addAction(a); //printf("line %d\n",__LINE__); #ifndef QT_NO_CLIPBOARD actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty()); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif a=actionSearch=editMenu->addAction(QIcon(theIconPath+"search.svg"), "&Find in Text",this,SLOT(showSearch()),QKeySequence(tr("Ctrl+F", "Edit|Find"))); tb->addAction(a); a->setEnabled(false); a=actionNext=editMenu->addAction(QIcon(theIconPath+"moveright.svg"), tr("Find &Next"),this ,SLOT(findNext()),QKeySequence(tr("F3","Edit|Next"))); a->setEnabled(false); a=actionPrev=editMenu->addAction(QIcon(theIconPath+"moveleft.svg"), tr("Find &Previous"),this, SLOT(findPrev()), QKeySequence(tr("Shift+F3", "Edit|Previous"))); a->setEnabled(false); editToolBar->hide(); //printf("line %d\n",__LINE__); } { QToolBar *tb = refineToolBar = new QToolBar(this); tb->setObjectName("RefineTB"); tb->setWindowTitle(tr("Refinement Tools")); addToolBar(tb); tb->addAction(actionHFix); QIcon icke=QIcon(theIconPath+"killqs.svg"); QAction *a; a=killQs=editMenu->addAction(icke, tr("Delete all Q-peaks"), this, SLOT(deleteAllQ()), QKeySequence(tr("Meta+Shift+Q"))); tb->addAction(a); icke=QIcon(theIconPath+"killhs.svg"); a=killHs=editMenu->addAction(icke, tr("Delete all Hydrogen atoms"),this,SLOT(deleteAllH()), QKeySequence(tr("Meta+Shift+H"))); tb->addAction(a); tb->addAction(refineAct); tb->addAction(refineActAnis); tb->addAction(wghtRefineAct); if (squeezeAct!=nullptr) tb->addAction(squeezeAct); refineToolBar->hide(); } //printf("line %d\n",__LINE__); { //QToolBar *tb = vito = new QToolBar(this); vito->setWindowTitle(tr("View Tools")); vito->setObjectName("ViewTB"); addToolBar(vito); QAction *a; /* stereoMenu = new QMenu("&3D Stereo Options"); //zm_stereo = stereoMenu->addAction("&Zalman Monitor 3D"); pe_stereo = stereoMenu->addAction("&Parallel Eye Side by Side Stereo"); xe_stereo = stereoMenu->addAction("&Crossed Eye Side by Side Stereo"); an_stereo = stereoMenu->addAction("&Anaglyph Stereo red left blue right(testing)"); //hw_stereo = stereoMenu->addAction("&Hardware Stereo (testing)"); //printf("line %d\n",__LINE__); //hw_stereo->setEnabled(chgl->context()->format().stereo()); //printf("line %d\n",__LINE__); no_stereo = stereoMenu->addAction("Stereo &Mode off"); //connect(zm_stereo,SIGNAL(triggered()),chgl,SLOT(zalman())); connect(pe_stereo,SIGNAL(triggered()),chgl,SLOT(parallel())); connect(xe_stereo,SIGNAL(triggered()),chgl,SLOT(crosseye())); connect(an_stereo,SIGNAL(triggered()),chgl,SLOT(anaglyphRedCyan())); //connect(hw_stereo,SIGNAL(triggered()),chgl,SLOT(hardwareStereo())); connect(no_stereo,SIGNAL(triggered()),chgl,SLOT(nostereo())); stereoGroup = new QActionGroup(this); //stereoGroup->addAction(zm_stereo); stereoGroup->addAction(pe_stereo); stereoGroup->addAction(xe_stereo); stereoGroup->addAction(an_stereo); //stereoGroup->addAction(hw_stereo); stereoGroup->addAction(no_stereo); //zm_stereo->setCheckable(true); pe_stereo->setCheckable(true); xe_stereo->setCheckable(true); an_stereo->setCheckable(true); //hw_stereo->setCheckable(true); no_stereo->setCheckable(true); no_stereo->setChecked(true); viewMenu->insertMenu(actionEP,stereoMenu); viewMenu->insertSeparator(actionEP); */ moveMenu = new QMenu("Move Menu"); moveMenu->addAction(tr("Zoom in") ,this,SLOT(zoomin ()), QKeySequence(Qt::ALT | Qt::Key_PageUp) ); moveMenu->addAction(tr("Zoom out") ,this,SLOT(zoomout()), QKeySequence(Qt::ALT | Qt::Key_PageDown)); moveMenu->addAction(tr("Rotate left") ,this,SLOT(rotl ()), QKeySequence(Qt::ALT | Qt::Key_Left) ); moveMenu->addAction(tr("Rotate right") ,this,SLOT(rotr ()), QKeySequence(Qt::ALT | Qt::Key_Right) ); moveMenu->addAction(tr("Rotate upwards") ,this,SLOT(rotu ()), QKeySequence(Qt::ALT | Qt::Key_Up) ); moveMenu->addAction(tr("Rotate downwards") ,this,SLOT(rotd ()), QKeySequence(Qt::ALT | Qt::Key_Down) ); moveMenu->addAction(sma); moveMenu->addAction("test test 1 2",this, SLOT(testOGL()),QKeySequence(Qt::META|Qt::SHIFT|Qt::Key_A) ); //printf("line %d\n",__LINE__); moveMenu->addAction("Zoom out", chgl, SLOT(zoomOut()), QKeySequence(Qt::ALT | Qt::CTRL | Qt::Key_Z)); moveMenu->addAction("View along z direction",chgl,SLOT(along001())); viewMenu->insertMenu(actionEP,moveMenu); //printf("line %d\n",__LINE__); QIcon icke=QIcon(theIconPath+"ideal.svg"); chgl->hideBeLo=viewMenu->addAction(icke,"Toggle BEDE and LONE objects (IDEAL)",chgl,SLOT(update())); chgl->hideBeLo->setCheckable(true); chgl->hideBeLo->setChecked(true); chgl->hideBeLo->setVisible(false); belocube = viewMenu->addAction("Compute and visualize BODD in direct space (IDEAL)" ,this,SLOT(beloWriteCube())); belocube->setVisible(false); belocube->setObjectName("BeLoCube"); belocube->setShortcut(Qt::CTRL|Qt::Key_I); a=dialogMenu->addAction("HFIX only on suitable atoms", this, SLOT(toggleHFSAO(bool))); a->setCheckable(true); a->setChecked(mole.HFixSuitableAtomsOnly); //printf("line %d\n",__LINE__); dialogMenu->addAction("Style BEDE and LONE objects (IDEAL)",this,SLOT(configBeLos())); chgl->shortLabels=viewMenu->addAction("Short Labels",chgl,SLOT(makeLabels())); chgl->shortLabels->setCheckable(true); chgl->shortLabels->setChecked(true); chgl->shortLabels->setShortcut(Qt::SHIFT | Qt::ALT | Qt::Key_L); vito->addAction(astdlg); a=togAtom =viewMenu->addAction(QIcon(theIconPath+"atoms.svg"), tr("Toggle Atoms"), chgl, SLOT(setAtoms(bool)), QKeySequence("Alt+A")); a->setCheckable(true); a->setChecked(true); vito->addAction(a); a=chgl->tubes = vito->addAction(QIcon(theIconPath+"tubes.svg"),"Tubes",chgl,SLOT(update())); a=chgl->ballStick = vito->addAction(QIcon(theIconPath+"ballstick.svg"),"Ball-Stick",chgl,SLOT(update())); tubeGroup = new QActionGroup(this); tubeGroup->addAction(chgl->tubes); tubeGroup->addAction(chgl->ballStick); chgl->ballStick->setCheckable(true); chgl->ballStick->setChecked(true); connect(chgl->ballStick, SIGNAL(triggered()), chgl, SLOT(makeLegendAtoms())); chgl->tubes->setCheckable(true); chgl->tubes->setChecked(false); connect(chgl->tubes, SIGNAL(triggered()), chgl, SLOT(makeLegendAtoms())); //printf("line %d\n",__LINE__); { QIcon icke=QIcon(theIconPath+"adp.svg"); //icke.addFile(theIconPath+"adp23.svg"); a=chgl->adp =viewMenu->addAction(icke, tr("Toggle ADPs"), chgl, SLOT(update()), QKeySequence("Alt+E")); connect(chgl->adp, SIGNAL(triggered()), chgl, SLOT(makeLegendAtoms())); } a->setCheckable(true); a->setChecked(true); vito->addAction(a); a=togBond =viewMenu->addAction(QIcon(theIconPath+"bonds.svg"), tr("Toggle Bonds"), chgl, SLOT(setBonds(bool)), QKeySequence("Alt+B")); a->setCheckable(true); a->setChecked(true); vito->addAction(a); a=togLabel=viewMenu->addAction(QIcon(theIconPath+"labels.svg"), tr("Toggle Labels"),chgl,SLOT(setLabels(bool)),QKeySequence("Alt+L")); a->setCheckable(true); a->setChecked(true); vito->addAction(a); //printf("line %d\n",__LINE__); /* a=viewMenu->addAction(QIcon(theIconPath+"laplus.svg"), tr("Increase label fontsize"),chgl,SLOT(incFontSize()), QKeySequence("Alt++")); a=viewMenu->addAction(QIcon(theIconPath+"laminus.svg"), tr("Decrease label fontsize"),chgl,SLOT(decFontSize()), QKeySequence("Alt+-"));*/ //printf("line %d\n", __LINE__); a=chgl->togUnit =viewMenu->addAction(QIcon(theIconPath+"unitcell.svg"), tr("Toggle Unit Cell"),chgl,SLOT(update()),QKeySequence("Alt+C")); a->setCheckable(true); a->setChecked(false); vito->addAction(a); //printf("line %d %p\n", __LINE__,viewMenu,chgl->h_bonds); a=chgl->h_bonds=viewMenu->addAction(QIcon(theIconPath+"hbrs.svg"), tr("Toggle H-bonds"),chgl,SLOT(update()),QKeySequence("Alt+H")); a->setCheckable(true); a->setChecked(true); vito->addAction(a); //printf("line %d %p %d\n", __LINE__, chgl->h_bonds, chgl->h_bonds->isVisible()); a=chgl->atomLegend=viewMenu->addAction(QIcon(theIconPath+"legend.svg"), tr("Toggle Atom Legend"),chgl,SLOT(update()), QKeySequence("Alt+K")); a->setCheckable(true); a->setChecked(true); vito->addAction(a); //printf("line %d\n",__LINE__); fxle= new FourXle(&mole, chgl, vito); //printf("line %d\n",__LINE__); fxle->mapcontrol=dialogMenu->addAction(QIcon(theIconPath+"mapcontrol.svg"),tr("Open Map Control"), fxle, SLOT(openMapControl())); vito->addAction(fxle->mapcontrol); fxle->mapcontrol->setVisible(false); connect(chgl,SIGNAL(destroyed()),fxle ,SLOT(killFourXleFirst()));//maybe tidy up before die connect(fxle,SIGNAL(reloadRes()),this ,SLOT(loadAFile())); connect(fxle->jnkButton,SIGNAL(pressed()),this,SLOT(jnk())); fxle->keepiso = dialogMenu->addAction("Keep Map Iso Values Fixed", fxle, SLOT(keepIsoValues(bool ))); fxle->keepiso->setCheckable(true); fxle->keepiso->setChecked(fxle->keepIso->isChecked());//diffent CaSe ! /*a=viewMenu->addAction(tr("Toggle MSAA"),chgl,SLOT(setMSAA(bool)),QKeySequence("F4")); a->setCheckable(true); a->setChecked(true);*/ a=equivHighlighting=viewMenu->addAction("Highlight Symmetry Equivalents",this,SLOT(toggleEQHighlighting(bool))); equivHighlighting->setCheckable(true); equivHighlighting->setChecked(true); a=togBackGr=viewMenu->addAction(tr("Toggle Background Gradient"), chgl, SLOT(setBGGradient(bool)), QKeySequence("F6")); a->setCheckable(true); a->setChecked(true); viewMenu->addAction(dock->toggleViewAction()); viewMenu->addAction(shxEditorDock->toggleViewAction()); //viewMenu->addAction(chgl->wireButt); viewMenu->addAction(chgl->rainbowPlot); /*=togDepthCueing=viewMenu->addAction(tr("toggle DepthCueing (mist)"),chgl,SLOT(setDepthCueing(bool)), QKeySequence(Qt::ALT | Qt::Key_M));//=togDepthCueing a->setCheckable(true); a->setChecked(false);*/ //printf("line %d\n",__LINE__); viewMenu->addSeparator(); ydleStart=viewMenu->addAction("Start rotation", this, SLOT(idleRotStart()), QKeySequence(Qt::ALT | Qt::Key_Y)); ydleStop=viewMenu->addAction("Stop rotation", this, SLOT(idleRotStop()), QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Space)); ydleStop->setVisible(false); QAction *moviMaker = viewMenu->addAction("Create a Rotation Movie", this,SLOT(makeRotMovi())); moviMaker->setShortcut(Qt::CTRL | Qt::Key_M); viewMenu->addSeparator(); viewMenu->addAction("Redraw Structure", this, SLOT(effuenf()), QKeySequence("F5")); viewMenu->addAction("Reload Structure From Current File", this,SLOT(loadAFile()), QKeySequence("Ctrl+F5")); { QAction *a= viewMenu->addAction("Create Voronoi Polyeders of Asymmetric Unit",this,SLOT(makeVoro())); a->setData(-1); } { QAction *a=clearVoro= viewMenu->addAction("Remove Voronoi Polyeder(s) ",this,SLOT(clearVoros())); a->setData(-1); clearVoro->setVisible(false); } //viewMenu->addAction("hide me!",this, SLOT(hide()),QKeySequence("F12")); //viewMenu->addAction("show must go on!",this, SLOT(show()),QKeySequence("F10")); if (!QString(PROGRAM_NAME).compare("shelXle"))//olny in standalone shelXle viewMenu->addAction("Fullscreen Mode", this, SLOT(toggleFullScreen()), QKeySequence("F11")); } { QAction *a; QToolBar *tb=bottomToolBar= new QToolBar("Atom Selection Tools",this); tb->setObjectName("AtomTB"); tb->setMovable(false); tb->setAllowedAreas(Qt::BottomToolBarArea|Qt::TopToolBarArea); tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); QMenu *m= new QMenu("Configure selection toolbar"); a=m->addAction("Text Only",this,SLOT(configureBottomToolbar())); a->setData(Qt::ToolButtonTextOnly); a=m->addAction("Icon Only",this,SLOT(configureBottomToolbar())); a->setData(Qt::ToolButtonIconOnly); a=m->addAction("Text Beside Icon",this,SLOT(configureBottomToolbar())); a->setData(Qt::ToolButtonTextBesideIcon); a=m->addAction("Text Under Icon",this,SLOT(configureBottomToolbar())); a->setData(Qt::ToolButtonTextUnderIcon); m->addSeparator(); a=m->addAction("Place on Top",this,SLOT(configureBottomToolbar())); a->setData(static_cast(Qt::TopToolBarArea) + 32); a=m->addAction("Place on Bottom",this,SLOT(configureBottomToolbar())); a->setData(static_cast(Qt::BottomToolBarArea) + 32); useNativeDlg=dialogMenu->addAction("Use Native Dialog for File Open/Save",this,SLOT(fileNative())); useNativeDlg->setCheckable(true); useNativeDlg->setChecked(true); darkTheme=dialogMenu->addAction("Use Dark Colors Theme",this,SLOT(darkEdit())); darkTheme->setCheckable(true); darkTheme->setChecked(false); if (QString(PROGRAM_NAME).compare("shelXle")){ darkTheme->setVisible(false); } a=dialogMenu->addAction(QIcon(theIconPath+"configure-toolbars.svg"),"Configure Selection Toolbar"); a->setToolTip("Configure Selection Toolbar icon/text style"); a->setMenu(m); chgl->toggleDockWidgets= a = tb->addAction(QIcon(theIconPath+"hidedockwdg.svg"), "Hide Text Windows",this,SLOT(toggDocWid(bool))); a->setCheckable(true); a->setChecked(false); a->setVisible(false); chgl->toggleOrthoView = a = tb->addAction(QIcon(theIconPath+"ortho.svg"), "Ortho-projection",this,SLOT(toggleOrtho(bool))); a->setCheckable(true); a->setChecked(false); a->setToolTip("toggle Orthographic Projection / Central Perspective Projection"); chgl->grow=a=tb->addAction(QIcon(theIconPath+"grow.svg"),"GROW ",this,SLOT(grow())); a->setShortcut(Qt::ALT | Qt::Key_G); packMenu->addAction(a); a->setToolTip("Complete the Molecule(s)"); a->setVisible(false); chgl->fuse=a=tb->addAction(QIcon(theIconPath+"fuse.svg"),"FUSE ",this,SLOT(fuse())); a->setShortcut(Qt::ALT | Qt::Key_F); packMenu->addAction(a); a->setVisible(false); a->setToolTip("Show the Asymmetric Unit Only"); recalcSDM=a=packMenu->addAction(QIcon(theIconPath+"grow.svg"),"Recalculate Distance Matrices",this,SLOT(sdm())); recalcSDM->setShortcut(Qt::CTRL | Qt::Key_R); QToolBar *sptb=new QToolBar(); sptb->addAction(recalcSDM); renamUpdateAct=sptb->addAction("Update RESIdue Class ComboBox",this,SLOT(renamUpdate(bool))); renamUpdateAct->setCheckable(true); renamUpdateAct->setChecked(false); chgl->pickRadSpin=new QDoubleSpinBox(sptb); chgl->pickRadSpin->setMinimum(5.0); chgl->pickRadSpin->setMaximum(50.0); chgl->pickRadSpin->setDecimals(0); chgl->pickRadSpin->setValue(chgl->pickRad()); chgl->pickRadSpin->setPrefix("pick radius"); chgl->pickRadSpin->setSuffix("px"); connect(chgl->pickRadSpin,SIGNAL(valueChanged(double)),chgl,SLOT(setPickRad(double))); sptb->addWidget(chgl->pickRadSpin); rnla->addWidget(sptb); a=packMenu->addAction("Symmetry Manager",this,SLOT(symmetryManager())); a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_M); tb->addAction(enterRenameMode); enterRenameMode->setIcon(QIcon(theIconPath+"rename.svg")); enterRenameMode->setVisible(false); tb->addAction(showQPeakLegend); showQPeakLegend->setVisible(false); //printf("line %d\n",__LINE__); a=tb->addAction(QIcon(theIconPath+"qbond.svg"),"Q-Peak-Bonds",chgl,SLOT(update())); a->setCheckable(true); a->setChecked(true); a->setVisible(false); chgl->qPeakBonds=a; sinaAct->setVisible(false); chgl->addBond=a=tb->addAction(QIcon(theIconPath+"bind.svg"),"Bind Selected Atoms",editor,SLOT(insertBind())); a->setVisible(false); chgl->killBond=a=tb->addAction(QIcon(theIconPath+"free.svg"),"Free Selected Atoms",editor,SLOT(insertFree())); a->setVisible(false); chgl->clearSelection=a=tb->addAction(QIcon(theIconPath+"deselect.svg"),"Deselect",chgl,SLOT(disSelection())); a->setVisible(false); chgl->centroid=a=tb->addAction(QIcon(theIconPath+"centroid.svg"), "Create Centroid", this , SLOT(createCentroid())); a->setVisible(false); chgl->cntrPlot = a = tb->addAction(QIcon(theIconPath+"cont.svg"),"Create Contour Plot",this, SLOT(contourPlot())); a->setVisible(false); chgl->nocntrPlot = a = tb->addAction(QIcon(theIconPath+"nocont.svg"),"Remove Contour Plot",this, SLOT(nocontourPlot())); a->setVisible(false); chgl->centerSelection=a=tb->addAction(QIcon(theIconPath+"center.svg"),"Center Selected Atoms",chgl,SLOT(homeXY())); a->setCheckable(true); a->setChecked(false); a->setVisible(false); chgl->invSelection=a=tb->addAction(QIcon(theIconPath+"invsel.svg"),"Invert Selection",chgl,SLOT(invertSelection())); a->setVisible(false); chgl->hideNotSelection=a=tb->addAction(QIcon(theIconPath+"hide.svg"),"Hide Other Atoms",chgl,SLOT(hideNonSelected())); a->setVisible(false); a=chgl->hideHydrogen=tb->addAction(QIcon(theIconPath+"hideh.svg"),"Hide Hydrogen Atoms",chgl,SLOT(hideHydrogens())); a->setVisible(false); chgl->unhide=a=tb->addAction(QIcon(theIconPath+"show.svg"),"Show All Hidden",chgl,SLOT(showHidden())); connect(a,SIGNAL(triggered()),qpv,SLOT(unhide())); a->setVisible(false); chgl->invhide=a=tb->addAction(QIcon(theIconPath+"invshow.svg"),"Toggle Visibility ",chgl,SLOT(invertHidden())); a->setVisible(false); chgl->shpm1=a=tb->addAction(QIcon(theIconPath+"part-1.svg"),"Hide PART -N Ghost",chgl,SLOT(hidePartMinusOne(bool ))); a->setCheckable(true); a->setChecked(false); a->setVisible(false); a->setToolTip("Hide PART -N symmetry equivalent as ghost Atoms"); //printf("line %d\n",__LINE__); chgl->highlightParts=a=tb->addAction(QIcon(theIconPath+"parts.svg"),"Highlight PARTs",chgl,SLOT(update())); a->setCheckable(true); a->setChecked(false); a->setVisible(false); a=chgl->delSelAt = tb->addAction(QIcon(theIconPath+"killselected.svg"),"Delete Selected Atoms",this,SLOT(deleteSelectedAtoms())); a->setData(-1); a->setShortcut(Qt::CTRL|Qt::Key_Delete); a->setVisible(false); addToolBarBreak(); addToolBar(Qt::TopToolBarArea,tb); } { QAction *a; a=packMenu->addAction("Pack cell",this,SLOT(fillCell())); a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_U); a=packMenu->addAction("Expand all contacts",this,SLOT(expandAll())); a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_X); //a=packMenu->addAction("Complete asymmetric unit" ,this,SLOT(grow_plus())); a=packMenu->addAction("Complete" ,this,SLOT(complete())); a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_C); a=packMenu->addAction("Pack inside given limits",this,SLOT(packInLimits())); a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_I); } menuBar()->addMenu(fileMenu); menuBar()->addMenu(editMenu); menuBar()->addMenu(dialogMenu); menuBar()->addMenu(viewMenu); menuBar()->addMenu(packMenu); menuBar()->addMenu(runMenu); menuBar()->addMenu(extraMenu); fcvsfoAct=fcoMenu->addAction("Fc vs Fo",this,SLOT(foversusfc())); fcvsfoAct->setDisabled(true); calcAct=fcoMenu->addAction("Crystallographic Calculator",this,SLOT(calculator())); calcAct->setEnabled(true); fcoMenu->addAction("Fractal Dimension Analysis (Henn-Meindl-plot)",this,SLOT(jnk())); fcoMenu->addAction("Plot Atomic Scattering Factors SFAC ", editor, SLOT(plotSFAC())); dsrAct = fcoMenu->addAction("DSR Plugin",this,SLOT(create_DSRGui())); dsrAct->setEnabled(true); dsrAct->setShortcut(Qt::ALT | Qt::Key_D); menuBar()->addMenu(fcoMenu); //printf("line %d\n",__LINE__); { helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction("Help ", this, SLOT(linkHelp())); helpMenu->addAction(QWhatsThis::createAction(this)); helpMenu->addAction(tr("About"), this, SLOT(aboutXLE())); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); //helpMenu->addAction("Check for New Versions Now",this,SLOT(checkForUpdates())); helpMenu->addAction("Show Key Bindings", this, SLOT(hereAreMyKeys())); } chgl->rCenter = new QToolButton(); chgl->rCenter->setText("Reset Rotation Center"); connect(chgl->rCenter,SIGNAL(clicked()), chgl,SLOT( rotCenter())); chgl->rCenter->hide(); chgl->invertMouseZoom = new QToolButton(this); chgl->invertMouseZoom->setIcon(QIcon(theIconPath+"invzoom.svg")); chgl->invertMouseZoom->setCheckable(true); chgl->invertMouseZoom->setChecked(false); chgl->invertMouseZoom->setText("Invert Mouse Zoom"); chgl->invertMouseZoom->setToolTip("invert mouse zoom (right mouse click and drag up or down"); //* quickReLoadButton = new QToolButton(this); QIcon qrlic =QIcon(); qrlic.addFile(theIconPath+"quick-re-load.png",QSize(), QIcon::Normal, QIcon::Off ); qrlic.addFile(theIconPath+"quick-re-load_on.png",QSize(), QIcon::Normal, QIcon::On ); quickReLoadButton->setIcon(qrlic); quickReLoadButton->setCheckable(true); //Too many problems with this feature 11.03.2021 quickReLoadButton->setChecked(false); quickReLoadButton->hide(); quickReLoadButton->setText("Enable QuickReLoad"); quickReLoadButton->setToolTip("QuickReLoad updates the structure instead of fresh reloading it"); //*/ homeMe = new QToolButton(this); homeMe->setIcon(QIcon(theIconPath+"home.svg")); homeMe->setText("home"); homeMe->setToolTip("move molecules home"); connect(homeMe,SIGNAL(clicked()),chgl,SLOT(homeXY())); qGrowPeak = new QCheckBox("grow Q-peaks"); connect(qGrowPeak,SIGNAL(toggled(bool)),this,SLOT(growQPeaks(bool))); search4duplicates = new QCheckBox("search for duplicates"); search4duplicates->setChecked(true); connect(search4duplicates,SIGNAL(toggled(bool)),this,SLOT(duplicates())); //printf("line %d\n",__LINE__); sLabel = new QLabel; sLabel->setFrameStyle(QFrame::Panel ); sLabel->setLineWidth(2); sLabel->setText(QString("%1").arg(PROGRAM_NAME)); zoomIn = new QToolButton (this); zoomIn-> setIcon(QIcon(theIconPath+"zoom-in.svg")); zoomIn->setText("Zoom +"); zoomIn->setToolTip("Zoom +"); zoomIn->setAutoRepeat(true); zoomIn->setAutoRepeatDelay(150); zoomIn->setAutoRepeatInterval(3); zoomOut = new QToolButton(this); zoomOut->setIcon(QIcon(theIconPath+"zoom-out.svg")); zoomOut->setText("Zoom -"); zoomOut->setToolTip("Zoom -"); zoomOut->setAutoRepeat(true); zoomOut->setAutoRepeatDelay(150); zoomOut->setAutoRepeatInterval(3); connect(zoomIn,SIGNAL(pressed ()),this,SLOT(zoomin())); connect(zoomOut,SIGNAL(pressed ()),this,SLOT(zoomout())); //connect(chgl,SIGNAL(no_hw_st()),no_stereo,SLOT(toggle())); fvused = new QLabel(""); QCheckBox *autoupdate = new QCheckBox("?FPS?"); autoupdate->setChecked(false); connect(autoupdate, &QCheckBox::stateChanged, chgl, &PlayOpenGL::toggleAutoUpdate); lodsp = new QSpinBox(); lodsp->setPrefix("LOD = "); lodsp->setRange(2, 8); lodsp->setValue(chgl->mol->LOD); #if (QT_VERSION >= 0x050f10) connect(lodsp, &QSpinBox::valueChanged, chgl, &PlayOpenGL::setLOD); #else connect(lodsp, SIGNAL(valueChanged(int)), chgl, SLOT(setLOD(int))); #endif statusBar(); statusBar()->addPermanentWidget(fvused); statusBar()->addPermanentWidget(autoupdate); statusBar()->addPermanentWidget(lodsp); //statusBar()->addPermanentWidget(chgl->pickRadSpin); statusBar()->addPermanentWidget(chgl->rCenter); statusBar()->addPermanentWidget(chgl->enviButt); statusBar()->addPermanentWidget(chgl->enviSelect); statusBar()->addPermanentWidget(qGrowPeak); statusBar()->addPermanentWidget(search4duplicates); statusBar()->addPermanentWidget(zoomIn); statusBar()->addPermanentWidget(zoomOut); statusBar()->addPermanentWidget(homeMe); statusBar()->addPermanentWidget(chgl->invertMouseZoom); statusBar()->addPermanentWidget(quickReLoadButton); statusBar()->addPermanentWidget(fxle->keepIso); statusBar()->addPermanentWidget(fxle->doMaps); statusBar()->addPermanentWidget(fxle->ownfcf6); QCheckBox *hideToolBars = new QCheckBox("Hide Tool Bars"); hideToolBars->setChecked(false); connect(hideToolBars,SIGNAL(toggled(bool)),this,SLOT(hideToolz(bool))); statusBar()->addPermanentWidget(hideToolBars); statusBar()->addPermanentWidget(sLabel); connect(fxle,SIGNAL(bigmessage(const QString&)),this,SLOT(infoKanalNews(const QString&))); shxEditorDock->hide(); printf("now settings\n"); ////////////////////////////// SETTINGS ///////////////////////////////////////////////////////////////////////// mole.loadSettings(); einstellung->beginGroup("Window"); useNativeDlg->setChecked(einstellung->value("nativeDialogs",true).toBool()); chgl->invertMouseZoom->setChecked( einstellung->value("InvertMouseZoom").toBool()); //Too many issues with this feature 11.03.2021 //quickReLoadButton->setChecked( einstellung->value("QuickReLoad",true).toBool()); //connect(quickReLoadButton, SIGNAL(toggled(bool)), this, SLOT(loadAFile())); bool bbb=true; chgl->SDM_Limit=einstellung->value("SDM-LIMIT", 350).toInt(); if (einstellung->contains("HighlightEquivalents")){ bool bb; equivHighlighting->setChecked(bb=einstellung->value("HighlightEquivalents").toBool()); mole.highlightEquivalents=bb; } //printf("line %d\n",__LINE__); if (einstellung->contains("ADPs")) chgl->adp->setChecked(bbb=einstellung->value("ADPs").toBool()); if (einstellung->contains("Tubes")) chgl->tubes->setChecked(bbb=einstellung->value("Tubes").toBool()); if (einstellung->contains("Legend")) chgl->atomLegend->setChecked(einstellung->value("Legend").toBool()); if (einstellung->contains("ShowLabels")) togLabel->setChecked(bbb=einstellung->value("ShowLabels").toBool()); chgl->setLabels(togLabel->isChecked()); //printf("line %d\n",__LINE__); if (einstellung->contains("ShortLabels")) chgl->shortLabels->setChecked(bbb=einstellung->value("ShortLabels").toBool()); if (einstellung->contains("BackGroundGradient")) togBackGr->setChecked(bbb=einstellung->value("BackGroundGradient").toBool()); chgl->setBGGradient(togBackGr->isChecked()); /* if (einstellung->contains("WireModelOnRotate")) chgl->wireButt->setChecked(einstellung->value("WireModelOnRotate").toBool()); */ shelxlPath="shelxl"; if (einstellung->contains("SHELXL-PATH")) shelxlPath=einstellung->value("SHELXL-PATH").toString(); shelxlArgs=""; if (einstellung->contains("SHELXL-OPTION")) shelxlArgs=einstellung->value("SHELXL-OPTION").toString(); useMyBArray = false; // If true, ShelXle does not override b-array value if (einstellung->contains("SHELXL-BARRAY")) { useMyBArray=einstellung->value("SHELXL-BARRAY").toBool(); } einstellung->endGroup(); //printf("line %d\n",__LINE__); einstellung->beginGroup("Files"); dirName = einstellung->value("lastFile").toString(); QStringList files = einstellung->value("recentFileList").toStringList(); foreach (QWidget *widget, QApplication::topLevelWidgets()) { Window *mainWin = qobject_cast(widget); if (mainWin) mainWin->updateRecentFileActions(); } einstellung->endGroup(); einstellung->beginGroup("Colors"); chgl->backGroundColor=einstellung->value("BackGroundColor",QColor("lightskyblue")).value(); chgl->labelColor=einstellung->value("LabelColor").value(); chgl->labelBGColor = einstellung->value("LabelBGColor", QColor(0,0,0,0)).value(); chgl->focusedLabelBGColor = einstellung->value("focusedLabelBGColor", QColor(0,0,0,10)).value(); chgl->focusedLabelColor = einstellung->value("focusedLabelColor", QColor(255,255,0,255)).value(); chgl->selectedLabelBGColor = einstellung->value("selectedLabelBGColor", QColor(0,0,0,51)).value(); chgl->selectedLabelColor = einstellung->value("selectedLabelColor", QColor(135, 206, 235 ,255)).value(); /*printf("alphas %x %x %x %x %x %X", chgl->labelBGColor.alpha(), chgl->focusedLabelBGColor.alpha(), chgl->selectedLabelBGColor.alpha(), chgl->selectedLabelColor.alpha(), chgl->focusedLabelColor.alpha(), QColor(0u).alpha());*/ if (QString(PROGRAM_NAME).compare("shelXle")==0){ darkTheme->setChecked(einstellung->value("darkTheme","false").toBool()); } darkEdit(); einstellung->endGroup(); int ignore=QMessageBox::No; einstellung->beginGroup("Updates"); if (einstellung->contains("IgnoreUpdates")) ignore=einstellung->value("IgnoreUpdates").toInt(); einstellung->endGroup(); net = new QNetworkAccessManager(this); if (ignore!=QMessageBox::No){ checkForUpdates(); //connect(net, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); //reply = net->get(QNetworkRequest(QUrl("http://shelxle.org/shelx/revision.php"))); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// extraProgramNames.clear(); extraProgramPaths.clear(); extraArguments.clear(); extraExtensions.clear(); extraResIns.clear(); extraOpenFileDialogBefore.clear(); extraIconOverlay.clear(); extraOverlayPointSize.clear(); einstellung->beginGroup("Extra"); int siz=0; siz=einstellung->beginReadArray("ProgramNames"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraProgramNames.append(einstellung->value("Name","").toString()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("ProgramPaths"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraProgramPaths.append(einstellung->value("Path","").toString()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("ProgramArgs"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraArguments.append((Qt::CheckState) einstellung->value("Arg").toInt()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("ProgramExtensions"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraExtensions.append((Qt::CheckState)einstellung->value("Ext",0).toInt()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("ProgramResIns"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraResIns.append((Qt::CheckState)einstellung->value("Res2Ins",0).toInt()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("FileDialog"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraOpenFileDialogBefore.append((Qt::CheckState)einstellung->value("fd",0).toInt()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("IconOverlay"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraIconOverlay.append((Qt::CheckState)einstellung->value("icov",2).toInt()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("OverlayPointSize"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraOverlayPointSize.append(einstellung->value("icov",36).toInt()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("AltExtraIconPaths"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); altExtraIconPaths.append(einstellung->value("altIcon","").toString()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("ProgramDetached"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraDetach.append((Qt::CheckState)einstellung->value("Detach",0).toInt()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("AlternativeExtensions"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraExt2.append(einstellung->value("ext","").toString()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("CommandLineOptions"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraOptions.append(einstellung->value("opt","").toString()); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginReadArray("AbsolutePathRequired"); for (int i = 0; i < siz; i++) { einstellung->setArrayIndex(i); extraAbsolutePath.append(static_cast(einstellung->value("absolute",0).toInt())); } einstellung->endArray(); einstellung->endGroup(); /* einstellung->beginGroup("SaveHint"); if (einstellung->contains("ShowRenameHint")) hintL->setVisible(einstellung->value("ShowRenameHint").toBool()); einstellung->endGroup(); */ hintL->hide(); { extraMenu->addAction("add or remove external programs",this,SLOT(extraSettings())); } if (extraProgramNames.size()) extraMenu->addSeparator(); QFileIconProvider *epic = new QFileIconProvider(); extraTB= new QToolBar("External Program Tool Bar",this); extraTB->setObjectName("ExtraTB"); extraTB->setToolButtonStyle(Qt::ToolButtonIconOnly); for (int i=0; iicon(QFileInfo(icopa)); //qDebug()<setPen(QPen(QColor("#FFFFFF"))); QFont ifont=chgl->myFont; ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); paint->setFont(ifont); paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); paint->setPen(QPen(QColor("#000000"))); paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); paint->end(); } extraIcon=QIcon(fmap); a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); a->setData(i); extraTB->addAction(a); } delete epic; addToolBar(extraTB); extraOutput = new QDialog(this); lt = new QVBoxLayout(); extraOutPut = new QTextEdit(); QFont mospfo(FONTFAM); extraOutPut->setFont(mospfo); #if (QT_VERSION >=0x050000) extraOutput->setMinimumWidth( QFontMetrics(extraOutPut->font()) .horizontalAdvance("###########################################################################################")); #else extraOutput->setMinimumWidth( QFontMetrics(extraOutPut->font()) .width("###########################################################################################")); #endif extraOutPut->setLineWrapMode(QTextEdit::NoWrap); lt->addWidget(extraOutPut); extraOutput->setLayout(lt); #if defined (Q_OS_MAC) //printf("%d\n",__LINE__); setCentralWidget(container); #else setCentralWidget(chgl); #endif //chgl->setMSAA(true); // chgl->update(); //printf("%d\n",__LINE__); einstellung->beginGroup("Window"); bool EditorHasOwnToolBar = einstellung->value("EditorHasOwnToolBar",false).toBool(); if (EditorHasOwnToolBar) shxMW->addToolBar(editToolBar); else addToolBar(editToolBar); adoptAct->setChecked(EditorHasOwnToolBar); QByteArray ba,ba_state = einstellung->value("state").toByteArray(); bool ba_state_ok = false; if (!ba_state.isEmpty()) ba_state_ok = restoreState(ba_state); printf("ba_state_ok ? %d \n",ba_state_ok); QByteArray estate = einstellung->value("EditorState").toByteArray(); if (!estate.isEmpty()) { printf("<< %s %d\n",editor->font().family().toStdString().c_str(),editor->font().pointSize()); shxMW->restoreState(estate); printf(">> %s %d\n",editor->font().family().toStdString().c_str(),editor->font().pointSize()); printf("state: %d\n", estate.size()); //qDebug()<value("geometry").toByteArray(); //qDebug()<=0x050000) size=QSize(screen->geometry().width()-2,screen->geometry().height()-2); #else size=QSize(QApplication::desktop()->screenGeometry().width()-2,QApplication::desktop()->screenGeometry().height()-2); #endif ediSize=QSize(640,480); ediPos=QPoint(0,0); if ((size.height())<45||(size.width()<108)) size=QSize(640,480); QPoint pos; pos=QPoint(1,1); move(pos); if(size.isNull()) resize(640, 480); else resize(size); } einstellung->endGroup(); //printf("%d\n",__LINE__); einstellung->beginGroup("Fonts"); if (einstellung->contains("LabelFont")){ chgl->myFont = einstellung->value("LabelFont").value(); chgl->myFont.setPointSize(einstellung->value("LabelFontSize", 24).toInt()); } if (einstellung->contains("EditorFont")){ QFont fnt; int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); fnt = QFont(family); fnt = einstellung->value("EditorFont").value(); //editor->setFont(fnt); //QFontInfo finfo(fnt); /*if (!fnt.exactMatch()){ printf("Font family; Point size; Pixel size; Style hint; Font weight; Font style; " "Underline; Strike out; Fixed pitch; Always 0; Capitalization; Letter spacing; " "Word spacing; Stretch; Style strategy; Font style (omitted when unavailable)\n"); printf("Font: %s\nFont: %s\n", fnt.toString().toStdString().c_str(), editor->font().toString().toStdString().c_str()); //qDebug()<font().toString().toStdString().c_str()); }else printf("font fits\n"); */ int fosi = einstellung->value("EditorFontSize", 10).toInt(); fnt.setPointSize(fosi); //#if (QT_VERSION >= 0x040700) // fnt.setStyleStrategy(QFont::ForceIntegerMetrics);//not a member anymore //#endif editor->setFont(fnt); printf("Font: %s\nFont: %s\n", fnt.toString().toStdString().c_str(), editor->font().toString().toStdString().c_str()); xlPutor->setFont(fnt); printf("Font from settings %s %d\n", fnt.family().toStdString().c_str(),fnt.pointSize()); } einstellung->endGroup(); einstellung->beginGroup("ToolBar"); if (einstellung->contains("SelectionToolBarStyle")) bottomToolBar->setToolButtonStyle((Qt::ToolButtonStyle) einstellung->value("SelectionToolBarStyle").toInt()); einstellung->endGroup(); einstellung->beginGroup("DoNotAskFileSave"); if (einstellung->contains("DoNotAnnoyMe")) doNotAnnoyMe=einstellung->value("DoNotAnnoyMe",false).toBool(); einstellung->endGroup(); einstellung->beginGroup("Sorting"); if (einstellung->contains("SortingOption")){ editor->sortierWeise = einstellung->value("SortingOption").toInt(); } einstellung->endGroup(); //printf("%d\n",__LINE__); { sortGroup = new QActionGroup(this); sortMenu = new QMenu("Change sort order",this); QAction *a = sortMenu->addAction("label number > atomic number > label suffix"); sortGroup->addAction(a); a->setCheckable(true); if (editor->sortierWeise==1)a->setChecked(true); a->setData(1); a = sortMenu->addAction("atomic number > label number > label suffix"); sortGroup->addAction(a); a->setCheckable(true); if (editor->sortierWeise==2)a->setChecked(true); a->setData(2); a = sortMenu->addAction("SFAC number > label number > label suffix"); sortGroup->addAction(a); a->setCheckable(true); if (editor->sortierWeise==3)a->setChecked(true); a->setData(3); a = sortMenu->addAction("label suffix > atomic number > label number"); sortGroup->addAction(a); a->setCheckable(true); if (editor->sortierWeise==4)a->setChecked(true); a->setData(4); a = sortMenu->addAction("fragment> atomic number > label number > label suffix"); sortGroup->addAction(a); a->setCheckable(true); if (editor->sortierWeise==5)a->setChecked(true); a->setData(5); a = sortMenu->addAction("U equivalent"); sortGroup->addAction(a); a->setCheckable(true); if (editor->sortierWeise==6)a->setChecked(true); a->setData(6); connect(sortGroup,SIGNAL(triggered(QAction*)), editor,SLOT(changeSortierWeise(QAction*))); runMenu->insertMenu(soact,sortMenu); } einstellung->beginGroup("Labeling"); if (einstellung->contains("AutoUnused")){ rufModeBox->setChecked(einstellung->value("AutoUnused").toBool()); } einstellung->endGroup(); tbiconSize=32; einstellung->beginGroup("ToolBarIcons"); if (einstellung->contains("ToolBarIconSize")){ tbiconSize=einstellung->value("ToolBarIconSize").toInt(); } einstellung->endGroup(); tbiconSize=qMin(tbiconSize,96); tbiconSize=qMax(tbiconSize,16); fito->setIconSize(QSize(tbiconSize,tbiconSize)); editToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); refineToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); vito->setIconSize(QSize(tbiconSize,tbiconSize)); extraTB->setIconSize(QSize(tbiconSize,tbiconSize)); bottomToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); chgl->invertMouseZoom->setIconSize(QSize(tbiconSize,tbiconSize)); quickReLoadButton->setIconSize(QSize(tbiconSize,tbiconSize)); homeMe->setIconSize(QSize(tbiconSize,tbiconSize)); zoomIn->setIconSize(QSize(tbiconSize,tbiconSize)); zoomOut->setIconSize(QSize(tbiconSize,tbiconSize)); /// { scalDlg = new QDialog(this); scalDlg->setWindowTitle("Change screen-shot scalefactor"); scalla = new QGridLayout(); scalwla = new QLabel("Width: "); scalhla = new QLabel("Height: "); scalsla = new QLabel("Scalefactor: "); widthBox = new QSpinBox(); heightBox = new QSpinBox(); scalefBox = new QDoubleSpinBox(); widthBox->setMinimum(32); widthBox->setMaximum(10000); widthBox->setSuffix(" pixels"); widthBox->setObjectName("widthBox"); heightBox->setMinimum(32); heightBox->setMaximum(10000); heightBox->setSuffix(" pixels"); heightBox->setObjectName("heightBox"); scalefBox->setMinimum(1); scalefBox->setMaximum(400.0); scalefBox->setSuffix(" %"); scalefBox->setValue(scalePic*100.0); scalefBox->setObjectName("scalefBox"); header = new QLabel("

Change screen-shot scalefactor

"); scalla->addWidget(header ,0,0,1,3); scalla->addWidget(scalwla ,1,0); scalla->addWidget(widthBox ,1,1); scalla->addWidget(scalhla ,2,0); scalla->addWidget(heightBox,2,1); scalla->addWidget(scalsla ,3,0); scalla->addWidget(scalefBox,3,1); scalDlg->setLayout(scalla); scalDlg->hide(); connect(widthBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); connect(heightBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); connect(scalefBox,SIGNAL(valueChanged(double)),this,SLOT(updateScaleDlg())); } ///////////// toggDocWid(true); raise(); double vang=0; #if (QT_VERSION >= 0x040600) dirName = (QProcessEnvironment::systemEnvironment ().value("PWD",dirName)); #else { QStringList env = QProcess::systemEnvironment(); int da = env.indexOf(QRegularExpression("^PWD=.*$")); if (da>-1) { dirName = QString(env.at(da)).remove(0,4); } } #endif QString ffna=""; startFused=false; int argc=QCoreApplication::arguments().size(); if (argc>1){ for (int i=1;iMYFCF=true; if ((QCoreApplication::arguments().at(i).endsWith(".ins",Qt::CaseInsensitive)) || (QCoreApplication::arguments().at(i).endsWith(".res",Qt::CaseInsensitive))) ffna=QCoreApplication::arguments().at(i); if ((QCoreApplication::arguments().at(i)=="-fused")) startFused=true; if ((QCoreApplication::arguments().at(i)=="-HKLMAX")) fxle->HKLMX = QCoreApplication::arguments().at(i+1).toInt(); if ((QCoreApplication::arguments().at(i)=="-viewangle")) vang = QCoreApplication::arguments().at(i+1).toDouble(); if ((QCoreApplication::arguments().at(i)=="-voxel")) fxle->voxelstr = QCoreApplication::arguments().at(i+1); if ((QCoreApplication::arguments().at(i)=="-shaderInfo")) shaderInfo=true; //if ((QCoreApplication::arguments().at(i)=="-wt")) { chgl->dratpause = QCoreApplication::arguments().at(i+1).toInt();} } } //printf("%d\n",__LINE__); //chgl->update(); //if (vang>0.0) chgl->setViewAngle(vang); einstellung->beginGroup("ViewSettings"); if (einstellung->contains("OrthographicProjection")) { bool b=einstellung->value("OrthographicProjection").toBool(); chgl->toggleOrthoView->setChecked(b); chgl->toggleOrtho(b); //toggleOrtho(b); } einstellung->endGroup(); //printf("%d\n",__LINE__); qPeakDock->setVisible(true); shxEditorDock->hide(); shxOutputDock->hide(); if (!ffna.isEmpty()) { dirName=ffna; printf("I will load this: %s.\n",ffna.toStdString().c_str()); //connect(chgl, SIGNAL(initialized()), this, SLOT(loadAFile())); connect(chgl, SIGNAL(initialized()), this, SLOT(delayedLoad())); } printf("Window constructor finished.\n"); #include "WhatsThisAndWhere.h" lastDirName=""; //printf("%d\n",__LINE__); } Window::~Window() { //printf("close?? this %p calcmenu %p dsr %p sortmenu%p hidwillpse %p fxle%p chgl%p\n", this,calcmenu,dsr,sortMenu,hidwillpse,fxle,chgl); if (fxle!=NULL) delete fxle; //printf("OK!%d\n",__LINE__); if (calcmenu!=NULL) { calcmenu->close(); delete calcmenu;//only delete it if it has been created. (seg fault) } if (dsr!=NULL) { dsr->close(); delete dsr; } //printf("OK!%d\n",__LINE__); } int Window::Version(){ return Revision; } void Window::hereAreMyKeys(){ actionInfo.clear(); actionInfo.append(""); QWidgetList wl = QApplication::allWidgets(); QStringList shorts; for (int i=0; i acs = wl.at(i)->actions(); for (int j=0; jshortcut().toString(); QIcon ic=acs.at(j)->icon(); if (!st.isEmpty()){ QString kb=acs.at(j)->shortcut().toString().replace(QRegularExpression("\\+"),"] + ["); kb=kb.replace("+ [] + [","+ [+"); #if defined (Q_OS_MAC) kb=kb.replace("Ctrl","⌘");//clover CMD kb=kb.replace("Meta","⌃");//Ctrl kb=kb.replace("Alt","⌥");//Opt kb=kb.replace("Shift","⇧");//shift/ #endif QString ac=acs.at(j)->text(); int und=ac.indexOf('&'); if (und!=-1) { ac=ac.insert(und+2,""); ac=ac.replace('&',""); } ac[0]=ac[0].toUpper(); ac=ac.replace(' '," "); shorts.append(QString("").arg(ac).arg(kb)); } } } shorts.sort(); shorts.removeDuplicates(); for (int i=0; i%1\n").arg(shorts.at(i))); else actionInfo.append(QString("%1\n").arg(shorts.at(i))); } actionInfo.append("
[%2]%1

Try Whats This on empty menu parts for more."); QMessageBox::information(this, "ShelXle Key Bindings", actionInfo); } void Window::fileNative(){ einstellung->beginGroup("Window"); einstellung->setValue("nativeDialogs",useNativeDlg->isChecked()); einstellung->endGroup(); } void Window::darkEdit(){ bool b=darkTheme->isChecked(); bool classic=false; if (QString(PROGRAM_NAME).compare("shelXle")){ //this is BrukerShelXle so we do not use any syle sheets b=false; classic=true; editor->highlighter->loadHighlightPatterns(inspatternfile); xlPutor->highlighter->loadHighlightPatterns(lstpatternfile); qpv->dark=b; return; } maybeSave(); editor->dark=xlPutor->dark=b; qpv->dark=b; if (b){ editor->highlighter->loadHighlightPatterns(inspatternfile_dark); xlPutor->highlighter->loadHighlightPatterns(lstpatternfile_dark); QFile f(":dark/dstyle.qss"); if (!f.exists()) { printf("Unable to set stylesheet, file not found\n"); } else { f.open(QFile::ReadOnly | QFile::Text); QTextStream ts(&f); QString stle=ts.readAll(); if (!classic){ qApp->setStyleSheet(stle); //printf("darkstyle dark!\n"); } } QPalette p = editor->palette(); p.setColor(QPalette::Base,QColor(0xff1e1e1eu)); p.setColor(QPalette::WindowText,QColor(0xffc8c8c8u)); p.setColor(QPalette::Text,QColor(0xffc8c8c8u)); editor->setPalette (p ); p = xlPutor->palette(); p.setColor(QPalette::Base,QColor(0xff1e1e1eu)); p.setColor(QPalette::WindowText,QColor(0xffc8c8c8u)); p.setColor(QPalette::Text,QColor(0xffc8c8c8u)); xlPutor->setPalette (p ); xlPutor->setStyleSheet("QPlainTextEdit {\nbackground-color: #19232D;\ncolor: #E0E1E3;\nborder-radius: 4px;\nborder: 1px solid #455364;\n}"); }else{ editor->highlighter->loadHighlightPatterns(inspatternfile); xlPutor->highlighter->loadHighlightPatterns(lstpatternfile); QFile f(":light/lstyle.qss"); if (!f.exists()) { printf("Unable to set stylesheet, file not found\n"); } else { f.open(QFile::ReadOnly | QFile::Text); QTextStream ts(&f); QString stle=ts.readAll(); if (!classic){ qApp->setStyleSheet(stle); //printf("darkstyle light!\n"); } } QPalette p = xlPutor->palette(); p.setColor(QPalette::WindowText,QColor(0xff000000u)); p.setColor(QPalette::Text,QColor(0xff000000u)); p.setColor(QPalette::Base,QColor(0xffffffffu)); editor->setPalette (p ); p.setColor(QPalette::Base,QColor(0xffffffe6u)); xlPutor->setStyleSheet("QPlainTextEdit {\nbackground-color: #FFFFE6;\ncolor: #19232D;\nborder-radius: 4px;\nborder: 1px solid #C9CDD0;\n}"); xlPutor->setPalette (p ); } einstellung->beginGroup("Colors"); einstellung->setValue("darkTheme",darkTheme->isChecked()); einstellung->endGroup(); if (editor->isVisible()){ printf("reload file!\n"); loadAFile(); } einstellung->beginGroup("Fonts"); if (einstellung->contains("EditorFont")){ QFont fnt; int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); fnt = QFont(family); fnt = einstellung->value("EditorFont").value(); /*QFontInfo finfo(fnt); if (!finfo.exactMatch()){ int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); fnt = QFont(family); }*/ int fosi = einstellung->value("EditorFontSize", 10).toInt(); fnt.setPointSize(fosi); printf("Dark? Font from settings %s %d\n", fnt.family().toStdString().c_str(),fnt.pointSize()); // #if (QT_VERSION >= 0x040700) // fnt.setStyleStrategy(QFont::ForceIntegerMetrics); // #endif editor->setFont(fnt); xlPutor->setFont(fnt); } einstellung->endGroup(); update(); } bool Window::doWeHaveHKLF5here(QStringList &hk5s){ QString dn=dirName.section('/',0,-2); QStringList filter; filter.append("*.hkl"); QStringList files; files = QDir(dn).entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); int cread=-1,bn=0;//chars read //* //Joergs suggestion char buffer[260*2]; memset(buffer, '\0', sizeof(buffer)); char *cline=buffer, *pline=buffer+260, *temp; char batchstr[10]; memset(batchstr, '\0', sizeof(batchstr)); for (int i=0; i28) { //nb++; //strncpy memcpy(batchstr,cline+28,4); batchstr[4]='\0'; bn=atoi(batchstr); bnmax=fmax(bn,bnmax); bnmin=fmin(bn,bnmin); } if ((no != i) && (bnmin < 0) && (0 == memcmp(cline+12, pline+12, 16)) ) {//memcmp(cline+12, pline+12, 16))//strncmp(cline+12, pline+12,16) is_hklf5=true; //printf("|%s|%s|################\n%s",cline+12, pline+12,cline); no=i; hk5s.append(files.at(i)); } temp = pline; pline = cline; cline = temp; }while ((!is_hklf5)&&(cread>0)); //Joergs suggestion // */ /* char line[260],batchpart[120],isigpart[120],asig[120]; for (int j=0; j< 120;j++) {batchpart[j]='\0';isigpart[j]='\0';asig[j]='\0';} //int cread=-1,bn=0;//chars read for (int i=0; i12) { for (int j=12,k=0; j< 28;j++) isigpart[k++]=line[j]; } if (cread>28) { int maxbatch=fmin(cread,32); for (int j=28,k=0; j< maxbatch;j++) batchpart[k++]=line[j]; nb++; //if (cread>33) printf("%d\n%s\n\ %s\n",cread,line,batchpart); bn=atoi(batchpart); bnmax=fmax(bn,bnmax); bnmin=fmin(bn,bnmin); } if ((no!=i)&&(0==strncmp(isigpart,asig,16))&&(bnmin<0)) { is_hklf5=true; no=i; hk5s.append(files.at(i)); //printf("HKLF5 ?? %d %d i=%d bn=%d\n", hk5s.size(), hklf5files.size(), i, bn); } for (int j=0; j< 16;j++) asig[j]=isigpart[j]; }while (cread>0); //*/ /*printf("%s %d lines read bn max %d bn min %d (%d). Think this%s a HKLF5\n", files.at(i).toStdString().c_str(), nl, bnmax, bnmin, nb, (is_hklf5)?"":" not");// */ } return !hk5s.isEmpty(); } void Window::connectEdior(){ //printf("\n\n\nconnectEdior()-->\n"); //editor->dumpObjectInfo (); bool disok=false; disok=editor->disconnect(SIGNAL(saveMe(bool,bool)),this,SLOT(fileSave(bool,bool))); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(updateLabel()),this,SLOT(updateLabel())); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(textChanged ()),this,SLOT(spellCheck())); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(cursorPositionChanged ()),this,SLOT(updateLC())); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(findInStructure(const QString&)),this,SLOT(findInStructure(const QString &))); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(openIncludeFile(const QString&)),this,SLOT(openIncludeFile(const QString &))); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(electInStructure(const QString&)),this,SLOT(selectInStructure(const QString &))); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(textChanged()),this,SLOT(updateSelectResi())); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect(SIGNAL(cursorPositionChanged()),this,SLOT(resiSelectorCheck())); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect( SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); disok=editor->disconnect( SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); //printf("%d %s\n",__LINE__,(disok)?"ok":"no"); //printf("<--connectEdior()-->\n"); //editor->dumpObjectInfo (); //actionUndo->disconnect(); //actionRedo->disconnect(); //actionCut->disconnect(); //actionCopy->disconnect(); //actionPaste->disconnect(); connect(editor,SIGNAL(saveMe(bool,bool)),this,SLOT(fileSave(bool,bool))); connect(editor,SIGNAL(updateLabel()),this,SLOT(updateLabel())); connect(editor,SIGNAL(textChanged ()),this,SLOT(spellCheck())); connect(editor,SIGNAL(cursorPositionChanged ()),this,SLOT(updateLC())); connect(editor,SIGNAL(findInStructure(const QString&)),this,SLOT(findInStructure(const QString &))); connect(editor,SIGNAL(openIncludeFile(const QString&)),this,SLOT(openIncludeFile(const QString &))); connect(editor,SIGNAL(electInStructure(const QString&)),this,SLOT(selectInStructure(const QString &))); connect(editor,SIGNAL(textChanged()),this,SLOT(updateSelectResi())); connect(editor,SIGNAL(cursorPositionChanged()),this,SLOT(resiSelectorCheck())); connect(editor->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect(editor->document(), SIGNAL(modificationChanged(bool)), actionHFix, SLOT(setDisabled(bool))); connect(editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(editor->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(editor->document(), SIGNAL(undoCommandAdded ()), this, SLOT(wasRename())); connect(editor->document(), SIGNAL(undoCommandAdded()),this,SLOT(wasDelete())); connect(editor->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); connect(actionUndo, SIGNAL(triggered()), editor, SLOT(undo())); connect(actionUndo,SIGNAL(triggered()),this,SLOT(undoRename())); connect(actionRedo, SIGNAL(triggered()), editor, SLOT(redo())); connect(actionRedo, SIGNAL(triggered()),this, SLOT(redoRename())); connect(actionCut, SIGNAL(triggered()), editor, SLOT(mcut())); connect(actionCopy, SIGNAL(triggered()), editor, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), editor, SLOT(mpaste())); connect(editor, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(editor, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); connect(editor,SIGNAL(deleteSelected()),this,SLOT(deleteSelectedAtoms())); //editor->dumpObjectInfo (); //printf("<--connectEdior()\n"); } void Window::updateTwinTest(){ //printf("\n\nUPDATE TWIN TEST\n"); Matrix M[6]; M[0] =Matrix ( 0, 1, 0, 1, 0, 0, 0, 0, -1); M[1] =Matrix ( 0, -1, 0, -1, 0, 0, 0, 0, -1); M[2] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, 1); M[3] =Matrix ( 1, 0, 0, 0, -1, 0, 0, 0, -1); M[4] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, -1); M[5] =Matrix ( 1, 0, 0, 0, 1, 0, 0, 0, 1); QString dn=dirName.section('/',0,-2); QString wd=QString("%1/twintest/").arg(dn); bool didsomething=false; for (int m=0; m<6; m++){ if (twinRedundant.at(m)) continue; if (twinDone.at(m)) continue; didsomething=true; //QString insnam=QString("%1test%2.ins").arg(wd).arg(m); //QString insnambase=QString("test%1").arg(m); QString resnam=QString("%1test%2.res").arg(wd).arg(m); QFile res(resnam); if (res.open(QIODevice::ReadOnly|QIODevice::Text)){ //printf("resname=%s\n",resnam.toStdString().c_str()); QString inhalt=res.readAll(); res.close(); if (inhalt.isEmpty()) continue; QStringList basfs=inhalt.section("\nBASF ",1).section("\n",0,0).trimmed().split(" ",skipEmptyParts); bool maybe=true; if (!basfs.isEmpty()) { double basf=basfs.at(0).toDouble(); //printf("BASF %f\n",basf); maybe=((basf>0.04)&&(basf<0.96)); } inhalt = inhalt.section("\nHKLF ",1); QStringList sl2 = inhalt.section("REM wR2 =",1).section("\n",0,0).trimmed().split(",",skipEmptyParts); //REM R1 = 0.0150 for 6927 Fo > 4sig(Fo) and 0.0160 for all 7220 data QStringList sl = inhalt.section("REM R1 =",1).section("\n",0,0).trimmed().split(" ",skipEmptyParts); if (sl.size()<11)continue; if (sl2.size()<1) maybe=maybe&&(sl.at(0).toDouble()*100.0<=(rvalue2beat+0.075)); else maybe=maybe&&(sl2.at(0).toDouble()*100.0<=(wr2value2beat+0.075)); /*printf("m=%d R1 %5.2f %d all %5.2f %d %s (%f)\n", m, sl.at(0).toDouble()*100.0, sl.at(2).toInt(), sl.at(7).toDouble()*100.0, sl.at(10).toInt(), (maybe)?"probably a twin":"not realy likely a suitabe twin law", rvalue2beat );*/ QString Label= QString("TWIN %1 %2 %3 %4 %5 %6 %7 %8 %9 %10") .arg(M[m].m11).arg(M[m].m21).arg(M[m].m31) .arg(M[m].m12).arg(M[m].m22).arg(M[m].m32) .arg(M[m].m13).arg(M[m].m23).arg(M[m].m33) .arg((m==5)?"= no twin law for comparison":""); QGroupBox *gpx2 = new QGroupBox(Label,twinDlg); gpx2->setAlignment(Qt::AlignRight); gpx2->setCheckable(true); gpx2->setChecked(maybe); QVBoxLayout *v = new QVBoxLayout(gpx2); QHBoxLayout *hbl1 = new QHBoxLayout(); double basfv=basfs.at(0).toDouble(); QLabel *R1lab = new QLabel(QString("R1=%1\nafter applying\ntwin law").arg(sl.at(0).toDouble()*100.0,0,'f',2),twinDlg); R1lab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(hw->rwert_farbverlauf(sl.at(0).toDouble()*300.0).name())); if (sl2.size()>0){ QLabel *wR2lab = new QLabel(QString("wR2=%1\nafter applying\ntwin law").arg(sl2.at(0).toDouble()*100.0,0,'f',2),twinDlg); wR2lab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(hw->rwert_farbverlauf(sl2.at(0).toDouble()*300.0).name())); QLabel *beatlab = new QLabel(QString("curent \nR1 =%1\nwR2= %2").arg(rvalue2beat,0,'f',2).arg(wr2value2beat,0,'f',2),twinDlg); beatlab->setStyleSheet(QString("QLabel { background-color : qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 %1, stop: 1 %2); color : white; }") .arg(hw->rwert_farbverlauf(rvalue2beat*3.0).name()) .arg(hw->rwert_farbverlauf(wr2value2beat*3.0).name())); QLabel *BASFlab = new QLabel(QString("BASF = %1").arg(basfv,0,'f',4),twinDlg); BASFlab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(((basfv>0.04)&&(basfv<0.96))?"#009933":"#990033")); hbl1->addWidget(beatlab); hbl1->addWidget(R1lab); hbl1->addWidget(wR2lab); hbl1->addWidget(BASFlab); }else{// old xl versions do not rem the wR2 value QLabel *beatlab = new QLabel(QString("curent \nR1 =%1").arg(rvalue2beat,0,'f',2),twinDlg); beatlab->setStyleSheet(QString("QLabel { background-color : %1; white; }") .arg(hw->rwert_farbverlauf(rvalue2beat*3.0).name()) ); QLabel *BASFlab = new QLabel(QString("BASF = %1").arg(basfv,0,'f',4),twinDlg); BASFlab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(((basfv>0.04)&&(basfv<0.96))?"#009933":"#990033")); hbl1->addWidget(beatlab); hbl1->addWidget(R1lab); hbl1->addWidget(BASFlab); } //if (maybe){ QAction *tryThisTwin = new QAction("insert this twin \nlaw in res file",twinDlg); tryThisTwin->setEnabled(maybe); tryThisTwin->setData(QString("%1\nBASF %2\n").arg(Label).arg(basfv,0,'f',4)); connect(tryThisTwin,SIGNAL(triggered()),this,SLOT(insertTwin())); connect(tryThisTwin,SIGNAL(triggered()),twinDlg,SLOT(reject())); QToolButton *button =new QToolButton(twinDlg); button->setDefaultAction(tryThisTwin); connect(gpx2,SIGNAL(toggled(bool)),button,SLOT(setEnabled(bool))); if (m==5) { gpx2->setChecked(false); gpx2->setCheckable(false); button->setEnabled(false); } //button->setEnabled(maybe); hbl1->addWidget(button); //} v->addLayout(hbl1); twinvbl->addWidget(gpx2); twinDone[m]=true; twingpx->adjustSize(); } }// */ if (didsomething){ twinDlg->update(); twinDlg->show(); }else {twinpatlab->hide();} } void Window::testMerohedral(){ Matrix M[6]; M[0] =Matrix ( 0, 1, 0, 1, 0, 0, 0, 0, -1); M[1] =Matrix ( 0, -1, 0, -1, 0, 0, 0, 0, -1); M[2] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, 1); M[3] =Matrix ( 1, 0, 0, 0, -1, 0, 0, 0, -1); M[4] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, -1); M[5] =Matrix ( 1, 0, 0, 0, 1, 0, 0, 0, 1); twinRedundant.clear(); twinDone.clear(); for (int i=0; i0)&&(m!=n)&&(tm==M[n])) {printf("Matrix %d %d %d is redundant\n",m,i,n); twinRedundant[m]=true; printf("\nX%9.3f %9.3f %9.3f\nX%9.3f %9.3f %9.3f\nX%9.3f %9.3f %9.3f\n\n" ,tm.m11 ,tm.m21 ,tm.m31 ,tm.m12 ,tm.m22 ,tm.m32 ,tm.m13 ,tm.m23 ,tm.m33 ); } } } } QFile res(dirName); res.open(QIODevice::ReadOnly|QIODevice::Text); QString inhalt=res.readAll(); res.close(); inhalt = inhalt.section("\nHKLF ",1); //REM wR2 = 0.176801, GooF = S = 1.14341, Restrained GooF = 1.14341 for all data QStringList sl2 = inhalt.section("REM wR2 =",1).section("\n",0,0).trimmed().split(",",skipEmptyParts); //REM R1 = 0.0150 for 6927 Fo > 4sig(Fo) and 0.0160 for all 7220 data QStringList sl = inhalt.section("REM R1 =",1).section("\n",0,0).trimmed().split(" ",skipEmptyParts); rvalue2beat=99.0; wr2value2beat=99.0; if (sl.size()>10) rvalue2beat=sl.at(0).toDouble()*100.0; if (sl2.size()>1) wr2value2beat=sl2.at(0).toDouble()*100.0; QString dn=dirName.section('/',0,-2); QString hkl=dirName; hkl=hkl.replace(resorins,".hkl"); QString wd=QString("%1/twintest/").arg(dn); QDir work=QDir(wd); if (!work.exists()) work.mkdir(wd); else{ QStringList filter; filter << QString("*.*"); QStringList files; files=work.entryList(filter,QDir::Files); for (int i=0; isetWorkingDirectory(wd); //qDebug()<hide(); delete twinDlg; } twinDlg = new QDialog(this); twingpx =new QGroupBox("Possible twin laws for this structure:",twinDlg); twinvbl = new QVBoxLayout(); QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Cancel,Qt::Horizontal,twinDlg); connect(bb, SIGNAL(rejected()), twinDlg, SLOT(reject())); twingpx->setLayout(twinvbl); QVBoxLayout *la = new QVBoxLayout(); QScrollArea *qsa = new QScrollArea(twinDlg); twingpx->setMinimumSize(590,650); qsa->setWidget(twingpx); qsa->setMinimumSize(600,660); la->addWidget(qsa); la->addWidget(bb); twinDlg->setLayout(la); twinvbl->addWidget(twinpatlab = new QLabel("...please wait until some twin laws are checked...")); updateTwinTest(); //QList alleboxen; //QSignalMapper *map = new QSignalMapper(this); for (int m=0; m<6; m++){ if (twinRedundant.at(m)) continue; QString insnam=QString("%1test%2.ins").arg(wd).arg(m); QString insnambase=QString("test%1").arg(m); QProcess *shelxl0 = new QProcess(this); shelxl0->setWorkingDirectory(wd); QFile f(insnam); f.open(QIODevice::ReadOnly|QIODevice::Text); QString all = f.readAll(); f.close(); all=all.replace(QRegularExpression("\nACTA[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no acta! all=all.replace(QRegularExpression("\nTWIN[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no TWIN! all=all.replace(QRegularExpression("\nBASF[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no basf! all=all.replace(QRegularExpression("\nAFIX[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no afix! all=all.replace(QRegularExpression("\nL.S.[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no L.S.! int unitpos=all.indexOf("UNIT",0,Qt::CaseInsensitive); int afterunitpos=all.indexOf("\n",unitpos); all=all.insert(afterunitpos+1,QString("TWIN %1 %2 %3 %4 %5 %6 %7 %8 %9 2\nBASF 0.41\nL.S. 10\nAFIX 6\n") .arg(M[m].m11).arg(M[m].m21).arg(M[m].m31) .arg(M[m].m12).arg(M[m].m22).arg(M[m].m32) .arg(M[m].m13).arg(M[m].m23).arg(M[m].m33)); f.open(QIODevice::WriteOnly|QIODevice::Text); f.write(all.toLatin1()); f.close(); QStringList al; al.append(insnambase); connect(shelxl0,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateTwinTest())); connect(shelxl0,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateTwinTest())); shelxl0->start(shelxlPath,al); //shelxl0->waitForFinished(); //fprintf(stderr,"\n!![%s]\n",shelxl0->readAllStandardOutput().data()); //fprintf(stderr,"\n!![%s]\n",shelxl0->readAllStandardError().data()); } QTimer::singleShot(5000,twinpatlab,SLOT(hide())); } void Window::insertTwin(){ QAction *action = qobject_cast(sender()); QString insertthis; if (action) insertthis=action->data().toString(); else return; QTextDocument *document = editor->document(); QTextCursor cursor = editor->textCursor(); cursor.beginEditBlock(); editor->replace->setText(""); editor->searchLE->setText("^TWIN"); editor->wholeLine->setChecked(true); editor->replaceAll(); editor->searchLE->setText("^BASF"); editor->replaceAll(); editor->replace->setText(""); editor->searchLE->setText(""); editor->wholeLine->setChecked(false); cursor.movePosition(QTextCursor::Start); cursor = document->find(unitinst,cursor); cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); cursor.insertText(insertthis); cursor.endEditBlock(); } void Window::idleRotStart(){ if ((ydleStart!=NULL)&&(ydleStop!=NULL)){ ydleStart->setVisible(false); ydleStop->setVisible(true); ydleStart->setEnabled(false); ydleStop->setEnabled(true); } chgl->idl = new QTimer(this); chgl->idl_end = new QTimer(this); connect(chgl->idl, SIGNAL(timeout()), chgl, SLOT(rotateIdle( ))); connect(this,SIGNAL(movedByUser()), this, SLOT(idleRotStop())); if (chgl!=NULL) connect(chgl,SIGNAL(movedByUser()), this, SLOT(idleRotStop()));//we have a signal in chgl as well chgl->idl->start(5); chgl->idl_end->singleShot(36000,this,SLOT(idleRotStop()));//stop this after ca 10 rotations 360/0.5 * 5 *10 // printf("start rotation %d\n",chgl->idl->timerId()); } void Window::idleRotStop(){ if ((ydleStart!=NULL)&&(ydleStop!=NULL)){ ydleStart->setVisible(true); ydleStop->setVisible(false); ydleStart->setEnabled(true); ydleStop->setEnabled(false); } disconnect(this,SIGNAL(movedByUser()),this, SLOT(idleRotStop())); if (chgl!=NULL) { disconnect(chgl,SIGNAL(movedByUser()), this, SLOT(idleRotStop()));//we have a signal in chgl as well if (chgl->idl==NULL) return; } chgl->idl->stop(); chgl->idl->disconnect(); chgl->idl->deleteLater(); // printf("stop rotation\n"); } void Window::setMonoQ(bool vis){ mole.monoQrom=!vis; chgl->update(); } void Window::foversusfc(){ QString fcfname = dirName; fcfname.replace(resorins,".fcf"); FcVsFo *d = new FcVsFo(fcfname,mole.cell.a, mole.cell.b, mole.cell.c, mole.cell.al, mole.cell.be, mole.cell.ga, mole.cell.wave); connect(d,SIGNAL(weg(const QString &)), editor,SLOT(omitsome(const QString &))); d->exec(); delete d; } void Window::toggleHFSAO(bool on){ mole.HFixSuitableAtomsOnly=on; einstellung->beginGroup("HFIX"); //HFixSuitableAtomsOnly= einstellung->setValue("HFixSuitableAtomsOnly0",on); einstellung->endGroup(); } void Window::togOMIT(bool b){ QGroupBox *gpx = findChild("worstReflectionsGPX"); if (gpx!=nullptr){ QList ck = gpx->findChildren(); for (int i=0; isetChecked(b); } update(); //printf("toggled %d boxes...\n",ck.size()); }else{ printf("cant't find worstReflectionsGPX"); } } void Window::selOmitG5(){ QGroupBox *gpx = findChild("worstReflectionsGPX"); if (gpx!=nullptr){ QList ck = gpx->findChildren(); for (int i=0; isetChecked(false); QString s=ck[i]->text(); QStringList num = s.split(" ",skipEmptyParts); if ((num.size()==8)&&(num.at(5).toDouble()>5.0)){ ck[i]->setChecked(true); } } update(); }else{ printf("cant't find worstReflectionsGPX"); } } void Window::selOmitG10(){ QGroupBox *gpx = findChild("worstReflectionsGPX"); if (gpx!=nullptr){ QList ck = gpx->findChildren(); for (int i=0; isetChecked(false); QString s=ck[i]->text(); QStringList num = s.split(" ",skipEmptyParts); if ((num.size()==8)&&(num.at(5).toDouble()>10.0)){ ck[i]->setChecked(true); } } update(); }else{ printf("cant't find worstReflectionsGPX"); } } void Window::omitRfl(){ QGroupBox *gpx = findChild("worstReflectionsGPX"); if (gpx!=nullptr){ QList ck = gpx->findChildren(); QString omitstring; for (int i=0; iisChecked()){ QString s=ck[i]->text(); QStringList num = s.split(" ",skipEmptyParts); omitstring.append(QString("OMIT %1 %2 %3\n").arg(num.at(0)).arg(num.at(1)).arg(num.at(2))); } } editor->omitsome(omitstring); }else{ printf("cant't find worstReflectionsGPX"); } } void Window::worstReflections(){ QString listName=dirName; listName.replace(punktins,".lst"); listName.replace(punktres,".lst"); QFile lstf(listName); if (lstf.open(QIODevice::ReadOnly|QIODevice::Text)){ QDialog *mdr = new QDialog(this); QScrollArea *qsa = new QScrollArea(mdr); //mdr->set QGroupBox *gpx = new QGroupBox("Check Refelextions to omit.",mdr); gpx->setObjectName("worstReflectionsGPX"); QVBoxLayout *lt = new QVBoxLayout(gpx); QVBoxLayout *la = new QVBoxLayout(); QFont font; font.setFamily("Droid Sans Mono"); la->addWidget(new QLabel("Most Disagreeable Reflections (* if suppressed or used for Rfree).\n\ Error/esd is calculated as sqrt(wD^2/) where w is given by the weight\n\ formula, D = Fo^2-Fc^2 and <> refers to the average over all reflections.",mdr)); QCheckBox *allx; lt->addWidget(allx = new QCheckBox(QString(" h k l Fo^2 Fc^2 Error/esd Fc/Fc(max) Resolution(A)"))); connect(allx,SIGNAL(toggled(bool)),this, SLOT(togOMIT(bool))); allx->setFont(font); QStringList liste=QString(lstf.readAll()).split('\n'); int moststart=liste.indexOf(" h k l Fo^2 Fc^2 Error/esd Fc/Fc(max) Resolution(A)"); if (moststart>0)for (int i=moststart+2; iaddWidget(bx = new QCheckBox(QString("%1%2%3 %4 %5 %6 %7 %8") .arg(num.at(0).toInt(),4) .arg(num.at(1).toInt(),4) .arg(num.at(2).toInt(),4) .arg(num.at(3).toDouble(),10,'f',3) .arg(num.at(4).toDouble(),10,'f',3) .arg(num.at(5).toDouble(),10,'f',3) .arg(num.at(6).toDouble(),10,'f',3) .arg(num.at(7).toDouble(),10,'f',3))); bx->setFont(font); /* printf("%4d%4d%4d %10.3f %10.3f %10.3f %10.3f %10.3f\n" ,num.at(0).toInt() ,num.at(1).toInt() ,num.at(2).toInt() ,num.at(3).toDouble() ,num.at(4).toDouble() ,num.at(5).toDouble() ,num.at(6).toDouble() ,num.at(7).toDouble());*/ }else break; } //printf("Most Disagreeable Reflections %d %d\n", moststart,static_cast(liste.size())); gpx->setLayout(lt); qsa->setWidget(gpx); la->addWidget(qsa); QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Cancel,Qt::Horizontal,mdr); QPushButton *omit = bb->addButton("OMIT selected Refelections",QDialogButtonBox::AcceptRole); QPushButton *g5 = bb->addButton("select Refelections Error/esd > 5",QDialogButtonBox::ApplyRole); QPushButton *g10 = bb->addButton("select Refelections Error/esd > 10",QDialogButtonBox::ApplyRole); connect(omit,SIGNAL(clicked()),this,SLOT(omitRfl())); connect(g10,SIGNAL(clicked()),this,SLOT(selOmitG10())); connect(g5,SIGNAL(clicked()),this,SLOT(selOmitG5())); connect(bb, SIGNAL(accepted()), mdr, SLOT(accept())); connect(bb, SIGNAL(rejected()), mdr, SLOT(reject())); la->addWidget(bb); mdr->setLayout(la); mdr->exec(); mdr->deleteLater(); } } void Window::delayedLoad(){ printf("...load in 150ms\n"); tim = new QTimer(this); tim->setSingleShot(true); connect(tim,SIGNAL(timeout()),this,SLOT(loadAFile())); tim->start(150); } void Window::loadAFile(){ /* einstellung->beginGroup("Window"); einstellung->setValue("QuickReLoad",quickReLoadButton->isChecked()); einstellung->endGroup(); */ printf("...load now\n"); loadFile(dirName); } void Window::openSaveHistory(){ if ((dirName.isEmpty())||(!QFile::exists(dirName))) return; SaveHistoryWidget *shw = new SaveHistoryWidget(dirName,(QString(PROGRAM_NAME).compare("shelXle")==0)?darkTheme->isChecked():false); if (QDialog::Accepted==shw->exec()) { if ((quickReLoadButton->isChecked())) sdm(); loadFile(dirName); if ((quickReLoadButton->isChecked())) sdm(); } delete shw; } void Window::adoptEditToolBar(bool b){ if (b) shxMW->addToolBar(editToolBar); else addToolBar(editToolBar); einstellung->beginGroup("Window"); einstellung->setValue("EditorHasOwnToolBar",b); einstellung->endGroup(); update(); } void Window::toggleEQHighlighting(bool b){ mole.highlightEquivalents = b; chgl->update(); } void Window::toggleOrtho(bool ov){ //printf("toggleOrtho %d\n",__LINE__); chgl->toggleOrtho(ov); chgl->update(); /*if ((ov)&&(togDepthCueing->isChecked())){ togDepthCueing->setChecked(false); chgl->setDepthCueing(false); //printf("toggleOrtho %d\n",__LINE__); } togDepthCueing->setDisabled(ov);*/ //chgl->setViewAngle((ov)?0.1:29.0); einstellung->beginGroup("ViewSettings"); einstellung->setValue("OrthographicProjection",ov); einstellung->endGroup(); } int Window::getFvarCntr(int fvar){ return fvarCntr.value(fvar); } void Window::growQPeaks(bool qpg){ mole.growQPeak=qpg; bool growYes=chgl->fuse->isVisible (); chgl->mol->fuse(); if (growYes) chgl->mol->grow(); loadMolInTest(); chgl->update(); } void Window::spellCheck(){ QString t=editor->toPlainText(); if (t==altText) return; altText=t; QRegularExpression rx=QRegularExpression("\\s|_"); QRegularExpression nch=QRegularExpression("[^\"\\-~#%&$'`§()+\\*\\./@\\[\\]^\\\\{}\\|<>A-Za-z0-9]+"); QString s,s0; QString meld; editor->errorInLine.clear(); bool cont=false; QStringList sl; for (int i= 0;i< editor->blocks.size(); i++){ sl = editor->blocks.at(i).split(" ",skipEmptyParts); if (sl.isEmpty())continue; if ((cont)&&(editor->blocks.at(i).contains(QRegularExpression("^\\S+")))){ editor->errorInLine.append(i-1); editor->errorInLine.append(i); meld+=QString("ERROR in line %1: Bad continuation line!
").arg(i); } cont=false; if (sl.isEmpty())continue; cont= (!(sl.at(0).contains(QRegularExpression("(^REM)|(^TITL)",QRegularExpression::CaseInsensitiveOption)))&&(editor->blocks.at(i).contains(QRegularExpression("=\\s*$")))); if((editor->blocks.at(i).size()>SX_LINE_LENGTH)&&(!editor->blocks.at(i).contains(QRegularExpression("^\\s+")))){ editor->errorInLine.append(i); meld+=QString("ERROR in line %1: Line is too long for SHELXL!
").arg(i+1); } if (editor->blocks.at(i).startsWith(" ")) continue; if (isacommand(sl.at(0))==-1){ s0=sl.at(0).section(rx,0,0); if (s0.size()>4) { meld+=QString("ERROR in line %1: Atom label too long %2!
").arg(i+1).arg(sl.at(0)); editor->errorInLine.append(i); } if (sl.at(0).contains(nch)) { meld+=QString("ERROR in line %1: Not allowed characters in atom label %2!
").arg(i+1).arg(sl.at(0)); editor->errorInLine.append(i); } bool bb=true; if (sl.size()>1) { s=sl.at(1); int ii = s.toInt(&bb); if ((sl.size()>3)&&((ii<1)||(!bb))) { meld+=QString("ERROR in line %1: Scatering-factor number is missing or out of range!
").arg(i+1); editor->errorInLine.append(i); } } } } FehlerTeufel= !meld.isEmpty(); if (FehlerTeufel) infoKanalNews(""+meld+""); else infoKanalNews(""); spellCheckact->setVisible(FehlerTeufel); spellCheckact2->setVisible(FehlerTeufel); editor->update(); } void Window::exportCoordinates(){ QString exportName = dirName; exportName.replace(resorins,"_EXPORTED.res"); QString fn=QFileDialog::getSaveFileName(this, tr("Export all visible atoms"), exportName, tr("SHELX-files (*.res *.ins)")); if (fn.isEmpty()) return; QFile f(fn); QString body; body.append(QString("TITL %1\nCELL %2 %3 %4 %5 %6 %7 %8\n%9\n") .arg(title) .arg(mole.cell.wave ) .arg(mole.cell.a ) .arg(mole.cell.b ) .arg(mole.cell.c ) .arg(mole.cell.al ) .arg(mole.cell.be ) .arg(mole.cell.ga ) .arg(mole.cell.Z ) ); body.append(QString("LATT -1\n")); for (int i=1; isfac.size(); i++){ body.append(QString("%1 ").arg(mole.pse(editor->sfac.at(i)))); } body.append("\n"); body.append(editor->unitNeu); body.append( "\n\nREM ######################################################\n" "REM This file exported by ShelXle is for information or \n" "REM visualiztion purposes only. You may run into trouble \n" "REM if you try to refine it against data.\n" "REM DISABLE_REFINE\n" "REM ######################################################\n\n"); body.append("FVAR 1.00 "); for (int i=0; irehide(); for (int i=0; i< mole.showatoms.size(); i++){ if (mole.showatoms.at(i).hidden) continue; if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) if ((mole.showatoms.at(i).an!=-42)&&(mole.showatoms.at(i).resiNr!=resi)) body.append(QString("RESI %1 %2\n").arg(mole.showatoms.at(i).resiNr).arg(mole.showatoms.at(i).ResiClass)); if ((mole.showatoms.at(i).an!=-42)&&(mole.showatoms.at(i).part!=part)) body.append(QString("PART %1\n").arg(mole.showatoms.at(i).part)); if (mole.showatoms.at(i).an==-1) body.append(QString("%1 %2 %3 %4 %5 %6 %7 %8\n") .arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) .arg(qMax(1,editor->sfac.indexOf(mole.showatoms.at(i).an)+1)) .arg(mole.showatoms.at(i).frac.x,10,'f',6) .arg(mole.showatoms.at(i).frac.y,10,'f',6) .arg(mole.showatoms.at(i).frac.z,10,'f',6) .arg(mole.showatoms.at(i).sof_org,9,'f',5) .arg(mole.showatoms.at(i).uf.m33,9,'f',5) .arg(mole.showatoms.at(i).peakHeight,9,'f',2) ); else if (mole.showatoms.at(i).an==-42){ Matrix uf = mole.b2u(mole.showatoms.at(i).uf); body.append(QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12\n") .arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) .arg(2) .arg(mole.showatoms.at(i).frac.x,10,'f',6) .arg(mole.showatoms.at(i).frac.y,10,'f',6) .arg(mole.showatoms.at(i).frac.z,10,'f',6) .arg(mole.showatoms.at(i).sof_org,9,'f',5) .arg(uf.m11,9,'f',5) .arg(uf.m22,9,'f',5) .arg(uf.m33,9,'f',5) .arg(uf.m23,9,'f',5) .arg(uf.m13,9,'f',5) .arg(uf.m12,9,'f',5) ); } else {if (mole.showatoms.at(i).isIso){ body.append(QString("%1 %2 %3 %4 %5 %6 %7!x\n") .arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) .arg(qMax(1,editor->sfac.indexOf(mole.showatoms.at(i).an)+1)) .arg(mole.showatoms.at(i).frac.x,10,'f',6) .arg(mole.showatoms.at(i).frac.y,10,'f',6) .arg(mole.showatoms.at(i).frac.z,10,'f',6) .arg(mole.showatoms.at(i).sof_org,9,'f',5) .arg(mole.showatoms.at(i).ufiso_org) ); }else{ body.append(QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12\n") .arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) .arg(qMax(1,editor->sfac.indexOf(mole.showatoms.at(i).an)+1)) .arg(mole.showatoms.at(i).frac.x,10,'f',6) .arg(mole.showatoms.at(i).frac.y,10,'f',6) .arg(mole.showatoms.at(i).frac.z,10,'f',6) .arg(mole.showatoms.at(i).sof_org,9,'f',5) .arg(mole.showatoms.at(i).uf.m11,9,'f',5) .arg(mole.showatoms.at(i).uf.m22,9,'f',5) .arg(mole.showatoms.at(i).uf.m33,9,'f',5) .arg(mole.showatoms.at(i).uf.m23,9,'f',5) .arg(mole.showatoms.at(i).uf.m13,9,'f',5) .arg(mole.showatoms.at(i).uf.m12,9,'f',5) ); }} part=mole.showatoms.at(i).part; resi=mole.showatoms.at(i).resiNr; } body.append("\n\n"); QString eqi=mole.symmcode2human(mole.usedSymmetry); eqi.replace("»","EQIV $"); eqi.replace(":",""); eqi.replace("",""); eqi.replace("",""); eqi.replace("
","\n"); body.append(eqi); body.append("\n\n"); for (int i =0; ihidden) continue; if (mole.showbonds.at(i).ato2->hidden) continue; if ((mole.nopm1)&&(mole.showbonds.at(i).ato1->symmGroup)&&(mole.showbonds.at(i).ato1->part<0))continue; // if ((mole.nopm1)&&(mole.showbonds.at(i).ato2->symmGroup)&&(mole.showbonds.at(i).ato2->part<0))continue; // ignore hidden parts (-1) QString s1="",s2="",s3=""; s1=mole.showbonds.at(i).ato1->Label; s2=mole.showbonds.at(i).ato2->Label; s1=s1.section(QString::fromUtf8("»"),0,0); s2=s2.section(QString::fromUtf8("»"),0,0); if ((mole.showbonds.at(i).ato2->symmGroup)||(mole.showbonds.at(i).ato1->symmGroup)) s3.append(QString("_$%1").arg(qMax(mole.showbonds.at(i).ato1->symmGroup,mole.showbonds.at(i).ato2->symmGroup))); body.append(QString("BIND%3 %1 %2\n") .arg(s1) .arg(s2) .arg(s3)); } body.append("\nHKLF 0 !don't refine this\nEND\n"); bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); if (success){ f.write(body.toLatin1()); f.close(); } } void Window::changeIconSize(){ bool ok; int tbs=tbiconSize; #if (QT_VERSION >= 0x040500) tbs=QInputDialog::getInt(this,"Change tool bar icon size...","Tool bar icon size:",tbiconSize,16,96,1,&ok); #else tbs=QInputDialog::getInteger(this,"Change tool bar icon size...","Tool bar icon size:",tbiconSize,16,32,1,&ok); #endif if (ok) tbiconSize=tbs; einstellung->beginGroup("ToolBarIcons"); einstellung->setValue("ToolBarIconSize",tbiconSize); einstellung->endGroup(); fito->setIconSize(QSize(tbiconSize,tbiconSize)); editToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); refineToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); vito->setIconSize(QSize(tbiconSize,tbiconSize)); extraTB->setIconSize(QSize(tbiconSize,tbiconSize)); bottomToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); chgl->invertMouseZoom->setIconSize(QSize(tbiconSize,tbiconSize)); homeMe->setIconSize(QSize(tbiconSize,tbiconSize)); zoomIn->setIconSize(QSize(tbiconSize,tbiconSize)); zoomOut->setIconSize(QSize(tbiconSize,tbiconSize)); update(); } void Window::changeQPeakLimit(){ bool ok; int limit=MaxNumberOfPeaks; #if (QT_VERSION >= 0x040500) limit=QInputDialog::getInt(this,"Change maximum number of created Q-peaks","maximum number of created Q-peaks:",MaxNumberOfPeaks,1,600,1,&ok); #else limit=QInputDialog::getInteger(this,"Change maximum number of created Q-peaks","maximum number of created Q-peaks:",MaxNumberOfPeaks,1,600,1,&ok); #endif if (ok) MaxNumberOfPeaks=limit; actionQPeakLimit->setText(QString("change maximum number of created Q-peaks (%1)").arg(MaxNumberOfPeaks)); update(); } void Window::jnk(){ if (!fxle->doMaps->isChecked())fxle->doMaps->setChecked(true); fxle->maptrunc=fxle->mapSchnitt->currentIndex (); if ((fxle->rw!=fxle->weak->value())||(fxle->rr!=fxle->mapprec->value())){ fxle->rr = fxle->mapprec->value(); fxle->rw = fxle->weak->value(); if (!fxle->loadFouAndPerform(fxle->fouName.toLocal8Bit(),false)){ infoKanalNews(QString("Error while loading %1!
").arg(fxle->fouName)); //printf("%d\n",__LINE__); fxle->killmaps(); //printf("%d\n",__LINE__); } } chgl->lintrans = fxle->lineTrans->value(); chgl->linwidth = fxle->lineWidth->value(); fxle->map_radius = fxle->maprad->value(); fxle->iso[0] = fxle->fomaps->value(); fxle->iso[1] = -fxle->difmaps->value(); fxle->jnk(); } void Window::deleteAllQ(){ if (editor->sfac.isEmpty()) return; bool isQ = false; for (int o = 0; o < mole.asymm.size();o++){ if (mole.asymm.at(o).an == -1){ isQ = true; break; } } if (!isQ) return; QTextCursor cursor = editor->textCursor(); editor->wholeLine->setChecked(false); editor->replace->setText(""); editor->searchLE->setText("^Q\\S+\\s+1\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s*"); for (int i = mole.asymm.size()-1; i>=0; i-- ){ if (mole.asymm.at(i).an==-1){ QString s = QString("Deleted atom: %1 part:%2 residue:%3 %4 Please save to update structure view.") .arg(mole.asymm.at(i).Label) .arg(mole.asymm.at(i).part) .arg(mole.asymm.at(i).resiNr) .arg(mole.asymm.at(i).ResiClass); infoKanalNews(s); deletedAtom.append(mole.asymm.at(i)); mole.asymm.removeAt(i); } } editor->replaceAll(); editor->searchLE->setText(""); mole.showatoms.clear(); mole.showbonds.clear(); chgl->mol->showatoms.clear(); chgl->mol->showbonds.clear(); chgl->mol->selectedatoms.clear(); for (int o=0; ofuse->isVisible (); if (growYes) chgl->mol->grow(); else chgl->mol->fuse(); if ((chgl->rotze!=-1)&&(!chgl->enviPositions.isEmpty())){ chgl->envi(); } chgl->mol->selectedatoms.clear(); chgl->showHidden(); // printf("%d\n",__LINE__); loadMolInTest(); chgl->updateBondActions(); chgl->update(); update(); chgl->update(); } void Window::sdm(){ if (!(chgl->fuse->isVisible()||chgl->grow->isVisible ())){ chgl->fuse->setVisible(true); chgl->grow->setVisible(false); } mole.showatoms.clear(); mole.showbonds.clear(); chgl->mol->showatoms.clear(); chgl->mol->showbonds.clear(); chgl->mol->selectedatoms.clear(); for (int o=0; omol->selectedatoms.clear(); bool growYes=chgl->fuse->isVisible (); chgl->mol->fuse(); if (growYes) chgl->mol->grow(); // printf("%d\n",__LINE__); chgl->updateBondActions(); infoKanalNews(mole.Fragments); chgl->update(); update(); chgl->update(); loadMolInTest(); } void Window::makeVoro(){ int ind=-1; QAction *action = qobject_cast(sender()); if (action!=NULL){ ind=action->data().toInt(); ind=qMax(ind,-1); ind=qMin(ind,mole.asymm.size()-1); } clearVoro->setVisible(true); /*if (tgl) tgl->ogl->voronoij(mole.asymm,ind); else mole.voronoij(mole.asymm,ind);*/ chgl->voronoij(mole.asymm,ind); infoKanalNews(mole.voroMsg); chgl->update(); } void Window::clearVoros(){ mole.vtriangles.clear(); mole.vorobas=0; chgl->voroDestruct(); clearVoro->setVisible(false); chgl->update(); } void Window::deleteAllH(){ if (editor->sfac.isEmpty()) return; bool isH = false; for (int o = 0; o < mole.asymm.size(); o++){ if (mole.asymm.at(o).an == 0){ isH = true; break; } } if (!isH) return; /* maybeSave2(); printf("deleteallh %d %d\n",mole.asymm.size(),chgl->mol->showatoms.size());*/ chgl->mol->selectedatoms.clear(); for (int o = 0; o < mole.asymm.size(); o++){ if (mole.asymm.at(o).an == 0){ chgl->mol->selectedatoms.append(chgl->mol->showatoms[o]); chgl->mol->selectedatoms.last().style=o; } } deleteSelectedAtoms(); } void Window::deleteSelectedAtoms(){ if (chgl->mol->selectedatoms.isEmpty()){ QAction *action = qobject_cast(sender()); int index=-1; if (action) index=action->data().toInt(); else index=-1; if (index>mole.asymm.size()) index=-1; if (index!=-1) { chgl->mol->selectedatoms.clear(); chgl->mol->selectedatoms.append(chgl->mol->showatoms[index]); chgl->mol->selectedatoms.last().style=index; } } if (chgl->mol->selectedatoms.isEmpty()) return; bool donotsymm=false; QTextCursor cursor = editor->textCursor(); QTextDocument *document = editor->document(); cursor.beginEditBlock(); int ende=chgl->mol->selectedatoms.size(); for (int i = 0; i < ende; i++ ){ if (chgl->mol->selectedatoms.at(i).symmGroup) continue; if (chgl->mol->selectedatoms.at(i).Label.contains(QString::fromUtf8("»")))continue; if ((chgl->mol->selectedatoms.at(i).afix>0)&&(chgl->mol->selectedatoms.at(i).an>0)) continue; int wg=chgl->mol->selectedatoms.at(i).style; QString label = mole.asymm.at(wg).orginalLine.left(80).trimmed(); cursor.movePosition(QTextCursor::Start); cursor = document->find(label,cursor); if (cursor.isNull()){ cursor = editor->textCursor(); cursor.movePosition(QTextCursor::Start); label.chop(10); cursor = document->find(label,cursor); if (cursor.isNull()) { cursor = editor->textCursor(); printf("hab was nicht %d/%d %d [%s]\n",i,ende,static_cast(chgl->mol->selectedatoms.size()),label.toStdString().c_str()); continue; } } cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); //printf("wg2160->%d %s\n",wg,label.toStdString().c_str()); bool afx=false; if (editor->parenthesis.at(cursor.blockNumber())){ afx=true; do { if (!cursor.block().text().contains("afix",Qt::CaseInsensitive)) wg--; cursor.movePosition(QTextCursor::Up,QTextCursor::MoveAnchor); }while(!cursor.block().text().contains("afix",Qt::CaseInsensitive)); cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); } //printf("wg2168->%d [%s] {%s}\n",wg,cursor.selectedText().toStdString().c_str(),cursor.block().text().toStdString().c_str()); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); while (cursor.selectedText().endsWith("=")) { cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); } int haa=1; if (afx) while (!cursor.block().text().contains("afix",Qt::CaseInsensitive)){ cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); if ((!cursor.block().text().contains("afix",Qt::CaseInsensitive))&&(wg+haa)mol->showatoms.size()){ chgl->mol->selectedatoms.append(chgl->mol->showatoms.at(wg+haa)); chgl->mol->selectedatoms.last().style=wg+haa; haa++; } /* printf("wg+ =%d %d/%d %d\n",wg+haa,cursor.blockNumber()+2,(editor->parenthesis.size()),editor->blockCount()); printf("[[%s]]\n", cursor.selectedText().toStdString().c_str()); printf("%d %d!\n",editor->parenthesis.at(cursor.blockNumber()+1),editor->parenthesis.at(cursor.blockNumber()+2)); */ } //printf("wg2191->[%s]\n",cursor.selectedText().toStdString().c_str()); cursor.deleteChar(); cursor.deleteChar(); editor->updateAfix(); } for (int i = chgl->mol->selectedatoms.size()-1; i>=0; i-- ){ if (chgl->mol->selectedatoms.at(i).Label.contains(QString::fromUtf8("»"))){donotsymm=true;continue;} if (chgl->mol->selectedatoms.at(i).symmGroup){donotsymm=true;continue;} QString s = QString("Deleted atom: %1 part:%2 residue:%3 %4 Please save to update structure view.") .arg(chgl->mol->selectedatoms.at(i).Label) .arg(chgl->mol->selectedatoms.at(i).part) .arg(chgl->mol->selectedatoms.at(i).resiNr) .arg(chgl->mol->selectedatoms.at(i).ResiClass); infoKanalNews(s); int wg=mole.asymm.indexOf(chgl->mol->selectedatoms.at(i)); if (wg<0) continue; deletedAtom.append(mole.asymm.at(wg)); mole.asymm.removeAt(wg); } cursor.endEditBlock(); mole.showatoms.clear(); mole.showbonds.clear(); chgl->mol->showatoms.clear(); chgl->mol->showbonds.clear(); chgl->mol->selectedatoms.clear(); for (int o=0; osetMolecule(&mole); loadMolInTest(); chgl->mol->selectedatoms.clear(); bool growYes=chgl->fuse->isVisible (); chgl->mol->fuse(); if (growYes) chgl->mol->grow(); switch (duplicates()){ case 1:infoKanalNews("Some hydrogen atoms have identical names please check.");break; case 2:infoKanalNews("Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!");break; case 3:infoKanalNews("Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!");break; } if (donotsymm) QMessageBox::information(0,"information","Only unique atoms can be deleted!"); // printf("%d\n",__LINE__); loadMolInTest(); chgl->updateBondActions(); chgl->update(); update(); chgl->update(); /* } else {chgl->disSelection();}*/ } void Window::createCentroid(){ if (chgl->mol->selectedatoms.isEmpty()) return; QTextCursor cursor = editor->textCursor(); QTextDocument *document = editor->document(); cursor.beginEditBlock(); int ctrcnt=1; for (int i=0; imol->selectedatoms.size(); V3 posc = V3(0,0,0), posf = V3(0,0,0); QString creatorS; for (int i = 0; i < ende; i++ ){ posc+=chgl->mol->selectedatoms.at(i).pos; creatorS.append(chgl->mol->selectedatoms.at(i).Label+", "); if (creatorS.section('\n',-1).size()>50) creatorS.append("\nREM "); } posc*=1.0/ende; mole.kart2frac(posc,posf); MyAtom ctr ; ctr.an=-66; ctr.part=0; ctr.peakHeight=9999.99; ctr.resiNr=0; ctr.hidden=0; ctr.symmGroup=0; ctr.sg=0; ctr.scod=555;//the identity ctr.auidx=-1; ctr.uc.m12=ctr.uc.m23=ctr.uc.m13=0.0; ctr.uc.m21=ctr.uc.m32=ctr.uc.m31=0.0; ctr.uf.m12=ctr.uf.m23=ctr.uf.m13=0.0; ctr.uf.m21=ctr.uf.m32=ctr.uf.m31=0.0; ctr.pos=posc; ctr.frac=posf; if (!editor->sfac.contains(-66)){ editor->sfac.append(-66); editor->unitNeu.append(" 0"); cursor.movePosition(QTextCursor::Start); cursor = document->find(editor->unitAlt,cursor); if (cursor.isNull()) { cursor = editor->textCursor(); cursor.endEditBlock (); printf("can't find unit\n"); update(); return; } cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); cursor.deleteChar(); cursor.insertText(editor->unitNeu); cursor.movePosition(QTextCursor::Start); cursor = document->find(editor->unitNeu,cursor); cursor.clearSelection (); cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.insertText("SFAC cnt 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 ! centroid dummy\n"); } cursor.movePosition(QTextCursor::Start); cursor = document->find("HKLF",cursor); cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.insertText(ctr.orginalLine=QString("Cnt%5 %1 %2 %3 %4 10.000 0.001 ! centroid\n") .arg(editor->sfac.indexOf(-66)+1) .arg(posf.x,10,'f',6) .arg(posf.y,10,'f',6) .arg(posf.z,10,'f',6) .arg(ctrcnt,0,36)); cursor.insertText(QString("REM Cnt%1 was created from: %2\n").arg(ctrcnt,0,36).arg(creatorS)); for (int i = 0; i < ende; i++ ){ cursor.insertText(QString("FREE Cnt%1 %2 ! this might be needed for AFIX\n").arg(ctrcnt,0,36).arg(chgl->mol->selectedatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0))); } ctr.orginalLine= QString("Cnt%5 %1 %2 %3 %4 10.000 0.001\n") .arg(editor->sfac.indexOf(-66)+1) .arg(posf.x,10,'f',6) .arg(posf.y,10,'f',6) .arg(posf.z,10,'f',6) .arg(ctrcnt,0,36); ctr.Label=QString("Cnt%1").arg(ctrcnt,0,36); cursor.endEditBlock (); editor->setTextCursor(cursor); editor->centerCursor () ; cursor.clearSelection (); editor->setTextCursor(cursor); editor->setFocus () ; mole.asymm.append(ctr); mole.showatoms.clear(); mole.showbonds.clear(); chgl->mol->showatoms.clear(); chgl->mol->showbonds.clear(); chgl->mol->selectedatoms.clear(); for (int o=0; osetMolecule(&mole); chgl->mol->selectedatoms.clear(); bool growYes=chgl->fuse->isVisible (); chgl->mol->fuse(); if (growYes) chgl->mol->grow(); // printf("%d\n",__LINE__); loadMolInTest(); chgl->update(); update(); } void Window::moveSymmMateSel(){ QString kep,nextli; QTextCursor cursor = editor->textCursor(); QTextDocument *document = editor->document(); cursor.beginEditBlock(); for (int si=0; si=mole.asymm.size())||(that<0)) return; QString susu=mole.asymm.at(that).orginalLine; cursor.movePosition(QTextCursor::Start); cursor = document->find(susu,cursor); if (mole.asymm.at(that).isIso){ ato.ufiso_org = mole.asymm.at(that).ufiso_org; kep=QString("%1 %2 %3 %4 %5 %6 %7") .arg(ato.Label.section('_',0,0),-5) .arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) .arg(ato.frac.x,10,'f',6) .arg(ato.frac.y,10,'f',6) .arg(ato.frac.z,10,'f',6) .arg(mole.asymm.at(that).sof_org,9,'f',5) .arg(ato.ufiso_org) ; ato.uf.m11=ato.uc.m11=ato.uc.m22=ato.uc.m33= mole.asymm.at(that).uf.m11; ato.isIso=true; ato.uc.m12=ato.uc.m13=ato.uc.m23=ato.uc.m21=ato.uc.m31=ato.uc.m32=0; cursor.deleteChar(); cursor.insertText(kep); cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); editor->wholeLine->setChecked(false); editor->replaceNext(); }else{ kep=QString("%1 %2 %3 %4 %5 %6 %7 %8 ") .arg(ato.Label.section('_',0,0),-5) .arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) .arg(ato.frac.x,10,'f',6) .arg(ato.frac.y,10,'f',6) .arg(ato.frac.z,10,'f',6) .arg(mole.asymm.at(that).sof_org,9,'f',5) .arg(ato.uf.m11,9,'f',5) .arg(ato.uf.m22,9,'f',5); ato.sof_org=mole.asymm.at(that).sof_org; cursor.deleteChar(); cursor.insertText(kep); cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::Down); cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); nextli=cursor.selectedText(); cursor = document->find(nextli,cursor); cursor.deleteChar(); cursor.insertText(QString(" %1 %2 %3 %4") .arg(ato.uf.m33,9,'f',5) .arg(ato.uf.m23,9,'f',5) .arg(ato.uf.m13,9,'f',5) .arg(ato.uf.m12,9,'f',5)); cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); } ato.orginalLine=kep.section("=",0,0); mole.asymm[that]=ato; } cursor = editor->textCursor(); cursor.endEditBlock(); mole.showatoms.clear(); mole.showbonds.clear(); chgl->mol->showatoms.clear(); chgl->mol->showbonds.clear(); chgl->mol->selectedatoms.clear(); for (int o=0; osetMolecule(&mole); chgl->mol->selectedatoms.clear(); bool growYes=chgl->fuse->isVisible (); chgl->mol->fuse(); if (growYes) chgl->mol->grow(); editor->searchLE->setText(""); editor->hideSearch(); loadMolInTest(); // printf("%d\n",__LINE__); chgl->update(); update(); } void Window::moveSymmMate(){ QAction *action = qobject_cast(sender()); int index=0; if (action) index=action->data().toInt(); else return; QString source,target; source=chgl->mol->showatoms.at(index).Label; target=source.section(QString::fromUtf8("»"),0,0); MyAtom ato=chgl->mol->showatoms.at(index); ato.Label=target; ato.symmGroup=0; ato.sg=0; ato.scod=555;//the identity int that=mole.asymm.indexOf(ato); ato.auidx=that; if ((that>=mole.asymm.size())||(that<0)) return; QString susu=mole.asymm.at(that).orginalLine; editor->searchLE->setText(susu); if (mole.asymm.at(that).isIso){ ato.ufiso_org = mole.asymm.at(that).ufiso_org; editor->replace->setText(QString("%1 %2 %3 %4 %5 %6 %7") .arg(ato.Label.section('_',0,0),-5) .arg(qMax(1, editor->sfac.indexOf(ato.an)+1)) .arg(ato.frac.x,10,'f',6) .arg(ato.frac.y,10,'f',6) .arg(ato.frac.z,10,'f',6) .arg(mole.asymm.at(that).sof_org,9,'f',5) .arg(ato.ufiso_org) ); ato.uf.m11=ato.uc.m11=ato.uc.m22=ato.uc.m33= mole.asymm.at(that).uf.m11; ato.isIso=true; ato.uc.m12=ato.uc.m13=ato.uc.m23=ato.uc.m21=ato.uc.m31=ato.uc.m32=0; editor->wholeLine->setChecked(false); editor->replaceNext(); }else{ QString kep=QString("%1 %2 %3 %4 %5 %6 %7 %8 ") .arg(ato.Label.section('_',0,0),-5) .arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) .arg(ato.frac.x,10,'f',6) .arg(ato.frac.y,10,'f',6) .arg(ato.frac.z,10,'f',6) .arg(mole.asymm.at(that).sof_org,9,'f',5) .arg(ato.uf.m11,9,'f',5) .arg(ato.uf.m22,9,'f',5); editor->replace->setText(kep); editor->wholeLine->setChecked(false); editor->replaceNext(); editor->searchLE->setText(editor->replace->text()); editor->replace->setText(""); editor->findNext(); QTextCursor cursor = editor->textCursor(); cursor.movePosition(QTextCursor::Down); cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); editor->searchLE->setText(cursor.selectedText()); editor->replace->setText(QString(" %1 %2 %3 %4") .arg(ato.uf.m33,9,'f',5) .arg(ato.uf.m23,9,'f',5) .arg(ato.uf.m13,9,'f',5) .arg(ato.uf.m12,9,'f',5) ); editor->replaceNext(); editor->replace->setText(kep); } editor->searchLE->setText(editor->replace->text()); editor->replace->setText(""); editor->findNext(); QTextCursor cursor = editor->textCursor(); ato.orginalLine=cursor.selectedText().section("=",0,0); mole.asymm[that]=ato; mole.showatoms.clear(); mole.showbonds.clear(); chgl->mol->showatoms.clear(); chgl->mol->showbonds.clear(); chgl->mol->selectedatoms.clear(); for (int o=0; osetMolecule(&mole); chgl->mol->selectedatoms.clear(); bool growYes=chgl->fuse->isVisible (); chgl->mol->fuse(); if (growYes) chgl->mol->grow(); editor->searchLE->setText(""); editor->hideSearch(); loadMolInTest(); // printf("%d\n",__LINE__); chgl->update(); update(); } void Window::copySymmMate(){ QAction *action = qobject_cast(sender()); int index=0; if (action) index=action->data().toInt(); else return; QString source,target; source=chgl->mol->showatoms.at(index).Label; target=source.section(QString::fromUtf8("»"),0,0); MyAtom ato=chgl->mol->showatoms.at(index); ato.Label=target; ato.symmGroup=0; ato.sg=0; ato.scod=555;//the identity int that=mole.asymm.indexOf(ato); ato.auidx=that; if ((that>=mole.asymm.size())||(that<0)) return; QString susu=mole.asymm.at(that).orginalLine; QTextCursor cursor = editor->textCursor(); cursor.movePosition(QTextCursor::Start); QTextDocument *document = editor->document(); if (document->find(susu, cursor).isNull()) { QMessageBox::information(0,"information","The File is out of sync with the model. Please save and try again!"); return; } cursor.beginEditBlock(); cursor.movePosition(QTextCursor::Start); cursor = document->find("HKLF",cursor); cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); if (editor->parenthesis.at(cursor.blockNumber())){ cursor.select(QTextCursor::WordUnderCursor); if ((cursor.selectedText().contains("RESI",Qt::CaseInsensitive))||(cursor.selectedText().contains("PART",Qt::CaseInsensitive))) cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); cursor.select(QTextCursor::WordUnderCursor); if ((cursor.selectedText().contains("RESI",Qt::CaseInsensitive))||(cursor.selectedText().contains("PART",Qt::CaseInsensitive))) cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); cursor.clearSelection(); cursor.insertText("AFIX 0 \n"); } ///////////////////////////// cursor.movePosition(QTextCursor::Start); cursor = document->find(susu, cursor); cursor.movePosition(QTextCursor::Down); cursor.movePosition(QTextCursor::StartOfLine); if (mole.asymm.at(that).Label.contains(numbers)) { int p=mole.asymm.at(that).an; labelPSE=mole.pse(p); labelIndex=mole.asymm.at(that).Label.section(nonumbers,0,0,QString::SectionSkipEmpty).toInt(); labelSuffix=mole.asymm.at(that).Label.section(numbers,1,1); labelSuffix.remove(vorneweg); } else{ int p=mole.asymm.at(that).an; labelPSE=mole.pse(p); labelIndex=-1; labelSuffix=mole.asymm.at(that).Label; labelSuffix.remove(0,labelPSE.size()); labelSuffix.remove(vorneweg); } partSpin->setValue(mole.asymm.at(that).part); resiNrSpin->setValue(mole.asymm.at(that).resiNr); resiResiClass->setText(mole.asymm.at(that).ResiClass); pserbt[mole.asymm.at(that).an+1]->setChecked(true); renamUpdate(false); updateLabel(); QString neues=nextLabel; if (mole.asymm.at(that).isIso){ cursor.insertText(QString("%1 %2 %3 %4 %5 %6 %7 !copy\n") .arg(neues,-5)//1 .arg(qMax(1,editor->sfac.indexOf(ato.an)+1))//2 .arg(ato.frac.x,10,'f',6)//3 .arg(ato.frac.y,10,'f',6)//4 .arg(ato.frac.z,10,'f',6)//5 .arg(mole.asymm.at(that).sof_org,9,'f',5)//6 .arg(ato.uf.m33=mole.asymm.at(that).uf.m33,9,'f',5)//7 ); }else{ cursor.movePosition(QTextCursor::Down); cursor.movePosition(QTextCursor::StartOfLine); while(editor->parenthesis.at(cursor.blockNumber()+1)){ cursor.movePosition(QTextCursor::Down); cursor.movePosition(QTextCursor::StartOfLine); } cursor.insertText(QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12 !copy\n") .arg(neues,-5)//1 .arg(qMax(1,editor->sfac.indexOf(ato.an)+1))//2 .arg(ato.frac.x,10,'f',6)//3 .arg(ato.frac.y,10,'f',6)//4 .arg(ato.frac.z,10,'f',6)//5 .arg(mole.asymm.at(that).sof_org,9,'f',5)//6 .arg(ato.uf.m11,9,'f',5)//7 .arg(ato.uf.m22,9,'f',5)//8 .arg(ato.uf.m33,9,'f',5)//9 .arg(ato.uf.m23,9,'f',5)//10 .arg(ato.uf.m13,9,'f',5)//11 .arg(ato.uf.m12,9,'f',5)//12 ); } QString nn=QString("%1_%3%4") .arg(nextLabel) .arg((resiNrSpin->value())?QString::number(resiNrSpin->value()):"") .arg((partSpin->value())?QString::number((partSpin->value()<0)? 36+partSpin->value(): partSpin->value()+9,36):""); ato.Label=nn; mole.asymm.append(ato); cursor.endEditBlock(); renamUpdate(false); updateLabel(); mole.showatoms.clear(); mole.showbonds.clear(); chgl->mol->showatoms.clear(); chgl->mol->showbonds.clear(); chgl->mol->selectedatoms.clear(); for (int o=0; osetMolecule(&mole); chgl->mol->selectedatoms.clear(); bool growYes=chgl->fuse->isVisible (); chgl->mol->fuse(); if (growYes) chgl->mol->grow(); loadMolInTest(); // printf("%d\n",__LINE__); chgl->update(); update(); } void Window::updateTieFreeVar(){ int part = partSpin->value(); if (!part) { tieOccL->hide(); tieType->hide(); tieType->setCurrentIndex(0); tieFVNrL->hide(); tieFVNr->hide(); tieUsedL->hide(); tieFix->hide(); update(); return; } tieOccL->show(); tieType->show(); if (tieType->itemData(tieType->currentIndex()).toInt()){ tieFVNrL->show(); tieFVNr->show(); tieUsedL->hide(); tieFix->hide(); int j=tieFVNr->value(); tieUsedL->setText(QString("fv(%1)=%3 [%2x used]") .arg(j) .arg(fvarCntr.value(j)) .arg((fvar.size()>(j-1))?fvar.at(j-1):0.666) ); tieFVNr->setMaximum(fvar.size()+1); if (j!=1) tieUsedL->show(); else { tieFix->show(); tieType->hide(); } }else{ tieFVNrL->hide(); tieFVNr->hide(); tieUsedL->hide(); tieFix->hide(); } update(); } void Window::clipboardDataChanged(){ #ifndef QT_NO_CLIPBOARD actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty()); #endif } void Window::shxActUpdate(bool vis){ bool v = shxOutputDock->isVisible(); editToolBar->setVisible(vis|v); refineToolBar->setVisible(vis|v); actionSearch->setVisible(vis|v); actionNext->setVisible(vis|v); actionPrev->setVisible(vis|v); actionUndo->setVisible(vis); actionRedo->setVisible(vis); actionCut->setVisible(vis); actionCopy->setVisible(vis); actionPaste->setVisible(vis); actionEP->setVisible(vis|v); actionEM->setVisible(vis|v); } void Window::shxOPTUpdate(bool vis){ bool v = shxEditorDock->isVisible(); xlPutor->hideSearch(); editToolBar->setVisible(vis|v); refineToolBar->setVisible(vis|v); actionSearch->setVisible(vis|v); actionNext->setVisible(vis|v); actionPrev->setVisible(vis|v); actionEP->setVisible(vis|v); actionEM->setVisible(vis|v); update(); } void Window::renamUpdate(bool vis){ /*QElapsedTimer tmr; int ran=rand(); tmr.start();*/ //printf("==>%lld %d\n",tmr.elapsed(), ran); enterRenameMode->setChecked(vis); enterRenameMode->setText((vis)?"Exit Rename Mode":"Rename Mode"); renamUpdateAct->setChecked(false); updateTieFreeVar(); labelSuffix = ""; sufixBox->clearEditText(); sufixBox->setCurrentIndex(1); psew->hide(); willpse->show(); QStringList RCL;//ResiClassList RCL.append(""); QString curcls=resiResiClass->text(); if (!curcls.isEmpty()) RCL.append(curcls); for (int i=0; iclear(); resiResiClassCB->addItems(RCL); if (!curcls.isEmpty()) resiResiClassCB->setCurrentIndex(resiResiClassCB->findText(curcls)); renameRNchanged(resiNrSpin->value()); resiResiClass->setText(curcls); if (vis) { renamDock->show(); renamDock->raise(); if (dock->isVisible()) dock->hide(); if (histDock->isVisible()) histDock->hide(); //if (!renamDock->isVisible()) renamDock->show(); machPlatz=true; //printf("renamDock->raise()\n"); renamDock->raise(); //renamDock->raise(); editToolBar->setVisible(vis); refineToolBar->setVisible(vis); actionSearch->setVisible(vis); actionNext->setVisible(vis); actionPrev->setVisible(vis); actionUndo->setVisible(vis); actionRedo->setVisible(vis); actionCut->setVisible(vis); actionCopy->setVisible(vis); actionPaste->setVisible(vis); actionEP->setVisible(vis); actionEM->setVisible(vis); //printf(" . da\n"); } else if (enterRenameMode->text()=="Rename Mode"){ if ((machPlatz)&&(!dock->isVisible())&&(!histDock->isVisible())) { //printf(" da %d\n",vis); dock->show(); histDock->show(); shxEditorDock->show(); shxEditorDock->raise(); machPlatz=false; } } if (strcmp(PROGRAM_NAME,"shelXle")){ if ((vis)&&(height()>hhh)) { #if defined(linux) showMaximized (); showNormal (); #endif //printf("da\n"); showMaximized (); } } //printf("rename update %lld %s\n",tmr.elapsed(),(vis)?"true":"false"); /* if ((vis)&&(renamDock->isVisible())){chgl->updateLabelTextures(); //printf("rename update textures %lld %d\n",tmr.elapsed(),ran); }*/ } void Window::addNewScatteringFactor(int oz, bool HisD){ QString smbl=((oz==0) && HisD)?"D":chgl->mol->pse(oz); changeElemetofLabel(smbl); if (editor->sfacsmbl.contains(smbl)) { pserbt[oz+1]->setChecked(true); return; } editor->sfac.append(oz); editor->sfacsmbl.append(smbl); int an = ((oz==0) && HisD)?110:editor->sfac.last()+1; pserbt[an]->show(); pserbt[an]->setChecked(true); sfacBox->setFixedSize((editor->sfacsmbl.size()+1)*52,70); QTextDocument *document = editor->document(); QTextCursor cursor = editor->textCursor(); cursor.beginEditBlock(); cursor.movePosition(QTextCursor::End); cursor = document->find("sfac", cursor, QTextDocument::FindBackward); if (!cursor.isNull()){ cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); QString sf = cursor.selectedText().trimmed(); if (sf.size()<77) sf.append(QString(" %1").arg(smbl)); cursor.deleteChar(); cursor.insertText(sf); } cursor.movePosition(QTextCursor::End); cursor = document->find("unit", cursor, QTextDocument::FindBackward); if (!cursor.isNull()){ cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); QString sf = cursor.selectedText().trimmed(); if (sf.size()<77) sf.append(" 1"); cursor.deleteChar(); cursor.insertText(sf); } cursor.endEditBlock(); } void Window::setDefaultPath(){ //!beginGroup("Files"); if (einstellung->contains("defaultPath")) dfpa= einstellung->value("defaultPath").toString(); else dfpa= QDir::homePath(); einstellung->endGroup(); dfpa=QFileDialog::getOpenFileName(this, "set default file directory", dfpa, "SHELX-Files (*.res *.ins);;", nullptr); if (!dfpa.isEmpty()){ einstellung->beginGroup("Files"); einstellung->setValue("defaultPath",dfpa); einstellung->endGroup(); } } void Window::openFile(){ QString location=dirName; if (!QFile::exists(dirName)) { einstellung->beginGroup("Files"); if (einstellung->contains("defaultPath")) location = einstellung->value("defaultPath").toString(); else location = QDir::homePath(); einstellung->endGroup(); } QString fileName = QFileDialog::getOpenFileName(this, tr("Open shelX file "), location, "SHELX-Files (*.res *.ins);;",nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); if (!fileName.isEmpty()) { loadFile(fileName); } update(); } void Window::setShelxlOptions(){ QDialog *shxOptDLG = new QDialog(this); shxOptDLG->setWindowTitle("SHELXL runtime options"); QGridLayout *lt = new QGridLayout(shxOptDLG); QLabel *PathL = new QLabel("Full path to executable",shxOptDLG); shxPath = new QLineEdit(shxOptDLG); QLabel *argumentsL = new QLabel("Commandline options",shxOptDLG); QCheckBox *barray = new QCheckBox(tr("I want to set the B-array size myself")); shxOptions = new QLineEdit(shxOptDLG); shxPath->setText(shelxlPath); shxOptions->setText(shelxlArgs); if (useMyBArray == true) { barray->setChecked(true); } else { barray->setChecked(false); } QPushButton *browsePath = new QPushButton("Browse",shxOptDLG); connect(browsePath,SIGNAL(pressed ()),this, SLOT(setShelxlPath())); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,Qt::Horizontal,shxOptDLG); connect(buttonBox, SIGNAL(accepted()), shxOptDLG, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), shxOptDLG, SLOT(reject())); lt->addWidget(PathL, 1, 0); lt->addWidget(shxPath, 1, 1); lt->addWidget(argumentsL, 2, 0); lt->addWidget(shxOptions, 2, 1); lt->addWidget(browsePath, 1, 2); lt->addWidget(barray, 3, 1, 1, 2); lt->addWidget(buttonBox, 8, 1, 1, 3); shxOptDLG->setLayout(lt); if (shxOptDLG->exec()==QDialog::Accepted) { shelxlArgs=shxOptions->text(); shelxlPath=shxPath->text(); einstellung->beginGroup("Window"); einstellung->setValue("SHELXL-PATH", shelxlPath); einstellung->setValue("SHELXL-OPTION", shelxlArgs); einstellung->setValue("SHELXL-BARRAY", barray->isChecked()); useMyBArray = barray->isChecked(); einstellung->endGroup(); } shxOptDLG->deleteLater (); delete shxPath; delete shxOptions; shxPath=shxOptions=NULL; } void Window::extraSettings(){ // printf("extraSettings()\n"); QDialog *extDLG = new QDialog(this); extDLG->setWindowTitle("External programs"); QGridLayout *lt = new QGridLayout(extDLG); pgms = new QComboBox(extDLG); pgms->addItems(extraProgramNames); connect(pgms,SIGNAL(currentIndexChanged(int)), this, SLOT(updateExtraSettings(int))); QLabel *extraNameL = new QLabel("Name of external program for menu entry:",extDLG); extraName = new QLineEdit(extDLG); extraName->setMinimumSize(150,15); QLabel *extraPathL = new QLabel("Full path to executable",extDLG); extraPath = new QLineEdit(extDLG); QLabel *argumentsL = new QLabel("Commandline options",extDLG); extraArgumentsEdit = new QLineEdit(extDLG); QLabel *altExtL = new QLabel("Alternative file Extension",extDLG); extraAltExtEdit = new QLineEdit(extDLG); QPushButton *browsePath = new QPushButton("Browse",extDLG); extraFakeButton = new QToolButton(extDLG); extraFakeButton->setIconSize(QSize(tbiconSize,tbiconSize)); connect(browsePath,SIGNAL(pressed ()),this, SLOT(setExtraPath())); connect(extraFakeButton,SIGNAL(pressed()),this,SLOT(brwsIcon())); useArgument = new QCheckBox("Give file name as argument",extDLG); omitExtension = new QCheckBox("Omit '*.res' extension in argument",extDLG); absolutePath = new QCheckBox("Use absolute path in argument",extDLG); copyResIns = new QCheckBox("Copy .res file to ins file before execution",extDLG); openFileDialogBefore = new QCheckBox("Open file dialog before execution",extDLG); iconOverlay = new QCheckBox("Text overlay",extDLG); iovlPointSize = new QSpinBox(extDLG); iovlPointSize->setRange(4,96); iovlPointSize->setValue(36); iovlPointSize->setPrefix("PointSize "); connect(iconOverlay,SIGNAL(stateChanged(int)),this,SLOT(updateExtraIcon())); connect(iovlPointSize,SIGNAL(valueChanged(int)),this,SLOT(updateExtraIcon())); detach = new QCheckBox("start detached",extDLG); detach->setChecked(true); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::No| QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel,Qt::Horizontal,extDLG); QPushButton *ok = buttonBox->button(QDialogButtonBox::Ok); ok->setText("Add program"); QPushButton *no =buttonBox->button(QDialogButtonBox::No); no->setText("Remove program"); connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),this,SLOT(removeExtra(QAbstractButton*))); connect(buttonBox, SIGNAL(accepted()), extDLG, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), extDLG, SLOT(reject())); lt->addWidget(pgms,0,0); lt->addWidget(extraNameL,1,0); lt->addWidget(extraName, 1,1); lt->addWidget(extraPathL,2,0); lt->addWidget(extraPath, 2,1); lt->addWidget(browsePath,2,2); lt->addWidget(extraFakeButton,0,1); lt->addWidget(iconOverlay,0,2); lt->addWidget(iovlPointSize,0,3); lt->addWidget(argumentsL,4,0); lt->addWidget(extraArgumentsEdit,4,1); lt->addWidget(altExtL,5,0); lt->addWidget(extraAltExtEdit,5,1); lt->addWidget(useArgument, 1, 9); lt->addWidget(absolutePath, 2, 9); lt->addWidget(omitExtension, 3, 9); lt->addWidget(detach, 4, 9); lt->addWidget(copyResIns, 5, 9); lt->addWidget(openFileDialogBefore, 6, 9); lt->addWidget(buttonBox,14,0,1,11); extDLG->setLayout(lt); altExtraIconPath=""; //printf("extraSettings()\n"); updateExtraSettings(0); while (extraOptions.size()>extraProgramNames.size()){extraOptions.removeLast();} while (extraAbsolutePath.size()>extraProgramNames.size()){extraAbsolutePath.removeLast();} while (extraExt2.size()>extraProgramNames.size()){extraExt2.removeLast();} if (extDLG->exec()==QDialog::Accepted) { int wegmuss=extraProgramNames.indexOf(extraName->text()); if (wegmuss!=-1) { extraProgramNames.removeAt(wegmuss); extraProgramPaths.removeAt(wegmuss); extraArguments.removeAt(wegmuss); extraExtensions.removeAt(wegmuss); if (wegmusstext().trimmed()); extraProgramPaths.append(extraPath->text().trimmed()); extraArguments.append(useArgument->checkState()); extraOptions.append(extraArgumentsEdit->text().trimmed()); extraExt2.append(extraAltExtEdit->text().trimmed()); extraExtensions.append(omitExtension->checkState()); extraAbsolutePath.append(absolutePath->checkState()); extraResIns.append(copyResIns->checkState()); extraOpenFileDialogBefore.append(openFileDialogBefore->checkState()); extraIconOverlay.append(iconOverlay->checkState()); extraOverlayPointSize.append(iovlPointSize->value()); extraDetach.append(detach->checkState()); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); for (int i = 0; i < extraProgramNames.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Name", extraProgramNames.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); for (int i = 0; i < extraProgramPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Path", extraProgramPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AlternativeExtensions",extraExt2.size()); for (int i = 0; i < extraExt2.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("ext", extraExt2.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("CommandLineOptions",extraOptions.size()); for (int i = 0; i < extraOptions.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("opt", extraOptions.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AbsolutePathRequired",extraAbsolutePath.size()); for (int i = 0; i < extraAbsolutePath.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("absolute", extraAbsolutePath.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); for (int i = 0; i < extraArguments.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Arg", extraArguments.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); for (int i = 0; i < extraExtensions.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Ext", extraExtensions.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); for (int i = 0; i < extraResIns.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Res2Ins", extraResIns.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); for (int i = 0; i < extraIconOverlay.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraIconOverlay.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); for (int i = 0; i < extraOverlayPointSize.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraOverlayPointSize.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); for (int i = 0; i < altExtraIconPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("altIcon", altExtraIconPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); for (int i = 0; i < extraDetach.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Detach", extraDetach.at(i)); } einstellung->endArray(); einstellung->endGroup(); extraMenu->clear(); extraTB->clear(); extraMenu->addAction("add/remove external program",this,SLOT(extraSettings())); QFileIconProvider *p = new QFileIconProvider(); if (extraProgramNames.size()) extraMenu->addSeparator(); for (int i=0; iicon(QFileInfo(icopa)); //qDebug()<setPen(QPen(QColor("#FFFFFF"))); QFont ifont=chgl->myFont; ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); paint->setFont(ifont); paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); paint->setPen(QPen(QColor("#000000"))); paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); paint->end(); } extraIcon=QIcon(fmap); a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); a->setData(i); extraTB->addAction(a); } //printf("extraSettings()\n"); delete p; } extDLG->deleteLater (); if (strcmp(PROGRAM_NAME,"shelXle")){ QMessageBox::information(0,"information","Restart of APEX is required to make your changes to external programs active. ",QMessageBox::Ok); } // printf("extraSettings()\n"); } void Window::extraSettingsLast(){ QDialog *extDLG = new QDialog(this); extDLG->setWindowTitle("External programs"); QGridLayout *lt = new QGridLayout(extDLG); pgms = new QComboBox(extDLG); pgms->addItems(extraProgramNames); connect(pgms,SIGNAL(currentIndexChanged(int)), this, SLOT(updateExtraSettings(int))); QLabel *extraNameL = new QLabel("Name of external program for menu entry:",extDLG); extraName = new QLineEdit(extDLG); extraName->setMinimumSize(150,15); QLabel *extraPathL = new QLabel("Full path to executable",extDLG); extraPath = new QLineEdit(extDLG); QLabel *argumentsL = new QLabel("Commandline options",extDLG); extraArgumentsEdit = new QLineEdit(extDLG); QLabel *altExtL = new QLabel("Alternative file Extension",extDLG); extraAltExtEdit = new QLineEdit(extDLG); QPushButton *browsePath = new QPushButton("Browse",extDLG); extraFakeButton = new QToolButton(extDLG); extraFakeButton->setIconSize(QSize(tbiconSize,tbiconSize)); connect(browsePath,SIGNAL(pressed ()),this, SLOT(setExtraPath())); connect(extraFakeButton,SIGNAL(pressed()),this,SLOT(brwsIcon())); useArgument = new QCheckBox("Give file name as argument",extDLG); omitExtension = new QCheckBox("Omit '*.res' extension in argument",extDLG); absolutePath = new QCheckBox("Use absolute path in argument",extDLG); copyResIns = new QCheckBox("Copy .res file to ins file before execution",extDLG); openFileDialogBefore = new QCheckBox("Open file dialog before execution",extDLG); iconOverlay = new QCheckBox("Text overlay",extDLG); iovlPointSize = new QSpinBox(extDLG); iovlPointSize->setRange(4,96); iovlPointSize->setValue(36); iovlPointSize->setPrefix("PointSize "); connect(iconOverlay,SIGNAL(stateChanged(int)),this,SLOT(updateExtraIcon())); connect(iovlPointSize,SIGNAL(valueChanged(int)),this,SLOT(updateExtraIcon())); detach = new QCheckBox("start detached",extDLG); detach->setChecked(true); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::No| QDialogButtonBox::Ok | QDialogButtonBox::Cancel,Qt::Horizontal,extDLG); QPushButton *ok = buttonBox->button(QDialogButtonBox::Ok); ok->setText("Add program"); QPushButton *no =buttonBox->button(QDialogButtonBox::No); no->setText("Remove program"); connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),this,SLOT(removeExtra(QAbstractButton*))); connect(buttonBox, SIGNAL(accepted()), extDLG, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), extDLG, SLOT(reject())); lt->addWidget(pgms,0,0); lt->addWidget(extraNameL,1,0); lt->addWidget(extraName, 1,1); lt->addWidget(extraPathL,2,0); lt->addWidget(extraPath, 2,1); lt->addWidget(browsePath,2,2); lt->addWidget(extraFakeButton,0,1); lt->addWidget(iconOverlay,0,2); lt->addWidget(iovlPointSize,0,3); lt->addWidget(argumentsL,4,0); lt->addWidget(extraArgumentsEdit,4,1); lt->addWidget(altExtL,5,0); lt->addWidget(extraAltExtEdit,5,1); lt->addWidget(useArgument, 1, 9); lt->addWidget(absolutePath, 2, 9); lt->addWidget(omitExtension, 3, 9); lt->addWidget(detach, 4, 9); lt->addWidget(copyResIns, 5, 9); lt->addWidget(openFileDialogBefore, 6, 9); lt->addWidget(buttonBox,14,0,1,11); extDLG->setLayout(lt); altExtraIconPath=""; pgms->setCurrentIndex(extraProgramNames.size()-1); updateExtraSettings(extraProgramNames.size()-1); while (extraOptions.size()>extraProgramNames.size()){extraOptions.removeLast();} while (extraExt2.size()>extraProgramNames.size()){extraExt2.removeLast();} if (extDLG->exec()==QDialog::Accepted) { int wegmuss=extraProgramNames.indexOf(extraName->text()); if (wegmuss!=-1) { extraProgramNames.removeAt(wegmuss); extraProgramPaths.removeAt(wegmuss); extraArguments.removeAt(wegmuss); extraExtensions.removeAt(wegmuss); if (wegmusstext().trimmed()); extraProgramPaths.append(extraPath->text().trimmed()); extraArguments.append(useArgument->checkState()); extraOptions.append(extraArgumentsEdit->text().trimmed()); extraExt2.append(extraAltExtEdit->text().trimmed()); extraExtensions.append(omitExtension->checkState()); extraAbsolutePath.append(absolutePath->checkState()); extraResIns.append(copyResIns->checkState()); extraOpenFileDialogBefore.append(openFileDialogBefore->checkState()); extraIconOverlay.append(iconOverlay->checkState()); extraOverlayPointSize.append(iovlPointSize->value()); extraDetach.append(detach->checkState()); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); for (int i = 0; i < extraProgramNames.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Name", extraProgramNames.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); for (int i = 0; i < extraProgramPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Path", extraProgramPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AlternativeExtensions",extraExt2.size()); for (int i = 0; i < extraExt2.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("ext", extraExt2.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("CommandLineOptions",extraOptions.size()); for (int i = 0; i < extraOptions.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("opt", extraOptions.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AbsolutePathRequired",extraAbsolutePath.size()); for (int i = 0; i < extraAbsolutePath.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("absolute", extraAbsolutePath.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); for (int i = 0; i < extraArguments.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Arg", extraArguments.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); for (int i = 0; i < extraExtensions.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Ext", extraExtensions.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); for (int i = 0; i < extraResIns.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Res2Ins", extraResIns.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); for (int i = 0; i < extraIconOverlay.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraIconOverlay.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); for (int i = 0; i < extraOverlayPointSize.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraOverlayPointSize.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); for (int i = 0; i < altExtraIconPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("altIcon", altExtraIconPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); for (int i = 0; i < extraDetach.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Detach", extraDetach.at(i)); } einstellung->endArray(); einstellung->endGroup(); extraMenu->clear(); extraTB->clear(); extraMenu->addAction("add/remove external program",this,SLOT(extraSettings())); QFileIconProvider *p = new QFileIconProvider(); if (extraProgramNames.size()) extraMenu->addSeparator(); for (int i=0; iicon(QFileInfo(icopa)); //qDebug()<setPen(QPen(QColor("#FFFFFF"))); QFont ifont=chgl->myFont; ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); paint->setFont(ifont); paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); paint->setPen(QPen(QColor("#000000"))); paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); paint->end(); } extraIcon=QIcon(fmap); a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); a->setData(i); extraTB->addAction(a); } delete p; } // printf("extraSettingsLast()\n"); extDLG->deleteLater (); if (strcmp(PROGRAM_NAME,"shelXle")){ QMessageBox::information(0,"information","Restart of APEX is required to make your changes to external programs active. ",QMessageBox::Ok); } // printf("extraSettingsLast()\n"); } void Window::removeExtra(QAbstractButton *button){ if (button->text()=="Remove program") { int wegmuss=extraProgramNames.indexOf(extraName->text()); if (wegmuss!=-1) { extraProgramNames.removeAt(wegmuss); extraProgramPaths.removeAt(wegmuss); extraArguments.removeAt(wegmuss); extraExtensions.removeAt(wegmuss); if (wegmussextraProgramNames.size()){extraOptions.removeLast();} while (extraExt2.size()>extraProgramNames.size()){extraExt2.removeLast();} einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); for (int i = 0; i < extraProgramNames.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Name", extraProgramNames.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); for (int i = 0; i < extraProgramPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Path", extraProgramPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); for (int i = 0; i < extraArguments.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Arg", extraArguments.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); for (int i = 0; i < extraExtensions.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Ext", extraExtensions.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); for (int i = 0; i < extraResIns.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Res2Ins", extraResIns.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); for (int i = 0; i < extraIconOverlay.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraIconOverlay.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); for (int i = 0; i < extraOverlayPointSize.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraOverlayPointSize.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); for (int i = 0; i < altExtraIconPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("altIcon", altExtraIconPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); for (int i = 0; i < extraDetach.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Detach", extraDetach.at(i)); } einstellung->endArray(); einstellung->endGroup(); extraMenu->clear(); extraMenu->addAction("add external program",this,SLOT(extraSettings())); extraTB->clear(); QFileIconProvider *epic = new QFileIconProvider(); if (extraProgramNames.size()) extraMenu->addSeparator(); for (int i=0; iicon(QFileInfo(icopa)); //qDebug()<setPen(QPen(QColor("#FFFFFF"))); QFont ifont=chgl->myFont; ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); paint->setFont(ifont); paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); paint->setPen(QPen(QColor("#000000"))); paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); paint->end(); } extraIcon=QIcon(fmap); a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); a->setData(i); extraTB->addAction(a); } delete epic; } else if (button->text()=="Apply"){ int wegmuss = pgms->currentIndex(); if ((wegmuss < 0)||(wegmuss >= extraProgramNames.size())) return; printf("changing extra programm %d\n", wegmuss); altExtraIconPaths[wegmuss] = altExtraIconPath; extraProgramNames[wegmuss] = extraName->text().trimmed(); extraProgramPaths[wegmuss] = extraPath->text().trimmed(); extraArguments[wegmuss] = useArgument->checkState(); extraOptions[wegmuss] = extraArgumentsEdit->text().trimmed(); extraExt2[wegmuss] = extraAltExtEdit->text().trimmed(); extraExtensions[wegmuss] = omitExtension->checkState(); extraAbsolutePath[wegmuss] = absolutePath->checkState(); extraResIns[wegmuss] = copyResIns->checkState(); extraOpenFileDialogBefore[wegmuss] = openFileDialogBefore->checkState(); extraIconOverlay[wegmuss] = iconOverlay->checkState(); extraOverlayPointSize[wegmuss] = iovlPointSize->value(); extraDetach[wegmuss] = detach->checkState(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); for (int i = 0; i < extraProgramNames.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Name", extraProgramNames.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); for (int i = 0; i < extraProgramPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Path", extraProgramPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AlternativeExtensions",extraExt2.size()); for (int i = 0; i < extraExt2.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("ext", extraExt2.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("CommandLineOptions",extraOptions.size()); for (int i = 0; i < extraOptions.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("opt", extraOptions.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AbsolutePathRequired",extraAbsolutePath.size()); for (int i = 0; i < extraAbsolutePath.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("absolute", extraAbsolutePath.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); for (int i = 0; i < extraArguments.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Arg", extraArguments.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); for (int i = 0; i < extraExtensions.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Ext", extraExtensions.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); for (int i = 0; i < extraResIns.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Res2Ins", extraResIns.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); for (int i = 0; i < extraIconOverlay.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraIconOverlay.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); for (int i = 0; i < extraOverlayPointSize.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("icov", extraOverlayPointSize.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); for (int i = 0; i < altExtraIconPaths.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("altIcon", altExtraIconPaths.at(i)); } einstellung->endArray(); einstellung->endGroup(); einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); for (int i = 0; i < extraDetach.size(); i++) { einstellung->setArrayIndex(i); einstellung->setValue("Detach", extraDetach.at(i)); } einstellung->endArray(); einstellung->endGroup(); extraMenu->clear(); extraTB->clear(); extraMenu->addAction("add/remove external program",this,SLOT(extraSettings())); //QFileIconProvider *p = new QFileIconProvider(); if (extraProgramNames.size()) extraMenu->addSeparator(); for (int i=0; iicon(QFileInfo(icopa)); //qDebug()<setPen(QPen(QColor("#FFFFFF"))); QFont ifont=chgl->myFont; ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); paint->setFont(ifont); paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); paint->setPen(QPen(QColor("#000000"))); paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); paint->end(); } extraIcon=QIcon(fmap); a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); a->setData(i); extraTB->addAction(a); } pgms->removeItem(wegmuss); pgms->insertItem(wegmuss,extraName->text().trimmed()); pgms->setCurrentIndex(wegmuss); } } void Window::updateExtraSettings(){ updateExtraSettings(0); } void Window::updateExtraSettings(int index){ if ((index<0)||(index>=extraProgramNames.size())) return; extraName->setText(extraProgramNames.at(index)); extraPath->setText(extraProgramPaths.at(index)); altExtraIconPath=(indexsetText(extraOptions.at(index)); extraAltExtEdit->setText(extraExt2.at(index)); QFileIconProvider *epic = new QFileIconProvider(); QString icopa=extraProgramPaths.at(index); QIcon ico = epic->icon(QFileInfo(icopa)); //qDebug()<setPen(QPen(QColor("#FFFFFF"))); QFont ifont=chgl->myFont; ifont.setPixelSize(qMax(iovlPointSize->value()*fmap.height()/64,2)); paint->setFont(ifont); paint->drawText(1,fmap.height()-5,extraProgramNames.at(index)); paint->setPen(QPen(QColor("#000000"))); paint->drawText(0,fmap.height()-4,extraProgramNames.at(index)); paint->end(); } extraIcon=QIcon(fmap); extraFakeButton->setIcon(extraIcon); delete epic; useArgument->setCheckState(extraArguments.at(index)); absolutePath->setCheckState(extraAbsolutePath.at(index)); omitExtension->setCheckState(extraExtensions.at(index)); if (indexsetCheckState(extraResIns.at(index)); if (indexsetCheckState(extraOpenFileDialogBefore.at(index)); if (indexsetCheckState(extraIconOverlay.at(index)); if (indexsetValue(extraOverlayPointSize.at(index)); detach->setCheckState(extraDetach.at(index)); update(); } void Window::updateExtraIcon(){ QPixmap fmap; if (altExtraIconPath.isEmpty()){ QFileIconProvider *epic = new QFileIconProvider(); QIcon ico = epic->icon(QFileInfo(extraPath->text())); //qDebug()<isChecked()){ QPainter *paint = new QPainter(&fmap); paint->setPen(QPen(QColor("#FFFFFF"))); QFont ifont=chgl->myFont; ifont.setPixelSize(qMax(iovlPointSize->value()*fmap.height()/64,2)); paint->setFont(ifont); paint->drawText(1, fmap.height()-5,extraName->text()); paint->setPen(QPen(QColor("#000000"))); paint->drawText(0, fmap.height()-4,extraName->text()); paint->end(); } extraIcon=QIcon(fmap); extraFakeButton->setIcon(extraIcon); } void Window::setExtraPath(){ QString s = QFileDialog::getOpenFileName(this, "Path to external program executable", extraPath->text(), QString(),nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); if (!s.isEmpty()){ extraPath->setText(s); updateExtraIcon();; } } void Window::brwsIcon(){ QString path=""; #if defined (Q_WS_X11) path="/usr/share/pixmaps/"; #endif QString *filter=NULL,s= QFileDialog::getOpenFileName(this,QString("Select icon source"),//caption path, "Icon files (*.xpm *.png *.ico *.svg);;",filter, (useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); if (QFile::exists(s)) altExtraIconPath=s; updateExtraIcon(); } void Window::runExtra(){ QAction *action = qobject_cast(sender()); int index=0; if (action){ index=action->data().toInt(); } else { return; } if ((index<0)||(index>=extraProgramNames.size())) return; extraOutput->hide(); delete extraOutput; extraIndex = index; extraOutput = new QDialog(this); lt = new QVBoxLayout(); extraOutPut = new QTextEdit(); QFont mospfo(FONTFAM); extraOutPut->setFont(mospfo); #if (QT_VERSION >=0x050000) extraOutput->setMinimumWidth( QFontMetrics(extraOutPut->font()) .horizontalAdvance("#########################################################################################################################################")); #else extraOutput->setMinimumWidth( QFontMetrics(extraOutPut->font()) .width("###########################################################################################")); #endif extraOutPut->setLineWrapMode(QTextEdit::NoWrap); lt->addWidget(extraOutPut); extraOutput->setLayout(lt); extraOutput->setWindowTitle(QString("Running %1 ...").arg(extraProgramNames.at(index))); extraOutPut->clear(); QString path,name; path=extraProgramPaths.at(index); #if defined (Q_WS_MAC) if ((QFileInfo(path).isDir())&&(path.endsWith(".app",Qt::CaseInsensitive))){ path.append("/Contents/MacOS/"); path.append(QDir(path).entryList(QDir::Executable|QDir::Files).first()); } #endif QString dn=dirName.section('/',0,-2), argument=dirName.section('/',-1); if (extraOpenFileDialogBefore.at(index)==Qt::Checked){ QString oMyDir= QFileDialog::getOpenFileName(this,QString("Open a file for %1").arg(extraProgramNames.at(index)),//caption dn,QString(),nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); dn=oMyDir.section('/',0,-2); argument=oMyDir.section('/',-1); } if (extraExtensions.at(index)==Qt::Checked) argument.remove(QRegularExpression(".res$|.ins$|.p4p$|.cif$",QRegularExpression::CaseInsensitiveOption)); if (extraResIns.at(index)==Qt::Checked) { //##@##bruce will es // //printf("bruce will es\n"); if (maybeSave2()){ QString dn=dirName.section('/',0,-2), argument=dirName.section('/',-1); argument.remove(resorins); if (dirName.contains(punktres)){ QString insname =dirName; insname.replace(punktres,".ins"); QString fcfname = dirName; fcfname.replace(punktres,".fcf"); QString fcfname2 = dirName; fcfname2.replace(punktres,".2fcf"); if ((QFileInfo(dirName).lastModified()>=QFileInfo(insname).lastModified())){ QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QStringList filter; filter << QString("%1_*_.ins").arg(argument); QStringList resfs; resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); int vers=0; if (resfs.isEmpty()) vers=1; else { bool ok=true; for (int i = 0; i < resfs.size(); i++) vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); vers++; } if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(insname); QFile::copy(dirName,insname); QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(fcfname2); QFile::copy(fcfname,fcfname2); } else { int but=QMessageBox::information(0,"information", QString("

The instruction file is newer than the result file you are working on!

%1 %2
%3
%4
Maybe you edited it outside of this program.\
Now the your computer clock says: %5
%6 %7 (negative numbers here probably indicate asynchronous clocks on network file systems.)

Click on 'Ignore' to copy your current .res to .ins file and refine.") .arg(insname) .arg(dirName) .arg(QFileInfo(insname).lastModified().toString(Qt::TextDate)) .arg(QFileInfo(dirName).lastModified().toString(Qt::TextDate)) .arg(QDateTime::currentDateTime().toString(Qt::TextDate)) #if (QT_VERSION >= 0x040700) .arg(QFileInfo(insname).lastModified().msecsTo(QDateTime::currentDateTime())) .arg(QFileInfo(dirName).lastModified().msecsTo(QDateTime::currentDateTime())) #else .arg(QFileInfo(insname).lastModified().secsTo(QDateTime::currentDateTime())) .arg(QFileInfo(dirName).lastModified().secsTo(QDateTime::currentDateTime())) #endif ,QMessageBox::Ignore|QMessageBox::Ok); if (but==QMessageBox::Ignore){ QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QStringList filter; filter << QString("%1_*_.ins").arg(argument); QStringList resfs; resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); int vers=0; if (resfs.isEmpty()) vers=1; else { bool ok=true; for (int i = 0; i < resfs.size(); i++) vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); vers++; } if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(insname); QFile::copy(dirName,insname); QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(fcfname2); QFile::copy(fcfname,fcfname2); }else{ shxOutputDock->hide(); infotainmentDock->hide(); refineButtonBox->hide(); pro7->hide(); refineButtonBox2->hide(); stoppRefinement->hide(); stoppRefinement2->hide(); finishRefinement->hide(); finishRefinement2->hide(); shxEditorDock->show(); dock->show(); histDock->show(); return; } } }else{ QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QStringList filter; filter << QString("%1_*_.ins").arg(argument); QStringList resfs; resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); int vers=0; if (resfs.isEmpty()) vers=1; else { bool ok=true; for (int i = 0; i < resfs.size(); i++) vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); vers++; } if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QFile::copy(dirName,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); } } /// bruce will es } if ((extraExt2.size()>index)&&(!extraExt2.at(index).isEmpty())){ argument.remove(resorins); argument.append(extraExt2.at(index)); } extraProc = new QProcess(this); QStringList al; if ((extraOptions.size()>index)&&(!extraOptions.at(index).isEmpty())) al.append(extraOptions.at(index)); if (extraArguments.at(index)==Qt::Checked){ if (extraAbsolutePath.at(index)==Qt::Checked) al.append(dirName); else al.append(argument); } extraProc->setWorkingDirectory(dn); // updateXLput() connect(extraProc,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateExtraOutput())); connect(extraProc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateExtraOutput())); connect(extraProc,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateExtraOutput())); #if (QT_VERSION >= 0x040600) QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); extraProc->setProcessEnvironment(env);//Thanks to Dr. Pavlo Solntsev!! #else QStringList env = QProcess::systemEnvironment(); extraProc->setEnvironment(env); #endif QString dummyargument=al.join(" "); al=dummyargument.split(" "); if (extraDetach.at(index)) { #if (QT_VERSION >= 0x050700) #if defined Q_WS_WIN || defined Q_OS_WIN extraProc->setProgram(path); extraProc->setArguments(al); extraProc->setWorkingDirectory(dn); extraProc->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) {args->flags &= ~CREATE_NO_WINDOW;}); extraProc->startDetached(); /* //https://bugreports.qt.io/browse/QTBUG-57687?focusedCommentId=354550&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-354550 QProcess p; p.setProgram("cmd.exe"); p.setArguments({"/k", "echo", "Hello from Qt!"}); p.setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) { args->flags &= ~CREATE_NO_WINDOW; }); p.startDetached(); */ #else extraProc->startDetached(path,al,dn); #endif #else extraProc->startDetached(path,al,dn); #endif } else { extraProc->start(path,al); extraOutPut->setText(QString("|--- Running %1 %2 in %3 ---|\n").arg(path).arg(al.join(" ")).arg(dn)); extraOutput->show(); } } void Window::updateExtraOutput(){ #if (QT_VERSION >= 0x050300) if (extraProc->processId()) { #else if (extraProc->pid()) { #endif extraOutPut->setReadOnly(false); QString s=extraOutPut->toPlainText(); s.append(extraProc->readAllStandardOutput()); s.append(extraProc->readAllStandardError()); extraOutPut->setPlainText(s); extraOutPut->moveCursor(QTextCursor::End); extraOutPut->ensureCursorVisible (); extraOutPut->setReadOnly(true); extraProc->write("\n"); // this is sent to fake a 'pause' waiting for any key so that the script continues }else{ extraOutPut->setReadOnly(false); QString s=extraOutPut->toPlainText(); s.append(extraProc->readAllStandardOutput()); s.append(extraProc->readAllStandardError()); if (s.isEmpty()) { s.append("|---Program is not running!---|\n"); extraIndex = -1; } else{ if ((s.endsWith(" ---|\n"))&&(extraIndex>-1)){ einstellung->beginGroup("Extra"); einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); einstellung->setArrayIndex(extraIndex); einstellung->setValue("Detach", Qt::Checked); extraDetach[extraIndex] = Qt::Checked; einstellung->endArray(); einstellung->endGroup(); printf("There was no output. I will start this program detached in future. I hope that is Ok.\n"); } if ((extraIndex == -21)&&(QFile::exists(pngName))){ //here should be a png output file of povray be loaded QLabel *preview = new QLabel(""); int eh = extraOutput->height(), ew = extraOutput->width(); preview->setPixmap(QPixmap(pngName)); if (qsaPNG==nullptr) qsaPNG = new QScrollArea(extraOutput); qsaPNG->setWidget(preview); lt->addWidget(qsaPNG); QString s=extraOutPut->toPlainText(); s.append("\n|---Program is finished.---|\n"); extraOutput->resize(ew,2*eh); }else{ s.append("\n|---Program is finished.---|\n"); QString dn=dirName.section('/',0,-2), argument=dirName.section('/',-1); argument.remove(QRegularExpression(".res$|.ins$|.cif$",QRegularExpression::CaseInsensitiveOption)); QDir work=QDir(QString("%1/").arg(dn)); QStringList filter; filter << QString("%1*.res").arg(argument)<< QString("%1*.ins").arg(argument);; QStringList resfs; resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); QList oldbuts = extraOutput->findChildren("resloadbutton"); //printf("old buttons %d\n",oldbuts.size()); for (int i=oldbuts.size()-1; i>=0; i--) { oldbuts[i]->setVisible(false); oldbuts[i]->deleteLater(); } QHBoxLayout *hbl=new QHBoxLayout(); QToolButton *tbb0=new QToolButton(); QAction *ac0=new QAction(QString("cancel"),this); connect(ac0,SIGNAL(triggered()),extraOutput,SLOT(reject())); tbb0->setDefaultAction(ac0); tbb0->setObjectName("resloadbutton"); for (int i=0; isetData(QString("%1/%2").arg(dn).arg(resfs.at(i))); connect(ac,SIGNAL(triggered()),this,SLOT(loadThisFile())); QToolButton *tbb=new QToolButton(); tbb->setDefaultAction(ac); tbb->setObjectName("resloadbutton"); hbl->addWidget(tbb); } hbl->addWidget(tbb0); lt->addLayout(hbl); }//-21 extraIndex = -1; } extraOutPut->setPlainText(s); extraOutPut->moveCursor(QTextCursor::End); extraOutPut->ensureCursorVisible (); extraOutPut->setReadOnly(true); } } void Window::loadThisFile(){ extraOutput->hide(); QAction *action = qobject_cast(sender()); QString name=""; if (action) name=action->data().toString(); else return; if (name.isEmpty()) return; loadFile(name); } void Window::configureBottomToolbar(){ QAction *action = qobject_cast(sender()); int index=0; if (action) index=action->data().toInt(); else return; if ((index>=0)&&(index<5)) bottomToolBar->setToolButtonStyle((Qt::ToolButtonStyle) index); if (index>32) { index-=32; addToolBarBreak(); addToolBar((Qt::ToolBarArea) index,bottomToolBar); } einstellung->beginGroup("ToolBar"); einstellung->setValue("SelectionToolBarStyle",bottomToolBar->toolButtonStyle()); einstellung->endGroup(); } void Window::grossRC(const QString &text){ QString s=text.toUpper (); resiResiClass->setText(s); update(); } void Window::defineBarray() { //! This method adjusts the value for the B array in SHELXL according to the number of atoms. //! The calculation is not rocket science, but should work in every case. int barray; if (useMyBArray) { return; // the user wants to have his own value; } barray = mole.asymm.size() * 9; // Can fail with very large molecules. if (barray > 3000) { // B array == 3000 is defult shelxlArgs = shelxlArgs.simplified(); if (!shelxlArgs.contains("-b")) { shelxlArgs += QString(" -b%1").arg(barray); } else { shelxlArgs.replace(QRegularExpression("\\s{0,2}\\-b\\s{0,1}\\d{0,8}"), QString(" -b%1").arg(barray)); } } } void Window::runShelXL(){ QAction *action = qobject_cast(sender()); if (action){ if (action->data().toInt()==1) {editor->insertAnis(); if (!fileSave(true,false)) return;} if (action->data().toInt()==2) {editor->insertActa(); if (!fileSave(true,false)) return;} if (action->data().toInt()==3) {editor->insertEXTI(); if (!fileSave(true,false)) return;} if (action->data().toInt()==4) {editor->insertCONF(); if (!fileSave(true,false)) return;} } if (maybeSave2()){ if (mole.qbeforehkl) deleteAllQ(); // printf("runXL line %d",__LINE__); editor->insertList6(); xlPutor->clear(); xlPutor->ListFile=false; //xlPutor->highlighter->loadHighlightPatterns(lstpatternfile); shxOutputDock->show(); stoppRefinement->show(); finishRefinement->show(); finishRefinement->setFocus(); QObject::disconnect(stoppRefinement, 0, this, 0); if (infotainmentDock->isVisible())finishRefinement2->setFocus(); stoppRefinement2->show(); finishRefinement2->show(); QObject::disconnect(stoppRefinement2, 0, this, 0); refineButtonBox->hide(); pro7->hide(); loadRes->show(); refineButtonBox2->hide(); loadRes2->show(); shxEditorDock->hide(); dock->hide(); histDock->hide(); renamDock->hide(); QString dn=dirName.section('/',0,-2), argument=dirName.section('/',-1); argument.remove(resorins); if (dirName.contains(punktres)){ QString insname =dirName; insname.replace(punktres,".ins"); QString fcfname = dirName; fcfname.replace(punktres,".fcf"); QString fcfname2 = dirName; fcfname2.replace(punktres,".2fcf"); // qDebug()<=QFileInfo(insname).lastModified()); if (//(0)&& (QFileInfo(dirName).lastModified()>=QFileInfo(insname).lastModified())){ QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QStringList filter; filter << QString("%1_*_.ins").arg(argument); QStringList resfs; resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); int vers=0; if (resfs.isEmpty()) vers=1; else { bool ok=true; for (int i = 0; i < resfs.size(); i++) vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); vers++; } if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(insname); QFile::copy(dirName,insname); QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(fcfname2); QFile::copy(fcfname,fcfname2); } else { int but=QMessageBox::information(0,"information", QString("

The instruction file is newer than the result file you are working on!

%1 %2
%3
%4
Maybe you edited it outside of this program.\
Now the your computer clock says: %5
%6 %7 (negative numbers here probably indicate asynchronous clocks on network file systems.)

Click on 'Ignore' to copy your current .res to .ins file and refine.") .arg(insname) .arg(dirName) .arg(QFileInfo(insname).lastModified().toString(Qt::TextDate)) .arg(QFileInfo(dirName).lastModified().toString(Qt::TextDate)) .arg(QDateTime::currentDateTime().toString(Qt::TextDate)) #if (QT_VERSION >= 0x040700) .arg(QFileInfo(insname).lastModified().msecsTo(QDateTime::currentDateTime())) .arg(QFileInfo(dirName).lastModified().msecsTo(QDateTime::currentDateTime())) #else .arg(QFileInfo(insname).lastModified().secsTo(QDateTime::currentDateTime())) .arg(QFileInfo(dirName).lastModified().secsTo(QDateTime::currentDateTime())) #endif ,QMessageBox::Ignore|QMessageBox::Ok); if (but==QMessageBox::Ignore){ QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QStringList filter; filter << QString("%1_*_.ins").arg(argument); QStringList resfs; resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); int vers=0; if (resfs.isEmpty()) vers=1; else { bool ok=true; for (int i = 0; i < resfs.size(); i++) vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); vers++; } if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(insname); QFile::copy(dirName,insname); QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); QFile::remove(fcfname2); QFile::copy(fcfname,fcfname2); }else{ shxOutputDock->hide(); infotainmentDock->hide(); refineButtonBox->hide(); pro7->hide(); refineButtonBox2->hide(); finishRefinement->hide(); finishRefinement2->hide(); stoppRefinement->hide(); stoppRefinement2->hide(); shxEditorDock->show(); dock->show(); histDock->show(); return; } } }else{ QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QStringList filter; filter << QString("%1_*_.ins").arg(argument); QStringList resfs; resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); int vers=0; if (resfs.isEmpty()) vers=1; else { bool ok=true; for (int i = 0; i < resfs.size(); i++) vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); vers++; } if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); QFile::copy(dirName,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); } //printf("runXL!123\n"); shxOutputDock->setWindowTitle(QString("SHELXL OUTPUT: %1").arg(argument)); shxOutputDock->show(); shxOutputDock->raise(); shelxl = new QProcess(this); QStringList al; al.append(argument); defineBarray(); finishRefinement->setFocus(); vis_settings->beginGroup("infotaiment"); bool lastvis = vis_settings->value("info_as_default").toBool(); vis_settings->endGroup(); if (lastvis) { raiseTaff(); finishRefinement2->setFocus(); } al+=shelxlArgs.split(' ',skipEmptyParts); shelxl->setWorkingDirectory(dn); // updateXLput() if (focusSet) connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),loadRes ,SLOT(setFocus())); if ((lastvis)&&(focusSet)) connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),loadRes2 ,SLOT(setFocus())); #if (QT_VERSION >= 0x060400) connect(shelxl,&QProcess::readyReadStandardOutput,this,&Window::updateXLput); connect(shelxl,&QProcess::finished, refineButtonBox, &QGroupBox::show); connect(shelxl,&QProcess::finished, refineButtonBox2, &QGroupBox::show); connect(shelxl,&QProcess::finished, stoppRefinement, &QPushButton::hide); connect(shelxl,&QProcess::finished, finishRefinement, &QPushButton::hide); connect(shelxl,&QProcess::finished, finishRefinement2, &QPushButton::hide); connect(shelxl,&QProcess::finished, stoppRefinement2, &QPushButton::hide); connect(shelxl,&QProcess::finished, this, &Window::updateXLput); connect(shelxl,&QProcess::finished, this, &Window::displayDisagreeableRestraints); connect(shelxl,&QProcess::errorOccurred,this,&Window::updateXLput); #else connect(shelxl,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateXLput())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),refineButtonBox ,SLOT(show())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),refineButtonBox2 ,SLOT(show())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),stoppRefinement ,SLOT(hide())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),finishRefinement ,SLOT(hide())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),finishRefinement2 ,SLOT(hide())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),stoppRefinement2 ,SLOT(hide())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateXLput())); connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(displayDisagreeableRestraints())); connect(shelxl,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateXLput())); //printf("QT??? %X\n",QT_VERSION); #endif connect(finishRefinement,SIGNAL(clicked()),this,SLOT(finXL())); connect(finishRefinement2,SIGNAL(clicked()),this,SLOT(finXL())); #if defined Q_WS_WIN || defined Q_OS_WIN connect(stoppRefinement,SIGNAL(clicked()),shelxl,SLOT(kill())); connect(stoppRefinement2,SIGNAL(clicked()),shelxl,SLOT(kill())); #else connect(stoppRefinement,SIGNAL(clicked()),shelxl,SLOT(terminate())); connect(stoppRefinement2,SIGNAL(clicked()),shelxl,SLOT(terminate())); #endif connect(stoppRefinement,SIGNAL(clicked()),loadRes,SLOT(hide())); connect(stoppRefinement2,SIGNAL(clicked()),loadRes2,SLOT(hide())); shelxl->start(shelxlPath,al); //printf("runXL!123 123\n"); pro7->show(); } } void Window::displayResiduals(XLOutputParser &lfo, QString s) { //! Draws the residuals of the refinement as a table //qDebug()<clear(); foreach (QString line, s.split(QRegularExpression("\n|\r\n|\r"))) { resid_label->setText(lfo.residualsTextDisplay(line, ls_cycls)); } } void Window::displayDisagreeableRestraints() { //! Displays the list of disagreeable restraints in the restr_table widget //! This has to be started ofter SHELXL is finished! (via signal) QFileInfo lfi(dirName); QString restrtext = "There is no SHELXL list file available for this structure. Please refine to get output here."; QString lfpath; lfpath = lfi.absoluteFilePath().replace(".res", ".lst"); if (QFile(lfpath).exists()) { ListFileHandler lf(lfpath); restrtext = lf.restraintsTable(); } restr_table->setText(restrtext); } void Window::updateXLput(){ XLOutputParser xlo; QString warn = "** NO running Process maybe the 'shelxl' is not in PATH or is spelled differently **\n\n" "** Please give a correct path to an existing executable of shelxl. **\n\n" "** Check SHELXL -> 'Specify SHELXL runtime options' **"; if (infotainmentDock->isVisible())finishRefinement2->setFocus(); else finishRefinement->setFocus(); #if (QT_VERSION >= 0x050300) if (shelxl->processId()&&shelxl->isOpen()) { #else if (shelxl->pid()&&shelxl->isOpen()) { #endif // printf("updateXLput()\n"); xlPutor->setReadOnly(false); QString s=xlPutor->toPlainText(); s.append(shelxl->readAllStandardOutput()); s.append(shelxl->readAllStandardError()); //qDebug()<<__LINE__<state()==QProcess::NotRunning) { s.append(warn); resid_label->append("" + warn.replace("\n", "
") + "
"); refineButtonBox->show(); stoppRefinement->hide(); finishRefinement->hide(); finishRefinement2->hide(); refineButtonBox2->show(); stoppRefinement2->hide(); } xlPutor->setPlainText(s); falschAtom=-1; xlPutor->setReadOnly(true); loadRes->setEnabled((s.contains("for all data"))); loadRes2->setEnabled((s.contains("for all data"))); if ((focusSet)&&(!s.contains("for all data"))) withdraw->setFocus(); if (s.contains(" ** ")) { QString Fehl=s.section("**",1,1).simplified(); Fehl=Fehl.remove("UNSUITABLE AFIX HYDROGENS FOLLOW "); Fehl=Fehl.remove("BAD Ueq DEPENDENCE FOR "); Fehl=Fehl.remove("BAD AFIX FOR "); Fehl=Fehl.remove("BAD AFIX CONNECTIVITY: "); Fehl=Fehl.remove("NO PIVOT ATOM FOR RIGID GROUP CONTAINING "); Fehl=Fehl.simplified(); Fehl=Fehl.section(' ',0,0); if ((Fehl.size()<5)||Fehl.contains('_')){ chgl->mol->selectedatoms.clear(); for (int i=0; imol->showatoms.size(); i++){ if (!Fehl.compare(chgl->mol->showatoms.at(i).Label,Qt::CaseInsensitive)){ chgl->mol->selectedatoms.append(chgl->mol->showatoms[i]); chgl->mol->selectedatoms.last().style=i; } } if (!chgl->mol->selectedatoms.isEmpty()) { chgl->centerSelection->setChecked(true); chgl->updateBondActions(); chgl->update(); update(); chgl->update(); falschAtom=chgl->mol->selectedatoms.last().style; jumpToAtom(chgl->mol->selectedatoms.last().style); } } } }else{ xlPutor->setReadOnly(false); QString s=xlPutor->toPlainText(); if (shelxl->isOpen()) { s.append(shelxl->readAllStandardOutput()); s.append(shelxl->readAllStandardError()); } //qDebug()<<__LINE__<append("" + warn.replace("\n", "
") + "
"); } xlPutor->setPlainText(s); xlPutor->setReadOnly(true); if (!s.contains("WGHT")){ loadRes->setEnabled((s.contains("for all data"))); loadRes2->setEnabled((s.contains("for all data"))); refineButtonBox->show(); stoppRefinement->hide(); finishRefinement->hide(); finishRefinement2->hide(); refineButtonBox2->show(); stoppRefinement2->hide(); } if (!s.contains("Total elapsed")) { // SHELXL executed but didn't finish: resid_label->append("SHELXL was terminated!"); } } QTextCursor tc = xlPutor->textCursor(); tc.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); xlPutor->setTextCursor(tc); xlPutor->ensureCursorVisible(); update(); if (infotainmentDock->isVisible())finishRefinement2->setFocus(); else finishRefinement->setFocus(); } void Window::loadrefres(){ dirName.replace(punktins,".res"); shxOutputDock->hide(); infotainmentDock->hide(); refineButtonBox->hide(); refineButtonBox2->hide(); shxEditorDock->show(); shxEditorDock->raise(); loadFile(dirName); } void Window::replyFinished(QNetworkReply* antwort){ QSettings *einstellung =new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME,mole.mynewnameis ); int ignore=0; einstellung->beginGroup("Updates"); if (einstellung->contains("IgnoreUpdates")) ignore=einstellung->value("IgnoreUpdates").toInt(); einstellung->endGroup(); QString a=antwort->readAll(); latestRev=a; bool ok; int lat=a.toInt(&ok,10); if (ok&&lat&&(0==(ignore&QMessageBox::No))){ if ((lat-7)>Revision) { int later= QMessageBox::information( 0,"information",QString( "

This is revision: %1" "
The latest available version is revision: %2 " "New versions can be downloaded here: " "" "http://shelxle.org/shelx/index.php

" "

Please contact the author" " chuebsch@moliso.de if you find any bugs.
Thank you!

" "

Do you want to be reminded later?

").arg(Revision).arg(lat) ,QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); einstellung->beginGroup("Updates"); einstellung->setValue("IgnoreUpdates",later); einstellung->endGroup(); } }else{ latestRev=" network unavailable, check failed."; } antwort->close(); antwort->deleteLater(); disconnect(net,SIGNAL(finished(QNetworkReply*)),0,0); delete einstellung; } void Window::checkForUpdates(){ //disconnect(net,SIGNAL(finished(QNetworkReply*)),0,0); connect(net, SIGNAL(finished(QNetworkReply*)), this, SLOT(isUpToDate(QNetworkReply*))); reply = net->get(QNetworkRequest(QUrl("http://shelxle.org/shelx/revision.php"))); } void Window::isUpToDate(QNetworkReply* antwort){ QSettings *einstellung =new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME,mole.mynewnameis); //int ignore=0; einstellung->beginGroup("Updates"); if (einstellung->contains("IgnoreUpdates")) // ignore= einstellung->value("IgnoreUpdates").toInt(); einstellung->endGroup(); QString a=antwort->readAll(); latestRev=a; bool ok; int lat=a.toInt(&ok,10); if (ok&&lat){ int later= QMessageBox::information( 0,"information",QString( "

This is revision: %1" "
The latest available version is revision: %2 " "

%3

" "New versions can be downloaded here: " "" "http://shelxle.org/shelx/index.php" "

Please contact the author" " chuebsch@moliso.de if you find any bugs.
Thank you!

" "

Do you want to be reminded for new versions at startup?

").arg(Revision).arg(lat).arg(((lat-3)>Revision)?"You should probably update ShelXle.":"Your ShelXle is rather up to date.") ,QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); einstellung->beginGroup("Updates"); einstellung->setValue("IgnoreUpdates",later); einstellung->endGroup(); }else{ latestRev=" network unavailable, check failed."; QMessageBox::information( 0,"information",latestRev); } antwort->close(); antwort->deleteLater(); disconnect(net,SIGNAL(finished(QNetworkReply*)),0,0); } void Window::changeLabelFont(){ bool ok; QFont font = QFontDialog::getFont(&ok, chgl->myFont, this,"Change Label Font"); if (ok) { //font.setStyleStrategy(QFont::OpenGLCompatible); chgl->myFont=font; einstellung->beginGroup("Fonts"); einstellung->setValue("LabelFont",chgl->myFont); einstellung->setValue("LabelFontSize", chgl->myFont.pointSize()); einstellung->endGroup(); //chgl->updateLabelTextures(); chgl->update(); } } void Window::changeEditorFont(){ bool ok; QFont font = QFontDialog::getFont(&ok, editor->font(), this,"Change Editor Font"); if (ok) { font.setFixedPitch(true); einstellung->beginGroup("Fonts"); einstellung->setValue("EditorFont",font); einstellung->setValue("EditorFontSize",font.pointSize()); einstellung->endGroup(); editor->setFont(font); xlPutor->setFont(font); } } void Window::withdrawres(){ if (dirName.contains(punktres)){ QString insname =dirName; insname.replace(punktres,".ins"); QString fcfname = dirName; fcfname.replace(punktres,".fcf"); QString fcfname2 = dirName; fcfname2.replace(punktres,".2fcf"); QFile::remove(dirName); QFile::copy(insname,dirName); QFile::remove(fcfname); QFile::copy(fcfname2,fcfname); editor->document()->setModified(false); loadFile(dirName); } shxOutputDock->hide(); infotainmentDock->hide(); refineButtonBox->hide(); shxEditorDock->show(); if (falschAtom!=-1){ // qDebug()<<"tata"<mol->selectedatoms.clear(); chgl->mol->selectedatoms.append(chgl->mol->showatoms[falschAtom]); chgl->mol->selectedatoms.last().style=falschAtom; chgl->centerSelection->setChecked(true); chgl->updateBondActions(); chgl->update(); update(); chgl->update(); jumpToAtom(falschAtom); } } void Window::loadLst(){ xlPutor->clear(); pro7->hide(); QString listName=dirName; listName.replace(punktins,".lst"); listName.replace(punktres,".lst"); QFile lstf(listName); int wl=0; //xlPutor->highlighter->setDocument(0); if (lstf.open(QIODevice::ReadOnly|QIODevice::Text)){ QElapsedTimer stech; stech.start(); xlPutor->setReadOnly(false); xlPutor->ListFile=true; //xlPutor->highlighter->setDocument(0); // xlPutor->highlighter->setOutputStyle(); shxOutputDock->setWindowTitle(QString("LIST FILE: %1").arg(listName.section('/', -1))); // shxOutputDock->setWhatsThis("

.lst file viewer

The .lst file contains useful information about the refinement of your structure."); printf("1 %d ms\n", stech.elapsed()); QString testS=QString(lstf.readAll().replace('\0','~')); printf("2 %d ms\n", stech.elapsed()); xlPutor->setPlainText(testS); printf("3 %d ms\n", stech.elapsed()); wl=testS.count("\n"); lstf.close(); shxOutputDock->show(); shxOutputDock->lower(); einstellung->beginGroup("Cursor"); if (einstellung->contains("ListFilePos")){ xlPutor->setReadOnly(false); int mipo= qMin(wl,einstellung->value("ListFilePos",0).toInt()); // printf("mipo %d\n",mipo); QTextCursor c=xlPutor->textCursor(); // qDebug()<setTextCursor(c); xlPutor->centerCursor(); xlPutor->setReadOnly(true); printf("%s read and ready after %d ms\n",listName.toStdString().c_str(),stech.elapsed()); } einstellung->endGroup(); xlPutor->setReadOnly(true); // shxOutputDock->raise(); }else { shxOutputDock->lower(); shxOutputDock->hide(); } update(); } void Window::loadFile(QString fileName, bool fromloadref){ //! Loads the shelxfile, sets the last cursor position in editor, saves "last file" entry in config, //! checks if file is valid in terms of UNIT, HKLF and END instructions, loads list file, runs the editor. mole.vtriangles.clear(); mole.vorobas=0; //chgl->setLabelSize(24); QDir directory(fileName); QString dn=directory.canonicalPath(); if ((editor->toPlainText().length()>79)){//(dn!=dirName)&& QTextCursor c=editor->textCursor(); if (!c.isNull()){ myHash[dirName]=c.position(); einstellung->beginGroup("Cursor"); einstellung->setValue("lastCursorHash", myHash ); einstellung->setValue("ListFilePos",xlPutor->midCursorpos); einstellung->endGroup(); } } dirName=dn; if (dn!=lastDirName){// do this only is we have a different file name hklf5files.clear(); //QTime rzeit; //rzeit.start(); switch2HKLF5->setVisible(doWeHaveHKLF5here(hklf5files)); //printf("doWeHaveHKLF5here() took %d ms.\n", rzeit.elapsed()); // rzeit.restart(); } switch2HKLF4->setVisible(false); einstellung->beginGroup("Files"); einstellung->setValue("lastFile", dirName ); einstellung->endGroup(); fileName = dirName; lastDirName = dirName; if (fileName.isEmpty()) return; bool gut=false; QFile test; // alltest will contain the shelxfile that is displayed: QString alltest; test.setFileName(fileName); if (test.exists()&&test.size()){ test.open(QIODevice::ReadOnly|QIODevice::Text); alltest=test.readAll().replace('\0','~');// title can be empty. Fortran then has a string with many \0 this would leed to end of string in Rfactor REMARK section as the title is there gut = ((alltest.contains("UNIT",Qt::CaseInsensitive))&&(alltest.contains("HKLF",Qt::CaseInsensitive)||alltest.contains("END",Qt::CaseInsensitive))); test.close(); } if (!gut){ fileName.replace(QRegularExpression("res$",QRegularExpression::CaseInsensitiveOption),"ins"); test.setFileName(fileName); if (test.exists()&&test.size()){ test.open(QIODevice::ReadOnly|QIODevice::Text); alltest=test.readAll(); gut = ((alltest.contains("UNIT",Qt::CaseInsensitive))&&(alltest.contains("HKLF",Qt::CaseInsensitive)||alltest.contains("END",Qt::CaseInsensitive))); test.close(); if (gut ) dirName=fileName; } } if (!gut) { QMessageBox::information(this, "information", QString("Can't open %1").arg(fileName)); test.open(QIODevice::ReadOnly|QIODevice::Text); alltest=test.readAll(); test.close(); return; } packMenu->setEnabled(true); int qtmajor=(QT_VERSION&0xff0000)>>16; if ((Revision%666)==0) { setWindowTitle(QString("%1 - A Qt GUI for sHELLxl (Rev: %2): %3[*] ") .arg(PROGRAM_NAME) .arg(Revision) .arg(fileName.section("/",-1))); } else { setWindowTitle(QString("%1 - A Qt GUI for SHELXL (Rev: %2)(%4bit)(Qt%5): %3[*] ") .arg(PROGRAM_NAME) .arg(Revision) .arg(fileName.section("/",-1)) .arg(BitWidth) .arg(qtmajor) ); } notRefine = alltest.contains("DISABLE_REFINE");// this has to be here to work correctly if (alltest.contains("OVERRIDEF000")) { double str = alltest.section("OVERRIDEF000",1,-1).section('\n',0,0).simplified().toDouble(); fxle->overridef000=(float)str; //qDebug()<setDisabled(notRefine); packMenu->setDisabled(notRefine); refineToolBar->setDisabled(notRefine); refineToolBar->setVisible(!notRefine); alltest.replace(QRegularExpression("=\\s*[\\r\\n]+\\s{1,}"),"="); alltest.replace(QRegularExpression("REM[^\\n]*\n"),"\n"); alltest.replace(QRegularExpression("![^\\n]*\n"),"\n"); while (alltest.contains(QRegularExpression("[\\n^]\\++[^\\n]*\n"))) { QString incl=alltest.section(QRegularExpression("[\\n^]\\++"),1,1,QString::SectionSkipEmpty); incl=incl.section('\n',0,0); QString pre=dirName.section('/',0,-2); // qDebug()<beginGroup("Files"); einstellung->setValue("lastFile", fileName ); QStringList files = einstellung->value("recentFileList").toStringList(); files.removeAll(fileName); //alle identischen "fileName" aus der Liste entfernen files.prepend(fileName); // und dann vorne anfuegen... while (files.size() > MaxRecentFiles) { files.removeLast() ;//hinten abschneiden was laenger als MaxRecentFiles ist } einstellung->setValue("recentFileList", files); foreach (QWidget *widget, QApplication::topLevelWidgets()) { Window *mainWin = qobject_cast(widget); if (mainWin) mainWin->updateRecentFileActions(); } einstellung->endGroup(); } hw->setPath(fileName, dock->width()); if (hw->gooddata.size()) histDock->show(); //chgl->updateLabelTextures(); emit fileLoaded(); if ((chgl->toggleOrthoView->isChecked())&&(chgl->viewAngle>3.0)) { toggleOrtho(true); chgl->update(); // qDebug()<viewAngle; } chgl->update(); loadMolInTest(fromloadref); printf("loadFile\n"); } void Window::openRecentFile() { QAction *action = qobject_cast(sender()); if (action) loadFile(action->data().toString()); } void Window::setMaxWGHTCycls(){ bool ok; int i = QInputDialog::getInt(this, "limit", "number of maximum cycles in WGHT refinement" , wght_max_cycls, -1, 100000, 1, &ok); if (ok){ wght_max_cycls = i; wghtRefineAct->setText(QString("Try to refine until WGHT converges (max %1 runs)").arg(wght_max_cycls)); } } void Window::setSDMLimit(){ bool ok; int i = QInputDialog::getInt(this,"limit", "number of atoms in asymmetric unit to skip automatic distance calculation on loading" , chgl->SDM_Limit, 100, 10000, 1, &ok); if (ok) chgl->SDM_Limit=i; } void Window::closeEvent(QCloseEvent *event) { //printf("Close Event\n"); chgl->clearEnvi(); //printf("Close Event survived clearEnvi\n"); if (isFullScreen ())showNormal(); if (maybeSave()){ einstellung->beginGroup("Window"); einstellung->setValue("geometry", saveGeometry()); einstellung->setValue("state", saveState()); /* int kinder=0; const QObjectList smwk = shxMW->children(); for (int chi=0; chichildren().size(); } printf("editor dock has %d children\n",kinder); */ einstellung->setValue("EditorState",shxMW->saveState()); einstellung->setValue("InvertMouseZoom",(chgl->invertMouseZoom->isChecked())); einstellung->setValue("SDM-LIMIT", chgl->SDM_Limit); einstellung->setValue("Calculate-Maps",fxle->doMaps->isChecked()); einstellung->setValue("KeepMapIsoValues",fxle->keepIso->isChecked()); einstellung->setValue("Fo-Map",chgl->foact->isChecked()); einstellung->setValue("Fc-Fo-Map",chgl->fofcact->isChecked()); einstellung->setValue("Map-truncation-type",fxle->mapSchnitt->currentIndex()); einstellung->setValue("Map-Line-Transparency",chgl->lintrans); einstellung->setValue("Map-Line-Width", chgl->linwidth); einstellung->setValue("Map-Resolution",fxle->rr); einstellung->setValue("Map-Weight",fxle->rw); einstellung->setValue("Map-Lighting",chgl->lighting->isChecked()); einstellung->setValue("Nice-Transparency",chgl->niceTrans->isChecked()); einstellung->setValue("Solid-Map",chgl->fillMap->isChecked()); einstellung->setValue("HighlightEquivalents",mole.highlightEquivalents); einstellung->setValue("ADPs",chgl->adp->isChecked()); einstellung->setValue("Tubes",chgl->tubes->isChecked()); einstellung->setValue("Legend",chgl->atomLegend->isChecked()); einstellung->setValue("ShowLabels",togLabel->isChecked()); einstellung->setValue("ShortLabels",chgl->shortLabels->isChecked()); einstellung->setValue("BackGroundGradient",togBackGr->isChecked()); einstellung->setValue("SHELXL-PATH",shelxlPath); einstellung->setValue("LevelOfDetail",mole.LOD); //einstellung->setValue("Use_GLSL_Shaders",mole.useShaders); //einstellung->setValue("WireModelOnRotate",chgl->wireButt->isChecked()); einstellung->endGroup(); einstellung->beginGroup("Colors"); einstellung->setValue("LabelColor",chgl->labelColor); einstellung->setValue("BackGroundColor",chgl->backGroundColor); einstellung->endGroup(); einstellung->beginGroup("Files"); einstellung->setValue("lastFile", dirName ); einstellung->endGroup(); einstellung->beginGroup("Fonts"); printf("Storing Font to Settings %s %d\n", editor->font().family().toStdString().c_str(), editor->font().pointSize()); einstellung->setValue("EditorFont", editor->font()); einstellung->setValue("EditorFontSize", editor->font().pointSize()); einstellung->setValue("LabelFont",chgl->myFont); einstellung->setValue("LabelFontSize", chgl->myFont.pointSize()); einstellung->endGroup(); einstellung->beginGroup("ToolBarIcons"); einstellung->setValue("ToolBarIconSize",tbiconSize); einstellung->endGroup(); QTextCursor c=editor->textCursor(); if (!c.isNull()){ myHash[dirName]=c.position(); einstellung->beginGroup("Cursor"); einstellung->setValue("lastCursorHash", myHash ); einstellung->endGroup(); } //printf("Close Event survived Einstellungen.\n"); delete einstellung; //printf("deleting\n"); // printf("%d\n",__LINE__); editor->clear(); mole.asymm.clear(); // printf("%d\n",__LINE__); mole.sdm.clear(); // printf("%d\n",__LINE__); mole.showatoms.clear(); // printf("%d\n",__LINE__); mole.showbonds.clear(); // printf("%d\n",__LINE__); mole.cell.symmops.clear(); // printf("%d\n",__LINE__); mole.cell.trans.clear(); // printf("%d\n",__LINE__); mole.selectedatoms.clear(); // printf("%d\n",__LINE__); editor->sfac.clear(); editor->sfacsmbl.clear(); // printf("%d\n",__LINE__); fvar.clear(); // printf("%d\n",__LINE__); fvarCntr.clear(); // printf("%d\n",__LINE__); mole.transEQIV.clear(); // printf("%d\n",__LINE__); mole.symmopsEQIV.clear(); // printf("%d\n",__LINE__); mole.labelEQIV.clear(); // printf("%d\n",__LINE__); mole.freeatoms.clear(); // printf("%d\n",__LINE__); mole.bindatoms.clear(); // printf("%d\n",__LINE__); // disconnect(this); // printf("%d\n",__LINE__); // disconnect(editor); // printf("%d %p\n", __LINE__, chgl); // disconnect(chgl); // printf("%d\n",__LINE__); mole.asymm.clear(); // printf("%d\n",__LINE__); mole.sdm.clear(); // printf("%d\n",__LINE__); mole.showbonds.clear(); // printf("%d\n",__LINE__); mole.showatoms.clear(); // printf("%d\n",__LINE__); mole.selectedatoms.clear(); // printf("%d\n",__LINE__); mole.envi_sdm.clear(); // printf("%d\n",__LINE__); mole.contact.clear(); // printf("%d\n",__LINE__); mole.symmopsEQIV.clear(); // printf("%d\n",__LINE__); mole.labelEQIV.clear(); // printf("%d\n",__LINE__); mole.transEQIV.clear(); // printf("%d\n",__LINE__); mole.freeatoms.clear(); // printf("%d\n",__LINE__); mole.bindatoms.clear(); // printf("%d\n",__LINE__); for (int i=0; iaccept(); } else{ event->ignore(); // printf("Close Event survived and Ignored\n"); } } void Window::changeScalefactor(){ widthBox->disconnect(); heightBox->disconnect(); scalefBox->disconnect(); widthBox->setValue(int(chgl->width()*scalePic+0.5)); heightBox->setValue(int(chgl->height()*scalePic+0.5)); scalefBox->setValue(scalePic*100.0); connect(widthBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); connect(heightBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); connect(scalefBox,SIGNAL(valueChanged(double)),this,SLOT(updateScaleDlg())); scalDlg->exec(); } void Window::updateScaleDlg(){ QObject *o = qobject_cast(sender()); if (o) { QString name = o->objectName(); widthBox->disconnect(); heightBox->disconnect(); scalefBox->disconnect(); if (name=="scalefBox"){ scalePic=scalefBox->value()*0.01; widthBox->setValue(int(chgl->width()*scalePic+0.5)); heightBox->setValue(int(chgl->height()*scalePic+0.5)); } else if (name=="widthBox"){ scalePic= (double (widthBox->value() -0.5) / chgl->width()) ; heightBox->setValue(int(chgl->height()*scalePic+0.5)); scalefBox->setValue(scalePic*100.0); } else if (name=="heightBox"){ scalePic= (double (heightBox->value() -0.5) / chgl->height()) ; widthBox->setValue(int(chgl->width()*scalePic+0.5)); scalefBox->setValue(scalePic*100.0); } scalDlg->update(); connect(widthBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); connect(heightBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); connect(scalefBox,SIGNAL(valueChanged(double)),this,SLOT(updateScaleDlg())); } } void Window::updateSelectResi(){ QStringList l = editor->document()->toPlainText().split('\n'); if (editor->resiFinder == NULL) return; editor->resiFinder->clear(); editor->resiFinder->addItem("