| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick |
| 4 |
** All rights reserved. |
| 5 |
** Contact: [email protected] |
| 6 |
** |
| 7 |
** This file is part of the ShelXle |
| 8 |
** |
| 9 |
** This file may be used under the terms of the GNU Lesser |
| 10 |
** General Public License version 2.1 as published by the Free Software |
| 11 |
** Foundation and appearing in the file COPYING included in the |
| 12 |
** packaging of this file. Please review the following information to |
| 13 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
| 14 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 15 |
** |
| 16 |
** |
| 17 |
****************************************************************************/ |
| 18 |
//äöüß needed to keep this file UTF8 QString::fromUtf8("»") |
| 19 |
int Revision=1551; |
| 20 |
#include "window.h" |
| 21 |
#include "scatt.h" |
| 22 |
#include "includeeditor.h" |
| 23 |
#include "exportccdlg.h" |
| 24 |
#include "deprecation.h" |
| 25 |
#include "partcolor.h" |
| 26 |
#include "highlighter.h" |
| 27 |
#include "eacDlg.h" |
| 28 |
//#include "dragdropatomsdlg.h" |
| 29 |
#include "savehistorywidget.h" |
| 30 |
#include "fcvsfo.h" |
| 31 |
#include "rename_selected.h" |
| 32 |
|
| 33 |
//QString datum=QString(__TIME__ " " __DATE__); |
| 34 |
#ifdef __x86_64__ |
| 35 |
const int BitWidth=64; |
| 36 |
#else |
| 37 |
#ifdef _WIN64 |
| 38 |
const int BitWidth=64; |
| 39 |
#else |
| 40 |
const int BitWidth=32;// "<p>This is a 32 bit Version.</p> " |
| 41 |
#endif |
| 42 |
#endif |
| 43 |
const QFileDialog::Options noneopt = QFileDialog::Options(); |
| 44 |
QString latestRev="no network available, or you disabled checking"; |
| 45 |
QString lstpatternfile=":lst_and_output_style.ini"; |
| 46 |
QString inspatternfile=":ins_res_style.ini"; |
| 47 |
QString lstpatternfile_dark=":lst_and_output_style_dark.ini"; |
| 48 |
QString inspatternfile_dark=":ins_res_style_dark.ini"; |
| 49 |
|
| 50 |
void Window::dragEnterEvent(QDragEnterEvent *event) { |
| 51 |
if (event->mimeData()->hasFormat("text/uri-list")) |
| 52 |
event->acceptProposedAction(); |
| 53 |
} |
| 54 |
|
| 55 |
void Window::toggleFullScreen(){ |
| 56 |
if (QString(PROGRAM_NAME).compare("shelXle")) return; |
| 57 |
fullscreen=!fullscreen; |
| 58 |
if (fullscreen) { |
| 59 |
showFullScreen(); |
| 60 |
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.+++"); |
| 61 |
} |
| 62 |
else showNormal(); |
| 63 |
} |
| 64 |
|
| 65 |
void Window::dropEvent(QDropEvent *event) { |
| 66 |
QList<QUrl> drops = event->mimeData()->urls(); |
| 67 |
QString path=drops.first().path(); |
| 68 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 69 |
path.remove(QRegularExpression("^/")); |
| 70 |
#endif |
| 71 |
if ((path.endsWith(".res",Qt::CaseInsensitive))||(path.endsWith(".ins",Qt::CaseInsensitive))){ |
| 72 |
loadFile(path); |
| 73 |
event->acceptProposedAction(); |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
void Window::qinitres() { |
| 78 |
if (!QString(PROGRAM_NAME).compare("shelXle")){ |
| 79 |
printf("init resorce: %s\n",PROGRAM_NAME); |
| 80 |
Q_INIT_RESOURCE(icons); |
| 81 |
}else{ |
| 82 |
printf("init resorce: %s\n",PROGRAM_NAME); |
| 83 |
Q_INIT_RESOURCE(bicons); |
| 84 |
Q_INIT_RESOURCE(shaders); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
Window::Window(PlayOpenGL *_chgl){ |
| 89 |
/*! \brief the constructor of the main window rather lengthy but most widgets are created and placed here. |
| 90 |
* |
| 91 |
*/ |
| 92 |
fullscreen=false; |
| 93 |
setObjectName("The Main Window"); |
| 94 |
oldFileName=popel=QString(""); |
| 95 |
extraIndex = -1; |
| 96 |
wght_max_cycls = 10; |
| 97 |
calcmenu=nullptr; |
| 98 |
printf("QT_VERSION %x \n",QT_VERSION); |
| 99 |
setAcceptDrops(true); |
| 100 |
mole.mynewnameis=QString(PROGRAM_NAME); |
| 101 |
if (!QString(PROGRAM_NAME).compare("shelXle")){ |
| 102 |
theIconPath=QString(":/xle-icons/"); |
| 103 |
}else{ |
| 104 |
theIconPath=QString(":/bicons/"); |
| 105 |
} |
| 106 |
int qtmajor=(QT_VERSION&0xff0000)>>16; |
| 107 |
if (PROGRAM_NAME[0]=='s') { |
| 108 |
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 |
| 109 |
//incompatible in windows state |
| 110 |
QSettings *testset = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, mole.mynewnameis ); |
| 111 |
QSettings *oldset = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, PROGRAM_NAME); |
| 112 |
if ((!QFile::exists(testset->fileName()))&&(QFile::exists(oldset->fileName()))){ |
| 113 |
QFile::copy(oldset->fileName(),testset->fileName()); |
| 114 |
} |
| 115 |
testset->deleteLater(); |
| 116 |
oldset->deleteLater(); |
| 117 |
} |
| 118 |
einstellung = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, mole.mynewnameis ); |
| 119 |
//QFontDatabase::addApplicationFont(":/xle-icons/droid-sans-mono.ttf"); |
| 120 |
falschAtom=-1; |
| 121 |
CurrentCellString=QString(); |
| 122 |
MaxNumberOfPeaks=100; |
| 123 |
altExtraIconPath=""; |
| 124 |
calcmenu=NULL;//if not needed it will be not created. |
| 125 |
dsr=NULL; |
| 126 |
qsaPNG=nullptr; |
| 127 |
nowaste=true; |
| 128 |
focusSet=true; |
| 129 |
doNotAnnoyMe=false; |
| 130 |
#if (QT_VERSION >=0x050000) |
| 131 |
screen = QGuiApplication::screens().at(0); |
| 132 |
hhh = screen->availableGeometry().height(); |
| 133 |
#else |
| 134 |
hhh = qApp->desktop()->availableGeometry(-1).height(); |
| 135 |
#endif |
| 136 |
printf("available height %d\n",hhh); |
| 137 |
shxPath=shxOptions=NULL; |
| 138 |
machPlatz=false; |
| 139 |
char *ENUS=setlocale(LC_ALL,"C"); |
| 140 |
if (!ENUS)ENUS=setlocale(LC_ALL,"en_US.UTF-8"); |
| 141 |
//printf("%s\n",ENUS); |
| 142 |
FFTErrorString=""; |
| 143 |
range=3.0; |
| 144 |
mode=0; |
| 145 |
weight=1.0; |
| 146 |
//scroller=false; |
| 147 |
setDockNestingEnabled(true); |
| 148 |
otherOpenFiles=false; |
| 149 |
QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Bold.ttf"); |
| 150 |
QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Italic.ttf"); |
| 151 |
int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); |
| 152 |
QString family = QFontDatabase::applicationFontFamilies(id).at(0); |
| 153 |
QFont font(family); |
| 154 |
|
| 155 |
{//initialize Edidor |
| 156 |
navibox = new QGroupBox(this); |
| 157 |
nlt = new QHBoxLayout(navibox); |
| 158 |
//nlt->setMargin(0); |
| 159 |
selectPart = new QCheckBox("Select Part",navibox); |
| 160 |
selectPart->setChecked(false); |
| 161 |
spinSelectPart = new QSpinBox(navibox); |
| 162 |
spinSelectPart->setMinimum(1); |
| 163 |
spinSelectPart->setMaximum(2); |
| 164 |
spinSelectPart->setVisible(false); |
| 165 |
inculdePartNull = new QCheckBox("incl. Pt. 0",navibox); |
| 166 |
inculdePartNull->setToolTip("Include part 0 in selection"); |
| 167 |
inculdePartNull->setChecked(true); |
| 168 |
inculdePartNull->setVisible(false); |
| 169 |
QToolButton *nothing=new QToolButton(navibox); |
| 170 |
nothing->setIcon(QIcon(theIconPath+"nospell.svg")); |
| 171 |
nothing->setText("no errors"); |
| 172 |
nothing->setIconSize(QSize(22,22)); |
| 173 |
nothing->setToolButtonStyle(Qt::ToolButtonIconOnly); |
| 174 |
spellCheckact = new QToolButton(navibox); |
| 175 |
spellCheckact->setIcon(QIcon(theIconPath+"spell.svg")); |
| 176 |
spellCheckact->setText("Jump to error"); |
| 177 |
spellCheckact->setIconSize(QSize(22,22)); |
| 178 |
spellCheckact->setToolTip("Jump to first error in file."); |
| 179 |
spellCheckact->setToolButtonStyle(Qt::ToolButtonIconOnly); |
| 180 |
lineColumn = new QLabel("",navibox); |
| 181 |
nlt->addWidget(selectPart); |
| 182 |
nlt->addWidget(spinSelectPart); |
| 183 |
nlt->addWidget(inculdePartNull); |
| 184 |
connect(selectPart,SIGNAL(toggled(bool)),spinSelectPart,SLOT(setVisible(bool))); |
| 185 |
connect(selectPart,SIGNAL(toggled(bool)),inculdePartNull,SLOT(setVisible(bool))); |
| 186 |
connect(selectPart,SIGNAL(stateChanged(int)),this,SLOT(selectParts())); |
| 187 |
connect(inculdePartNull,SIGNAL(toggled(bool)),this,SLOT(selectParts())); |
| 188 |
connect(spinSelectPart,SIGNAL(valueChanged(int)),this,SLOT(selectParts())); |
| 189 |
nlt->addStretch(10); |
| 190 |
nlt->addWidget(lineColumn); |
| 191 |
navibox->setLayout(nlt); |
| 192 |
editor = new CodeEditor(this); |
| 193 |
editor->setObjectName("ShelXleEditor"); |
| 194 |
QApplication::setCursorFlashTime(700); |
| 195 |
editor->setCursorWidth(2); |
| 196 |
nlt->addWidget(editor->resiFinder); |
| 197 |
nlt->addWidget(spellCheckact); |
| 198 |
nlt->addWidget(nothing); |
| 199 |
connect(spellCheckact,SIGNAL(clicked()),editor,SLOT(jumpToError())); |
| 200 |
completer = new QCompleter(this); |
| 201 |
{ |
| 202 |
QStringList keywords; |
| 203 |
keywords << "ACTA"<<"AFIX"<<"ANIS"<<"BASF"<<"BIND"<<"BLOC"<<"BOND"<< |
| 204 |
"BUMP"<<"CELL"<<"CGLS"<<"CHIV"<<"CONF"<<"CONN"<<"DAMP"<<"DANG"<< |
| 205 |
"DEFS"<<"DELU"<<"DFIX"<<"DISP"<<"EADP"<<"END "<<"EQIV"<< |
| 206 |
"EXTI"<<"EXYZ"<<"FEND"<<"FLAT"<<"FMAP"<<"FRAG"<<"FREE"<< |
| 207 |
"FVAR"<<"GRID"<<"HFIX"<<"HKLF"<<"HOPE"<<"HTAB"<<"ISOR"<< |
| 208 |
"LATT"<<"LAUE"<<"LIST"<<"L.S."<<"MERG"<<"MOLE"<< |
| 209 |
"MORE"<<"MOVE"<<"MPLA"<<"NCSY"<<"OMIT"<<"PART"<<"PLAN"<< |
| 210 |
"REM "<<"RESI"<<"RTAB"<<"SADI"<<"SAME"<<"SFAC"<<"SHEL"<< |
| 211 |
"SIMU"<<"SIZE"<<"SPEC"<<"STIR"<<"SUMP"<<"SWAT"<<"SYMM"<< |
| 212 |
"TEMP"<<"TIME"<<"TITL"<<"TWIN"<<"UNIT"<<"VECT"<< |
| 213 |
"WPDB"<<"WGHT"<<"ZERR"<< |
| 214 |
// New Shelxl commands! |
| 215 |
"XNPD"<<//83 |
| 216 |
"REST"<<//84 |
| 217 |
"CHAN"<<//85 |
| 218 |
"RIGU"<<//86 |
| 219 |
"FLAP"<<//87 |
| 220 |
"RNUM"<<//88 |
| 221 |
"SOCC"<<//89 |
| 222 |
"PRIG"<<//90 |
| 223 |
"WIGL"<<//91 |
| 224 |
"RANG"<<//92 |
| 225 |
"TANG"<<//93 |
| 226 |
"ADDA"<<//94 |
| 227 |
"STAG"<<//;//95 |
| 228 |
"ABIN"<<//96 |
| 229 |
"ANSC"<<//97 |
| 230 |
"ANSR"<<//98 |
| 231 |
"NOTR"<<//99 |
| 232 |
"NEUT"<<//100 |
| 233 |
"TWST";//<<101 |
| 234 |
keywords.sort(); |
| 235 |
|
| 236 |
completer->setModel(new QStringListModel(keywords, completer)); |
| 237 |
} |
| 238 |
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); |
| 239 |
completer->setCaseSensitivity(Qt::CaseInsensitive); |
| 240 |
completer->setWrapAround(false); |
| 241 |
editor->setCompleter(completer); |
| 242 |
shxEditorDock = new QDockWidget("SHELXL Editor",this,Qt::Widget);//Qt::Window//Qt::Tool |
| 243 |
shxEditorDock->setObjectName("Editor"); |
| 244 |
shxEditorDock->setFeatures( |
| 245 |
QDockWidget::DockWidgetMovable| |
| 246 |
QDockWidget::DockWidgetFloatable| |
| 247 |
QDockWidget::DockWidgetClosable); |
| 248 |
connect(shxEditorDock,SIGNAL(visibilityChanged(bool)),this,SLOT(editorIsVisible(bool))); |
| 249 |
shxMW = new QMainWindow(this); |
| 250 |
shx_group = new QWidget(this); |
| 251 |
shxMW->setCentralWidget(shx_group); |
| 252 |
shx_group->setContentsMargins(0,0,0,0); |
| 253 |
sss = new QVBoxLayout(shx_group); |
| 254 |
sss->addWidget(navibox); |
| 255 |
sss->addWidget(editor); |
| 256 |
sss->addWidget(editor->suchbox); |
| 257 |
shx_group->setLayout(sss); |
| 258 |
shxEditorDock->setWidget(shxMW); |
| 259 |
connect(shxEditorDock,SIGNAL(visibilityChanged(bool)),this,SLOT(shxActUpdate(bool))); |
| 260 |
editor->setFont(font); |
| 261 |
editor->setLineWrapMode(QPlainTextEdit::NoWrap); |
| 262 |
addDockWidget(Qt::RightDockWidgetArea, shxEditorDock ); |
| 263 |
} |
| 264 |
{//init shelx output viewer |
| 265 |
xlPutor = new CodeEditor(); |
| 266 |
xlPutor->setObjectName("shelx output viewer"); |
| 267 |
xlPutor->setReadOnly(true); |
| 268 |
xlPutor->setFont(font); |
| 269 |
xlPutor->setLineWrapMode(QPlainTextEdit::NoWrap); |
| 270 |
shxOutputDock = new QDockWidget("SHELXL output",this,Qt::Widget); |
| 271 |
shxOutputDock->setObjectName("Output"); |
| 272 |
shxOutputDock->setFeatures( |
| 273 |
QDockWidget::DockWidgetMovable| |
| 274 |
QDockWidget::DockWidgetFloatable| |
| 275 |
QDockWidget::DockWidgetClosable); |
| 276 |
shxOutputDock->hide(); |
| 277 |
connect(shxOutputDock,SIGNAL(visibilityChanged(bool)),this,SLOT(outputIsVisible(bool))); |
| 278 |
buttomLt = new QHBoxLayout(); |
| 279 |
loadRes = new QPushButton(QIcon(theIconPath+"open.svg"), "Load refinement results", this); |
| 280 |
withdraw = new QPushButton(QIcon(theIconPath+"cancel.svg"), "Discard results", this); |
| 281 |
showLst = new QPushButton("Show output listing file",this); |
| 282 |
connect(loadRes,SIGNAL(pressed()),this,SLOT(loadrefres())); |
| 283 |
connect(withdraw,SIGNAL(pressed()),this,SLOT(withdrawres())); |
| 284 |
connect(showLst,SIGNAL(pressed()),this,SLOT(loadLst())); |
| 285 |
pro7 = new QPushButton("Visualize output"); |
| 286 |
connect(pro7,SIGNAL(pressed()),this,SLOT(raiseTaff())); |
| 287 |
connect(pro7,SIGNAL(pressed()),this,SLOT(displayDisagreeableRestraints())); |
| 288 |
buttomLt->addWidget(loadRes); |
| 289 |
buttomLt->addWidget(withdraw); |
| 290 |
buttomLt->addStretch(10); |
| 291 |
buttomLt->addWidget(showLst); |
| 292 |
stoppRefinement = new QPushButton(QIcon(theIconPath+"cancel.svg"),"STOP refinement!",this); |
| 293 |
stoppRefinement->hide(); |
| 294 |
finishRefinement = new QPushButton(QIcon(theIconPath+"cancel.svg"),"Finish Gracefully.",this); |
| 295 |
finishRefinement->hide(); |
| 296 |
refineButtonBox = new QGroupBox(); |
| 297 |
refineButtonBox->setLayout(buttomLt); |
| 298 |
|
| 299 |
vlt = new QVBoxLayout(); |
| 300 |
vlt->addWidget(xlPutor); |
| 301 |
vlt->addWidget(xlPutor->suchbox); |
| 302 |
vlt->addWidget(refineButtonBox); |
| 303 |
vlt->addWidget(stoppRefinement); |
| 304 |
vlt->addWidget(finishRefinement); |
| 305 |
|
| 306 |
vlt->addWidget(pro7); |
| 307 |
refineButtonBox->hide(); |
| 308 |
pro7->hide(); |
| 309 |
gp = new QGroupBox(""); |
| 310 |
gp->setFlat(true); |
| 311 |
gp->setLayout(vlt); |
| 312 |
shxOutputDock->setWidget(gp); |
| 313 |
addDockWidget(Qt::RightDockWidgetArea, shxOutputDock); |
| 314 |
tabifyDockWidget (shxEditorDock,shxOutputDock); |
| 315 |
|
| 316 |
connect(shxOutputDock,SIGNAL(visibilityChanged(bool)),this,SLOT(shxOPTUpdate(bool))); |
| 317 |
} |
| 318 |
{//infotainment widget |
| 319 |
vis_settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, PROGRAM_NAME, mole.mynewnameis); |
| 320 |
vis_settings->beginGroup("infotaiment"); |
| 321 |
if (!vis_settings->contains("info_as_default")) { |
| 322 |
vis_settings->setValue("info_as_default", false); |
| 323 |
} |
| 324 |
vis_settings->endGroup(); |
| 325 |
infotainmentDock = new QDockWidget("Visual Refinement output",this,Qt::Widget); |
| 326 |
infotainmentDock->setObjectName("Painment"); |
| 327 |
infotainmentDock->setFeatures( |
| 328 |
QDockWidget::DockWidgetMovable| |
| 329 |
QDockWidget::DockWidgetFloatable| |
| 330 |
QDockWidget::DockWidgetClosable); |
| 331 |
infotainmentDock->hide(); |
| 332 |
resid_label = new QTextEdit(); // shows residuals from refinement output |
| 333 |
resid_label->setAlignment(Qt::AlignTop); |
| 334 |
resid_label->setStyleSheet("QLabel { background-color : white; border: 1px solid lightgray;}"); |
| 335 |
resid_label->setWordWrapMode(QTextOption::NoWrap); // prevents word wrap in the table |
| 336 |
restr_table = new QTextEdit(); |
| 337 |
restr_table->setAlignment(Qt::AlignBottom); |
| 338 |
restr_table->setReadOnly(true); |
| 339 |
resid_label->setReadOnly(true); |
| 340 |
resid_layout = new QVBoxLayout(); |
| 341 |
resid_layout->addWidget(resid_label, 4); // residuals |
| 342 |
resid_layout->addWidget(restr_table, 2); // list of most disagreeable restraints |
| 343 |
refineButtonBox2 = new QGroupBox(); |
| 344 |
loadRes2 = new QPushButton(QIcon(theIconPath+"open.svg"),"Load refinement results",this); |
| 345 |
withdraw2 = new QPushButton(QIcon(theIconPath+"cancel.svg"),"Discard results",this); |
| 346 |
connect(loadRes2,SIGNAL(pressed()),this,SLOT(loadrefres())); |
| 347 |
connect(withdraw2,SIGNAL(pressed()),this,SLOT(withdrawres())); |
| 348 |
QHBoxLayout *buttomLt2 = new QHBoxLayout(); |
| 349 |
buttomLt2->addWidget(loadRes2); |
| 350 |
buttomLt2->addWidget(withdraw2); |
| 351 |
QPushButton *arte= new QPushButton("show text output"); |
| 352 |
connect(arte,SIGNAL(pressed()),this,SLOT(raiseTaz())); |
| 353 |
refineButtonBox2->setLayout(buttomLt2); |
| 354 |
stoppRefinement2 = new QPushButton(QIcon(theIconPath+"cancel.svg"),"STOP refinement!",this); |
| 355 |
stoppRefinement2->hide(); |
| 356 |
finishRefinement2 = new QPushButton(QIcon(theIconPath+"cancel.svg"),"Finish Gracefully",this); |
| 357 |
finishRefinement2->hide(); |
| 358 |
resid_layout->addWidget(refineButtonBox2, 1); |
| 359 |
resid_layout->addWidget(stoppRefinement2, 1); |
| 360 |
resid_layout->addWidget(finishRefinement2, 1); |
| 361 |
resid_layout->addWidget(arte); |
| 362 |
refineButtonBox2->hide(); |
| 363 |
restr_table->setMinimumSize(150, 50); |
| 364 |
|
| 365 |
restr_table->setToolTip("The error of a parameter should generally not be higher than 3sigma. A higher\n" |
| 366 |
"value means that the assumption of the target value is not met. \n" |
| 367 |
"The reason for this can be either, for example, a distorted molecular geometry \n" |
| 368 |
"or systematic errors in the data.\n" |
| 369 |
"\n" |
| 370 |
"Disagreeable restraints will be highlighted in yellow if the error is above \n" |
| 371 |
"2.5sigma. They will be highlighted in red if the error is above 3.5sigma.\n"); |
| 372 |
|
| 373 |
resid_gb = new QGroupBox(""); |
| 374 |
resid_gb->setFlat(true); |
| 375 |
resid_gb->setLayout(resid_layout); |
| 376 |
infotainmentDock->setWidget(resid_gb); |
| 377 |
addDockWidget(Qt::RightDockWidgetArea, infotainmentDock); |
| 378 |
tabifyDockWidget (shxEditorDock,infotainmentDock); |
| 379 |
} |
| 380 |
|
| 381 |
dock = new QDockWidget("Information Window",this); |
| 382 |
dock->setObjectName("Info"); |
| 383 |
dock->setAllowedAreas(Qt::AllDockWidgetAreas); |
| 384 |
infoKanal = new QTextBrowser(dock); |
| 385 |
infoKanal->setLineWrapMode(QTextEdit::NoWrap); |
| 386 |
dock->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetClosable); |
| 387 |
dock->setWidget(infoKanal); |
| 388 |
dock->hide(); |
| 389 |
addDockWidget(Qt::RightDockWidgetArea, dock); |
| 390 |
// resize(qApp->desktop()->screenGeometry().width(),qApp->desktop()->screenGeometry().height()); |
| 391 |
|
| 392 |
//rename dock |
| 393 |
renamDock = new QDockWidget("Rename Mode"); |
| 394 |
renamDock->setObjectName("Rename"); |
| 395 |
enterRenameMode = renamDock->toggleViewAction (); |
| 396 |
enterRenameMode->setShortcut(Qt::ALT|Qt::Key_R); |
| 397 |
QShortcut *altplus = new QShortcut(Qt::CTRL|Qt::ALT|Qt::Key_Plus,renamDock); |
| 398 |
connect(altplus, SIGNAL(activated()),this, SLOT(incResiNr())); |
| 399 |
QShortcut *altminus = new QShortcut(Qt::CTRL|Qt::ALT|Qt::Key_Minus,renamDock); |
| 400 |
connect(altminus, SIGNAL(activated()),this, SLOT(decResiNr())); |
| 401 |
connect(enterRenameMode,SIGNAL(triggered(bool)),this,SLOT(renamUpdate(bool))); |
| 402 |
//connect(enterRenameMode,SIGNAL(triggered(bool)),enterRenameMode,SLOT(setVisible(bool))); |
| 403 |
renamDock->setFeatures( |
| 404 |
QDockWidget::DockWidgetMovable| |
| 405 |
QDockWidget::DockWidgetFloatable| |
| 406 |
QDockWidget::DockWidgetClosable); |
| 407 |
|
| 408 |
renameBox = new QGroupBox(); |
| 409 |
rnla = new QVBoxLayout(); |
| 410 |
rnla->setObjectName("Rename Layout"); |
| 411 |
nliL = new QLabel("You are in 'rename mode' now."); |
| 412 |
nliL->setFont(QFont("Helvetica",18,QFont::Bold)); |
| 413 |
spellCheckact2 = new QToolButton(renameBox); |
| 414 |
spellCheckact2->setIcon(QIcon(theIconPath+"spell.svg")); |
| 415 |
spellCheckact2->setText("Oops! I made a mistake! Sorry! Please check!"); |
| 416 |
spellCheckact2->setIconSize(QSize(22,22)); |
| 417 |
spellCheckact2->setToolTip("Jump to first error in file."); |
| 418 |
spellCheckact2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
| 419 |
connect(spellCheckact2,SIGNAL(clicked()),shxEditorDock,SLOT(raise())); |
| 420 |
connect(spellCheckact2,SIGNAL(clicked()),renamDock,SLOT(hide())); |
| 421 |
connect(spellCheckact2,SIGNAL(clicked()),editor,SLOT(jumpToError())); |
| 422 |
rnla->addWidget(spellCheckact2); |
| 423 |
rnla->addWidget(nliL); |
| 424 |
hintL = new QLabel("<div style=color:#0000aa; style=white-space:normal; style=background-color:" |
| 425 |
"#f8f5cd; style=font-size:large;><b><u>Hint:</u></b><a name=\"test\"><img width=\"23\" src=\"" |
| 426 |
+theIconPath+"filesave.svg\"></a> It is wise to save often. Especially after renaming a couple of Q-Peaks. " |
| 427 |
"<br>Saving synchronizes the visualized structure and the editor content.<br> <b>Before</b> you start renaming and <b>after</b> " |
| 428 |
"you are finished renaming you should <b>SAVE!</b> <a href=\"#test\" style=text-align:right;>Click here to hide this hint for ever.</a></div>"); |
| 429 |
hintL->setWordWrap(true); |
| 430 |
rnla->addWidget(hintL); |
| 431 |
hintL->setOpenExternalLinks(true); |
| 432 |
connect(hintL,SIGNAL(linkActivated(const QString &)), this ,SLOT(hintLhide())); |
| 433 |
rufModeBox = new QCheckBox("Automatically jump to first unused label"); |
| 434 |
rufModeBox->setChecked(false); |
| 435 |
connect(rufModeBox,SIGNAL(stateChanged(int)),this,SLOT(rufmode())); |
| 436 |
partSpinL = new QLabel("Part:"); |
| 437 |
partSpin = new QSpinBox(); |
| 438 |
partSpin->setMinimum(-99); |
| 439 |
partSpin->setMaximum(99); |
| 440 |
partSpin->setValue(0); |
| 441 |
connect(partSpin,SIGNAL(valueChanged(int)),this,SLOT(updateLabel())); |
| 442 |
resiNrSpinL = new QLabel("Residue Nr:"); |
| 443 |
resiNrSpin = new QSpinBox(); |
| 444 |
resiNrSpin->setMinimum(0); |
| 445 |
resiNrSpin->setMaximum(9999); |
| 446 |
resiNrSpin->setValue(0); |
| 447 |
connect(resiNrSpin,SIGNAL(valueChanged(int)),this,SLOT(renameRNchanged(int))); |
| 448 |
resiResiClassL = new QLabel("Residue Class:"); |
| 449 |
resiResiClass = new QLineEdit(""); |
| 450 |
resiResiClass->setMaxLength(4); |
| 451 |
resiResiClass->setValidator(new QRegularExpressionValidator(QRegularExpression("^[A-Za-z]\\w{0,3}"),resiResiClass)); |
| 452 |
resiResiClass->setMinimumWidth(100); |
| 453 |
connect(resiResiClass,SIGNAL(textEdited(const QString&)),this,SLOT(grossRC(const QString&))); |
| 454 |
resiResiClass->setEnabled(false); |
| 455 |
resiResiClassCB = new QComboBox(this); |
| 456 |
resiResiClassCB->setLineEdit(resiResiClass); |
| 457 |
resiResiClassCB->setEditable(true); |
| 458 |
resiResiClassCB->setMinimumWidth(150); |
| 459 |
rhla = new QHBoxLayout(); |
| 460 |
rhla->addWidget(partSpinL); |
| 461 |
rhla->addWidget(partSpin); |
| 462 |
rhla->addWidget(resiNrSpinL); |
| 463 |
rhla->addWidget(resiNrSpin); |
| 464 |
rhla->addWidget(resiResiClassL); |
| 465 |
rhla->addWidget(resiResiClassCB); |
| 466 |
rnla->addLayout(rhla); |
| 467 |
rhla2 = new QHBoxLayout(); |
| 468 |
tieOccL = new QLabel("Tie occupancy to: "); |
| 469 |
tieOccL->setAlignment(Qt::AlignRight|Qt::AlignVCenter); |
| 470 |
tieType = new QComboBox(); |
| 471 |
tieType->addItem("its fixed value",0); |
| 472 |
tieType->addItem("fv(n)",1); |
| 473 |
tieType->addItem("1-fv(n)",-1); |
| 474 |
tieFVNrL = new QLabel("n = "); |
| 475 |
tieFVNrL->setAlignment(Qt::AlignRight|Qt::AlignVCenter); |
| 476 |
tieFVNr = new QSpinBox(); |
| 477 |
tieFVNr->setMinimum(1); |
| 478 |
tieFVNr->setMaximum(9999); |
| 479 |
tieFVNr->setValue(2); |
| 480 |
tieUsedL = new QLabel("fv(2) is 0x used"); |
| 481 |
tieFix = new QDoubleSpinBox(this); |
| 482 |
tieFix->setDecimals(1); |
| 483 |
tieFix->setMinimum(0.0); |
| 484 |
tieFix->setMaximum(1.0); |
| 485 |
tieFix->setValue(1.0); |
| 486 |
tieFix->setSingleStep(0.1); |
| 487 |
tieFix->hide(); |
| 488 |
connect(tieType,SIGNAL(currentIndexChanged(int)),this,SLOT(updateTieFreeVar())); |
| 489 |
connect(tieFVNr,SIGNAL(valueChanged(int)),this,SLOT(updateTieFreeVar())); |
| 490 |
connect(partSpin,SIGNAL(valueChanged(int)),this,SLOT(updateTieFreeVar())); |
| 491 |
rhla2->addWidget(tieOccL); |
| 492 |
rhla2->addWidget(tieType); |
| 493 |
rhla2->addWidget(tieFix); |
| 494 |
rhla2->addWidget(tieFVNrL); |
| 495 |
rhla2->addWidget(tieFVNr); |
| 496 |
rhla2->addWidget(tieUsedL); |
| 497 |
rhla2->setEnabled ( false ); |
| 498 |
rnla->addLayout(rhla2); |
| 499 |
indexla = new QHBoxLayout(); |
| 500 |
indexIncr = new QCheckBox("Increment Suffix "); |
| 501 |
indexIncr->setChecked(false); |
| 502 |
indexL = new QLabel("Number"); |
| 503 |
indexSpin = new QSpinBox(); |
| 504 |
indexSpin->setMinimum(-1); |
| 505 |
indexSpin->setMaximum(999); |
| 506 |
indexSpin->setValue(labelIndex); |
| 507 |
connect(indexSpin,SIGNAL(valueChanged(int )),this,SLOT(changeIndexofLabel(int ))); |
| 508 |
sufixBox = new QComboBox(); |
| 509 |
sufixL =new QLabel("Suffix"); |
| 510 |
QFont dlg2fnt=sufixL->font(); |
| 511 |
alpha<<"'"<<""<<"A"<<"B"<<"C"<<"D"<<"E"<<"F"<<"G"<<"H"<<"I"<<"J"<<"K" |
| 512 |
<<"L"<<"M"<<"N"<<"O"<<"P"<<"Q"<<"R"<<"S"<<"T"<<"U"<<"V"<<"W"<<"X"<<"Y"<<"Z" |
| 513 |
<<"A'"<<"B'"<<"C'"<<"D'"<<"E'"<<"F'"<<"G'"<<"H'"<<"I'"<<"J'"<<"K'"<<"L'"<<"M'" |
| 514 |
<<"N'"<<"O'"<<"P'"<<"Q'"<<"R'"<<"S'"<<"T'"<<"U'"<<"V'"<<"W'"<<"X'"<<"Y'"<<"Z'"; |
| 515 |
sufixBox->addItems(alpha); |
| 516 |
sufixBox->setCurrentIndex(1); |
| 517 |
sufixBox->setEditable(true); |
| 518 |
connect(sufixBox,SIGNAL( currentIndexChanged (int)),this,SLOT(changeSuffixofLabel(int ))); |
| 519 |
indexla->addWidget(indexL); |
| 520 |
indexla->addWidget(indexSpin); |
| 521 |
indexla->addWidget(sufixL); |
| 522 |
indexla->addWidget(sufixBox); |
| 523 |
rnla->addLayout(indexla); |
| 524 |
labelSuffix=""; |
| 525 |
nextLabel="C1"; |
| 526 |
labelIndex=1; |
| 527 |
labelPSE="C"; |
| 528 |
sfacBox = new QGroupBox("Scattering factors"); |
| 529 |
sfacBox->setFixedSize(110*52,70); |
| 530 |
sfacla = new QHBoxLayout(); |
| 531 |
dsm= new QSignalMapper(this); |
| 532 |
sfacla->addWidget(pserbt[0] = new QRadioButton("any")); |
| 533 |
/* |
| 534 |
QString pth=QDir::homePath()+"/QRadioButtonFont.txt"; |
| 535 |
FILE *frbf=fopen(pth.toStdString().c_str(),"wt"); |
| 536 |
fprintf(frbf, "%d %s\n", pserbt[0]->fontInfo().pointSize(), pserbt[0]->fontInfo().family().toStdString().c_str()); |
| 537 |
fclose(frbf); |
| 538 |
*/ |
| 539 |
dlg2fnt.setPointSize(10); |
| 540 |
pserbt[0]->setFont(dlg2fnt); |
| 541 |
dsm->setMapping(pserbt[0],"any"); |
| 542 |
connect(pserbt[0], SIGNAL(clicked()), dsm, SLOT(map())); |
| 543 |
for (int i=1; i<109; i++){ |
| 544 |
sfacla->addWidget(pserbt[i] = new QRadioButton(mole.pse(i-1))); |
| 545 |
pserbt[i]->setFont(dlg2fnt); |
| 546 |
dsm->setMapping(pserbt[i],mole.pse(i-1)); |
| 547 |
connect(pserbt[i], SIGNAL(clicked()), dsm, SLOT(map())); |
| 548 |
pserbt[i]->hide(); |
| 549 |
} |
| 550 |
sfacla->addWidget(pserbt[110] = new QRadioButton("D")); |
| 551 |
pserbt[110]->setFont(dlg2fnt); |
| 552 |
dsm->setMapping(pserbt[110],"D"); |
| 553 |
connect(pserbt[110], SIGNAL(clicked()), dsm, SLOT(map())); |
| 554 |
pserbt[110]->hide(); |
| 555 |
|
| 556 |
//connect(dsm, SIGNAL(mappedString(const QString &)), this, SLOT(changeElemetofLabel(const QString &))); |
| 557 |
#if (QT_VERSION >= 0x050f00) |
| 558 |
connect(dsm, &QSignalMapper::mappedString, this, &Window::changeElemetofLabel); |
| 559 |
#else |
| 560 |
connect(dsm, SIGNAL(mapped(const QString &)), this, SLOT(changeElemetofLabel(const QString &))); |
| 561 |
#endif |
| 562 |
sfacBox->setLayout(sfacla); |
| 563 |
qsa =new QScrollArea(); |
| 564 |
qsa->setWidget(sfacBox); |
| 565 |
qsa->setMaximumHeight(100); |
| 566 |
QHBoxLayout *rufla= new QHBoxLayout(); |
| 567 |
rufla->addWidget(rufModeBox); |
| 568 |
rufla->addWidget(indexIncr); |
| 569 |
rnla->addLayout(rufla); |
| 570 |
nextNameL = new QLabel("Next Label is:<br> <font color=\"red\">C1</font>"); |
| 571 |
nextNameL->setFont(QFont("Helvetica",16,QFont::Bold)); |
| 572 |
rnla->addWidget(nextNameL); |
| 573 |
rnla->addWidget(qsa); |
| 574 |
psew = new PSEWidget(&mole,this); |
| 575 |
psew->selection=0; |
| 576 |
psew->setVisible(false); |
| 577 |
rnla->addWidget(psew); |
| 578 |
willpse = new QPushButton("more scattering factors"); |
| 579 |
|
| 580 |
willpse->setStyleSheet( |
| 581 |
QString( |
| 582 |
"QPushButton {" |
| 583 |
"border: 1px solid #000000;" |
| 584 |
"border-radius: 9px;" |
| 585 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);" |
| 586 |
"}" |
| 587 |
"QPushButton:hover {" |
| 588 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);" |
| 589 |
"}" |
| 590 |
"QPushButton:flat {" |
| 591 |
" border: none; /* no border for a flat push button */" |
| 592 |
"}" |
| 593 |
).arg("#dedede").arg("#eeeeee").arg("#aeaeae")); |
| 594 |
|
| 595 |
connect(willpse,SIGNAL(clicked()),psew,SLOT(show())); |
| 596 |
hidwillpse=new QTimer(this); |
| 597 |
hidwillpse->setSingleShot(true); |
| 598 |
hidwillpse->setInterval(100); |
| 599 |
|
| 600 |
connect(willpse,SIGNAL(clicked()),hidwillpse,SLOT(start())); |
| 601 |
connect(hidwillpse,SIGNAL(timeout()),willpse,SLOT(hide())); |
| 602 |
connect(psew,SIGNAL(pseSelected(int, bool)),psew,SLOT(hide())); |
| 603 |
connect(psew,SIGNAL(pseSelected(int, bool)),willpse,SLOT(show())); |
| 604 |
connect(psew,SIGNAL(pseSelected(int, bool)),this,SLOT(addNewScatteringFactor(int,bool))); |
| 605 |
|
| 606 |
rnla->addWidget(willpse); |
| 607 |
|
| 608 |
buttonBoxRN = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 609 |
buttonBoxRN->hide(); |
| 610 |
rnla->addWidget(buttonBoxRN); |
| 611 |
renameBox->setLayout(rnla); |
| 612 |
|
| 613 |
renamDock->setWidget(renameBox); |
| 614 |
addDockWidget(Qt::RightDockWidgetArea, renamDock); |
| 615 |
renamDock->hide(); |
| 616 |
tabifyDockWidget (shxEditorDock,renamDock); |
| 617 |
//rename dock |
| 618 |
// |
| 619 |
qPeakDock = new QDockWidget("Q-Peak-Legend"); |
| 620 |
qPeakDock->setObjectName("Peak"); |
| 621 |
qPeakDock->hide(); |
| 622 |
qPeakDock->setFixedWidth(50); |
| 623 |
qPeakDock->setToolTip("Click or scroll here to reduce the number of Q-peaks shown."); |
| 624 |
qPeakDock->setFeatures(QDockWidget::DockWidgetClosable); |
| 625 |
showQPeakLegend = qPeakDock->toggleViewAction (); |
| 626 |
connect(showQPeakLegend, SIGNAL(toggled(bool )),this,SLOT(setMonoQ(bool ))); |
| 627 |
showQPeakLegend->setIcon(QIcon(theIconPath+"qlegend.svg")); |
| 628 |
qpv = new QPeakView(); |
| 629 |
qPeakDock->setWidget(qpv); |
| 630 |
addDockWidget(Qt::LeftDockWidgetArea,qPeakDock); |
| 631 |
|
| 632 |
//HISTORY |
| 633 |
histDock = new QDockWidget("Refinement History"); |
| 634 |
histDock->setObjectName("History"); |
| 635 |
hw = new HistoryWidget(); |
| 636 |
qsa2 =new QScrollArea(); |
| 637 |
hwl = new QVBoxLayout(); |
| 638 |
hwl->addWidget(hw); |
| 639 |
qsa2->setLayout(hwl); |
| 640 |
qsa2->setWidget(hw); |
| 641 |
qsa2->setAlignment(Qt::AlignBottom|Qt::AlignLeft); |
| 642 |
histDock->hide(); |
| 643 |
histDock->setFeatures(QDockWidget::DockWidgetMovable| |
| 644 |
QDockWidget::DockWidgetFloatable| |
| 645 |
QDockWidget::DockWidgetClosable); |
| 646 |
histDock->setWidget(qsa2); |
| 647 |
histDock->setMinimumSize(100,150); |
| 648 |
addDockWidget(Qt::RightDockWidgetArea,histDock); |
| 649 |
connect(hw, SIGNAL(message(const QString&)), this, SLOT(updateStatusBar(const QString&))); |
| 650 |
connect(hw, SIGNAL(lofi(const QString&)), this, SLOT(loadFile(const QString&))); |
| 651 |
connect(hw, SIGNAL(saveHist()), this, SLOT(openSaveHistory())); |
| 652 |
//HISTORY |
| 653 |
|
| 654 |
|
| 655 |
scalePic=1.0; |
| 656 |
if ((Revision%666)==0) |
| 657 |
setWindowTitle(QString("%1 - A clumsy GUI for sHELLxl (Rev: %2)(easteregg) ") |
| 658 |
.arg(PROGRAM_NAME) |
| 659 |
.arg(Revision)); |
| 660 |
else |
| 661 |
setWindowTitle(QString("%1 - A Qt GUI for SHELXL (Rev: %2)(%3bit)(Qt%4)").arg(PROGRAM_NAME).arg(Revision) |
| 662 |
.arg(BitWidth) |
| 663 |
.arg(qtmajor) |
| 664 |
); |
| 665 |
//printf("line %d %p\n", __LINE__, _chgl); |
| 666 |
chgl = new PlayOpenGL(&mole); |
| 667 |
#if defined (Q_OS_MAC) |
| 668 |
static QWidget *container = QWidget::createWindowContainer(chgl); |
| 669 |
container->setObjectName("The Main Window"); |
| 670 |
|
| 671 |
#endif |
| 672 |
//printf("line %d %p\n", __LINE__, chgl,container); |
| 673 |
chgl->setMolecule(&mole); |
| 674 |
chgl->QPeakLegend = showQPeakLegend; |
| 675 |
editor->setgl(chgl); |
| 676 |
xlPutor->setgl(chgl); |
| 677 |
|
| 678 |
|
| 679 |
connect(qpv,SIGNAL(cutOffChanged(double)),chgl,SLOT(setQpeakCutoff(double))); |
| 680 |
connect(qpv,SIGNAL(findQP(double)),chgl,SLOT(highliteQPeak(double))); |
| 681 |
connect(chgl,SIGNAL(qpfoci(double)),qpv,SLOT(qpeaksInFocus(double))); |
| 682 |
connect(renamDock,SIGNAL(visibilityChanged(bool)),chgl,SLOT(setReNaMo(bool))); |
| 683 |
connect(renamDock,SIGNAL(visibilityChanged(bool)),this,SLOT(updateLabel())); |
| 684 |
|
| 685 |
connect(renamDock,SIGNAL(visibilityChanged(bool)),this,SLOT(renamUpdate(bool))); |
| 686 |
connect(chgl,SIGNAL(message(const QString&)),this,SLOT(updateStatusBar(const QString&))); |
| 687 |
connect(chgl,SIGNAL(bigmessage(const QString&)),this,SLOT(infoKanalNews(const QString&))); |
| 688 |
connect(chgl,SIGNAL(jumpit(int)),this ,SLOT(jumpToAtom(int))); |
| 689 |
connect(chgl,SIGNAL(insertDFIX(double,double,QList<MyAtom>,QString)), editor,SLOT(insertDFIX(double,double,QList<MyAtom>,QString))); |
| 690 |
connect(chgl,SIGNAL(bindthem()),editor,SLOT(insertBind())); |
| 691 |
connect(chgl,SIGNAL(insertDANG(double,double,QList<MyAtom>,QString)), editor,SLOT(insertDANG(double,double,QList<MyAtom>,QString))); |
| 692 |
connect(chgl,SIGNAL(insertFLAT(double,QList<MyAtom>,QString)), editor,SLOT(insertFLAT(double,QList<MyAtom>,QString))); |
| 693 |
connect(chgl,SIGNAL(insertEXYZ(QList<MyAtom>)), editor, SLOT(insertEXYZ(QList<MyAtom>))); |
| 694 |
connect(chgl,SIGNAL(insertEADP(QList<MyAtom>)), editor, SLOT(insertEADP(QList<MyAtom>))); |
| 695 |
connect(chgl,SIGNAL(insertSADI(int)), this, SLOT(insertSADI(int))); |
| 696 |
connect(chgl,SIGNAL(insertDELU(double, double, QList<MyAtom>,QString)), editor,SLOT(insertDELU(double,double,QList<MyAtom>,QString))); |
| 697 |
connect(chgl,SIGNAL(insertSIMU(double,double,double,QList<MyAtom>,QString)), editor,SLOT(insertSIMU(double,double,double,QList<MyAtom>,QString))); |
| 698 |
connect(chgl,SIGNAL(insertISOR(double,double,QList<MyAtom>,QString)), editor,SLOT(insertISOR(double,double,QList<MyAtom>,QString))); |
| 699 |
connect(chgl,SIGNAL(insertRIGU(double, double, QList<MyAtom>,QString)), editor,SLOT(insertRIGU(double,double,QList<MyAtom>,QString))); |
| 700 |
connect(chgl,SIGNAL(insertCHIV(double, double, QList<MyAtom>,QString)), editor,SLOT(insertCHIV(double,double,QList<MyAtom>,QString))); |
| 701 |
connect(chgl,SIGNAL(insertANIS(QList<MyAtom>)), editor, SLOT(insertANIS(QList<MyAtom>))); |
| 702 |
QAction *sma =new QAction("Show matrices (for debugging)",this); |
| 703 |
sma->setShortcut(tr("Alt+F1")); |
| 704 |
connect(sma,SIGNAL(triggered()),chgl,SLOT(showMatrix())); |
| 705 |
for (int i = 0; i < MaxRecentFiles; ++i) { |
| 706 |
recentFileActs[i] = new QAction(this); |
| 707 |
recentFileActs[i]->setVisible(false); |
| 708 |
connect(recentFileActs[i], SIGNAL(triggered()), |
| 709 |
this, SLOT(openRecentFile())); |
| 710 |
} |
| 711 |
fileMenu = new QMenu(tr("File"), this); |
| 712 |
//printf("line %d\n",__LINE__); |
| 713 |
|
| 714 |
chgl->sfacMenu = new QMenu(tr("Change element to...")); |
| 715 |
chgl->selSfacMenu = new QMenu(tr("Change elements of selection to...")); |
| 716 |
editMenu = new QMenu(tr("Edit"),this); |
| 717 |
dialogMenu = new QMenu(tr("Settings"), this); |
| 718 |
viewMenu = new QMenu(tr("View"), this); |
| 719 |
runMenu = new QMenu(tr("SHELX"),this); |
| 720 |
runMenu->setObjectName("SHELX"); |
| 721 |
packMenu = new QMenu(tr("Pack"),this); |
| 722 |
packMenu->setEnabled(false); |
| 723 |
QMenu *fcoMenu = new QMenu("Tools"); |
| 724 |
|
| 725 |
//printf("line %d\n",__LINE__); |
| 726 |
{ |
| 727 |
QAction *a = symmElementsAct = packMenu->addAction("Show Symmetry Elements", this, SLOT(symmElements(bool))); |
| 728 |
a->setCheckable(true); |
| 729 |
a->setChecked(false); |
| 730 |
//a->setVisible(false); |
| 731 |
} |
| 732 |
extraMenu = new QMenu(tr("Extra"),this); |
| 733 |
{ |
| 734 |
QAction *a; |
| 735 |
a = switch2HKLF5 = runMenu->addAction("Switch to HKLF 5 refinement.", this, SLOT(go2hklf5())); |
| 736 |
a->setVisible(false); |
| 737 |
switch2HKLF5->setObjectName("switch2HKLF5"); |
| 738 |
|
| 739 |
a = switch2HKLF4 = runMenu->addAction("Switch to HKLF 4 refinement.", this, SLOT(go2hklf4())); |
| 740 |
a->setVisible(false); |
| 741 |
a = refineAct = runMenu->addAction(QIcon(theIconPath+"refine.svg"),"Copy current file to instruction file and run shelxl",this,SLOT(runShelXL())); |
| 742 |
a->setShortcut(QKeySequence("F2")); |
| 743 |
a->setData(0); |
| 744 |
refineAct->setVisible(false); |
| 745 |
refineAct->setEnabled(false); |
| 746 |
|
| 747 |
a->setObjectName("refineAct"); |
| 748 |
|
| 749 |
a = refineActAnis = runMenu->addAction(QIcon(theIconPath+"refineanis.svg"),"Insert ANIS and run shelxl",this,SLOT(runShelXL())); |
| 750 |
a->setShortcut(QKeySequence("Alt+F2")); |
| 751 |
a->setData(1); |
| 752 |
refineActAnis->setVisible(false); |
| 753 |
refineActAnis->setEnabled(false); |
| 754 |
a->setObjectName("refineActAnis"); |
| 755 |
a = refineActActa = runMenu->addAction(QIcon(theIconPath+"refineacta.svg"),"Insert ACTA and run shelxl",this,SLOT(runShelXL())); |
| 756 |
a->setData(2); |
| 757 |
refineActActa->setVisible(false); |
| 758 |
refineActActa->setEnabled(false); |
| 759 |
a = refineActExti = runMenu->addAction("Insert EXTI and run shelxl",this,SLOT(runShelXL())); |
| 760 |
a->setData(3); |
| 761 |
refineActExti->setVisible(false); |
| 762 |
refineActExti->setEnabled(false); |
| 763 |
|
| 764 |
a = refineActConf = runMenu->addAction("Insert CONF and run shelxl",this,SLOT(runShelXL())); |
| 765 |
a->setData(4); |
| 766 |
refineActConf->setVisible(false); |
| 767 |
refineActConf->setEnabled(false); |
| 768 |
wghtRefineAct=runMenu->addAction(QIcon(theIconPath+"wghtref.svg"),QString("Try to refine until WGHT converges (max %1 runs)").arg(wght_max_cycls),this,SLOT(convergeWght())); |
| 769 |
if (canWeSqueeze()) { |
| 770 |
squeezeAct=a=fcoMenu->addAction(QIcon(theIconPath+"squeeze.svg"),"PLATON SQUEEZE this data",this,SLOT(runSqueeze())); |
| 771 |
} |
| 772 |
else squeezeAct=nullptr; |
| 773 |
|
| 774 |
QIcon icke = QIcon(theIconPath+"autohfix.svg"); |
| 775 |
a=actionHFix=runMenu->addAction(icke, |
| 776 |
tr("Automatic H-Fi&x"),this,SLOT(autoHFix())); |
| 777 |
a->setObjectName("actionHFix"); |
| 778 |
a=runMenu->addAction("DISPersion from WAVElength", editor, SLOT(dispFromWave())); |
| 779 |
a=runMenu->addAction("Replace SFAC by elastic electron atomic scattering factors",editor,SLOT(insertElectronSFACs())); |
| 780 |
a=actionUniq=runMenu->addAction("Move centers of gravity into unit cell",this,SLOT(uniq())); |
| 781 |
a->setObjectName("actionUniq"); |
| 782 |
runMenu->addAction("UNIQue ", this, SLOT(unique())); |
| 783 |
runMenu->addAction("Update UNIT instruction", editor, SLOT(updateUnit())); |
| 784 |
runMenu->addAction("Weed unused SFAC numbers ", editor, SLOT(weedEmptySfacs())); |
| 785 |
wghtAct=runMenu->addAction("Update WGHT instruction",editor,SLOT(updateWght())); |
| 786 |
wghtAct->setEnabled(false); |
| 787 |
runMenu->addAction("Invert structure", this, SLOT(invert())); |
| 788 |
runMenu->addAction("Fix some parameters", this, SLOT(fixIt())); |
| 789 |
sinaAct = runMenu->addAction(QIcon(theIconPath+"sina.svg"),"Make (selected or all) atoms isotropic (ISOT)",this,SLOT(sina())); |
| 790 |
sinaAct->setObjectName("sinaAct"); |
| 791 |
sinaAct->setData(-1); |
| 792 |
fcoMenu->addAction("Create Q-Peaks from Fo-Fc map",this, SLOT(addMoreQPeaks())); |
| 793 |
actionQPeakLimit = fcoMenu->addAction(QString("Change maximum number of created Q-peaks (%1)").arg(MaxNumberOfPeaks),this,SLOT(changeQPeakLimit())); |
| 794 |
fcoMenu->addAction("Most Disagreeable Reflections",this,SLOT(worstReflections())); |
| 795 |
fcoMenu->addAction("Split rotate molecule branch",this,SLOT(splitRotate())); |
| 796 |
a=fcoMenu->addAction("test for merohedral twinning"); |
| 797 |
twinDlg=nullptr; |
| 798 |
connect(a,SIGNAL(triggered() ),this,SLOT(testMerohedral())); |
| 799 |
runMenu->addAction(QIcon(theIconPath+"aula.svg"),"Automatic Labeling", this, SLOT(aula())); |
| 800 |
runMenu->addSeparator(); |
| 801 |
editor->sortierWeise=1; |
| 802 |
soact=runMenu->addAction("Sort atoms in file.",editor ,SLOT(sortAtoms())); |
| 803 |
|
| 804 |
runMenu->addSeparator(); |
| 805 |
a=runMenu->addAction("...find more functions in Menu->Tools"); |
| 806 |
a->setDisabled(true); |
| 807 |
runMenu->addSeparator(); |
| 808 |
runMenu->addAction("Specify SHELXL runtime options",this , SLOT(setShelxlOptions())); |
| 809 |
} |
| 810 |
{ |
| 811 |
QToolBar *tb =fito= new QToolBar(this); |
| 812 |
tb->setWindowTitle(tr("File Tools")); |
| 813 |
tb->setObjectName("FileTB"); |
| 814 |
addToolBar(tb); |
| 815 |
QAction *a; |
| 816 |
openAct=a=fileMenu->addAction(QIcon(theIconPath+"open.svg"), |
| 817 |
tr("&Open..."), this, SLOT(openFile() ),QKeySequence(tr("Ctrl+O", "File|Open"))); |
| 818 |
tb->addAction(a); |
| 819 |
actionSave = new QAction(QIcon(theIconPath+"filesave.svg"),tr("&Save"), this); |
| 820 |
actionSave->setShortcut(QKeySequence::Save); |
| 821 |
connect(actionSave, SIGNAL(triggered()), this, SLOT(fileSave())); |
| 822 |
actionSave->setEnabled(false); |
| 823 |
tb->addAction(actionSave); |
| 824 |
fileMenu->addAction(actionSave); |
| 825 |
actionSaveAs = new QAction(QIcon(theIconPath+"filesave.svg"),tr("&Save as ..."), this); |
| 826 |
actionSaveAs->setShortcut(tr("Shift+Alt+S")); |
| 827 |
connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(fileSaveAs())); |
| 828 |
actionSaveAs->setEnabled(true); |
| 829 |
fileMenu->addAction(actionSaveAs); |
| 830 |
fileMenu->addAction(tr("Open save history"),this,SLOT(openSaveHistory())); |
| 831 |
fileMenu->addAction("Shred a CIF and load its res",this,SLOT(shredCIF())); |
| 832 |
fileMenu->addSeparator(); |
| 833 |
screenshotAct=a=fileMenu->addAction(QIcon(theIconPath+"diskette.svg"), |
| 834 |
tr("&ScreenShot"), this, SLOT(saveScene()), QKeySequence(tr("F7","File|ScreenShot"))); |
| 835 |
//tb->addAction(a); |
| 836 |
actionPovRay=a=fileMenu->addAction(QIcon(theIconPath+"POV-Ray.ico"),"Export Scene to Pov-Ray",this, SLOT(savePovRay())); |
| 837 |
a->setShortcut(Qt::ALT|Qt::Key_P); |
| 838 |
tb->addAction(a); |
| 839 |
objExport=a=fileMenu->addAction(QIcon(theIconPath+"obj.svg"),"Export Wafefront .obj file",this,SLOT(obj())); |
| 840 |
tb->addAction(a); |
| 841 |
a->setShortcut(Qt::ALT|Qt::Key_O); |
| 842 |
fileMenu->addAction("Export Fourier Maps",this,SLOT(exportFMaps())); |
| 843 |
fileMenu->addAction("Export visible atoms ...",this,SLOT(exportCoordinates())); |
| 844 |
actionExportCC=fileMenu->addAction("Export for computational chemistry programs",this, SLOT(exportCC())); |
| 845 |
|
| 846 |
fileMenu->addSeparator(); |
| 847 |
for (int i = 0; i < MaxRecentFiles; ++i) |
| 848 |
fileMenu->addAction(recentFileActs[i]); |
| 849 |
fileMenu->addSeparator(); |
| 850 |
fileMenu->addAction("Set default path",this,SLOT(setDefaultPath())); |
| 851 |
fileMenu->addSeparator(); |
| 852 |
a=fileMenu->addAction(QIcon(theIconPath+"cancel.svg"), tr("&Quit") , |
| 853 |
this, SLOT(close()),QKeySequence(tr("Ctrl+Q", "File|Quit"))); |
| 854 |
tb->addAction(a); |
| 855 |
} |
| 856 |
|
| 857 |
//printf("line %d\n", __LINE__); |
| 858 |
backColor = new QAction(tr("Change background color"), this); |
| 859 |
labelColor = new QAction(tr("Change label color"), this); |
| 860 |
backColor->setShortcut (tr("Shift+Alt+B")); |
| 861 |
labelColor->setShortcut(tr("Shift+Alt+T")); |
| 862 |
connect(backColor, SIGNAL (triggered ()), chgl, SLOT(changeBColor())); |
| 863 |
connect(labelColor, SIGNAL (triggered ()), chgl, SLOT(changeTColor())); |
| 864 |
dialogMenu->addAction("Change tool bar icon size",this,SLOT(changeIconSize())); |
| 865 |
QAction *adoptAct= |
| 866 |
dialogMenu->addAction("Edit tool bar is attached to Editor",this,SLOT(adoptEditToolBar(bool))); |
| 867 |
adoptAct->setCheckable(true); |
| 868 |
adoptAct->setChecked(false); |
| 869 |
dialogMenu->addAction("Change screen shot resolution",this,SLOT(changeScalefactor())); |
| 870 |
dialogMenu->addAction("Number of atoms in asymmetric unit to skip automatic distance calculation on loading",this, SLOT(setSDMLimit())); |
| 871 |
dialogMenu->addAction("Number of max cycles in WGHT refine", this ,SLOT(setMaxWGHTCycls())); |
| 872 |
separateLabelFile= dialogMenu->addAction("Render labels in a separate file"); |
| 873 |
separateLabelFile->setCheckable(true); |
| 874 |
separateLabelFile->setChecked(false); |
| 875 |
dialogMenu->addAction(backColor); |
| 876 |
dialogMenu->addAction(labelColor); |
| 877 |
dialogMenu->addAction(tr("Change label font"), this, SLOT(changeLabelFont())); |
| 878 |
dialogMenu->addAction(tr("Change editor font"), this, SLOT(changeEditorFont())); |
| 879 |
astdlg = dialogMenu->addAction(QIcon(theIconPath+"eac.svg"),"Atom Styles", this,SLOT(styleDialog()),QKeySequence("Alt+Shift+A")); |
| 880 |
dialogMenu->addAction("Save current orientation matrix",chgl,SLOT(saveOrientation())); |
| 881 |
dialogMenu->addAction("Load orientation matrix",chgl,SLOT(loadOrientation())); |
| 882 |
editMenu->addAction(enterRenameMode); |
| 883 |
{ |
| 884 |
QToolBar *tb = editToolBar = new QToolBar(this); |
| 885 |
tb->setObjectName("EditTB"); |
| 886 |
tb->setWindowTitle(tr("Editor Tools")); |
| 887 |
QAction *a; |
| 888 |
actionEP=a=viewMenu->addAction(QIcon(theIconPath+"efplus.svg"), "Increase editor fontsize"); |
| 889 |
actionEP->setShortcut(QKeySequence(QKeySequence::ZoomIn)); |
| 890 |
connect(actionEP,SIGNAL(triggered()), editor, SLOT(increaseEdtiorFont())); |
| 891 |
connect(actionEP,SIGNAL(triggered()), xlPutor,SLOT(increaseEdtiorFont())); |
| 892 |
tb->addAction(a); |
| 893 |
actionEM=a=viewMenu->addAction(QIcon(theIconPath+"efminus.svg"), "Decrease editor fontsize"); |
| 894 |
actionEM->setShortcut(QKeySequence(QKeySequence::ZoomOut)); |
| 895 |
connect(actionEM,SIGNAL(triggered()), editor, SLOT(decreaseEdtiorFont())); |
| 896 |
connect(actionEM,SIGNAL(triggered()), xlPutor, SLOT(decreaseEdtiorFont())); |
| 897 |
tb->addAction(a); |
| 898 |
a = actionUndo = new QAction(QIcon( theIconPath+"editundo.svg"),tr("&Undo"), this); |
| 899 |
a->setShortcut(QKeySequence::Undo); |
| 900 |
a->setEnabled(false); |
| 901 |
tb->addAction(a); |
| 902 |
editMenu->addAction(a); |
| 903 |
a = actionRedo = new QAction(QIcon( theIconPath+"editredo.svg"),tr("&Redo"), this); |
| 904 |
a->setShortcut(QKeySequence::Redo); |
| 905 |
a->setEnabled(false); |
| 906 |
tb->addAction(a); |
| 907 |
editMenu->addAction(a); |
| 908 |
editMenu->addSeparator(); |
| 909 |
a = actionCut = new QAction(QIcon(theIconPath+"editcut.svg"),tr("Cu&t"), this); |
| 910 |
a->setShortcut(QKeySequence::Cut); |
| 911 |
a->setEnabled(false); |
| 912 |
tb->addAction(a); |
| 913 |
editMenu->addAction(a); |
| 914 |
a = actionCopy = new QAction(QIcon(theIconPath+"editcopy.svg"),tr("&Copy"), this); |
| 915 |
a->setShortcut(QKeySequence::Copy); |
| 916 |
a->setEnabled(false); |
| 917 |
tb->addAction(a); |
| 918 |
editMenu->addAction(a); |
| 919 |
a = actionPaste = new QAction(QIcon(theIconPath+"editpaste.svg"),tr("&Paste"), this); |
| 920 |
a->setShortcut(QKeySequence::Paste); |
| 921 |
a->setEnabled(false); |
| 922 |
tb->addAction(a); |
| 923 |
editMenu->addAction(a); |
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
//printf("line %d\n",__LINE__); |
| 928 |
#ifndef QT_NO_CLIPBOARD |
| 929 |
actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty()); |
| 930 |
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); |
| 931 |
#endif |
| 932 |
a=actionSearch=editMenu->addAction(QIcon(theIconPath+"search.svg"), |
| 933 |
"&Find in Text",this,SLOT(showSearch()),QKeySequence(tr("Ctrl+F", "Edit|Find"))); |
| 934 |
tb->addAction(a); |
| 935 |
a->setEnabled(false); |
| 936 |
a=actionNext=editMenu->addAction(QIcon(theIconPath+"moveright.svg"), |
| 937 |
tr("Find &Next"),this ,SLOT(findNext()),QKeySequence(tr("F3","Edit|Next"))); |
| 938 |
a->setEnabled(false); |
| 939 |
a=actionPrev=editMenu->addAction(QIcon(theIconPath+"moveleft.svg"), |
| 940 |
tr("Find &Previous"),this, SLOT(findPrev()), QKeySequence(tr("Shift+F3", "Edit|Previous"))); |
| 941 |
a->setEnabled(false); |
| 942 |
editToolBar->hide(); |
| 943 |
|
| 944 |
|
| 945 |
//printf("line %d\n",__LINE__); |
| 946 |
} |
| 947 |
{ |
| 948 |
QToolBar *tb = refineToolBar = new QToolBar(this); |
| 949 |
tb->setObjectName("RefineTB"); |
| 950 |
tb->setWindowTitle(tr("Refinement Tools")); |
| 951 |
addToolBar(tb); |
| 952 |
tb->addAction(actionHFix); |
| 953 |
QIcon icke=QIcon(theIconPath+"killqs.svg"); |
| 954 |
QAction *a; |
| 955 |
a=killQs=editMenu->addAction(icke, |
| 956 |
tr("Delete all Q-peaks"), this, SLOT(deleteAllQ()), QKeySequence(tr("Meta+Shift+Q"))); |
| 957 |
tb->addAction(a); |
| 958 |
icke=QIcon(theIconPath+"killhs.svg"); |
| 959 |
a=killHs=editMenu->addAction(icke, tr("Delete all Hydrogen atoms"),this,SLOT(deleteAllH()), QKeySequence(tr("Meta+Shift+H"))); |
| 960 |
tb->addAction(a); |
| 961 |
tb->addAction(refineAct); |
| 962 |
tb->addAction(refineActAnis); |
| 963 |
tb->addAction(wghtRefineAct); |
| 964 |
if (squeezeAct!=nullptr) tb->addAction(squeezeAct); |
| 965 |
refineToolBar->hide(); |
| 966 |
} |
| 967 |
|
| 968 |
|
| 969 |
//printf("line %d\n",__LINE__); |
| 970 |
{ |
| 971 |
//QToolBar *tb = |
| 972 |
vito = new QToolBar(this); |
| 973 |
vito->setWindowTitle(tr("View Tools")); |
| 974 |
vito->setObjectName("ViewTB"); |
| 975 |
addToolBar(vito); |
| 976 |
QAction *a; |
| 977 |
/* |
| 978 |
stereoMenu = new QMenu("&3D Stereo Options"); |
| 979 |
//zm_stereo = stereoMenu->addAction("&Zalman Monitor 3D"); |
| 980 |
pe_stereo = stereoMenu->addAction("&Parallel Eye Side by Side Stereo"); |
| 981 |
xe_stereo = stereoMenu->addAction("&Crossed Eye Side by Side Stereo"); |
| 982 |
an_stereo = stereoMenu->addAction("&Anaglyph Stereo red left blue right(testing)"); |
| 983 |
//hw_stereo = stereoMenu->addAction("&Hardware Stereo (testing)"); |
| 984 |
|
| 985 |
|
| 986 |
//printf("line %d\n",__LINE__); |
| 987 |
//hw_stereo->setEnabled(chgl->context()->format().stereo()); |
| 988 |
|
| 989 |
|
| 990 |
//printf("line %d\n",__LINE__); |
| 991 |
no_stereo = stereoMenu->addAction("Stereo &Mode off"); |
| 992 |
//connect(zm_stereo,SIGNAL(triggered()),chgl,SLOT(zalman())); |
| 993 |
connect(pe_stereo,SIGNAL(triggered()),chgl,SLOT(parallel())); |
| 994 |
connect(xe_stereo,SIGNAL(triggered()),chgl,SLOT(crosseye())); |
| 995 |
connect(an_stereo,SIGNAL(triggered()),chgl,SLOT(anaglyphRedCyan())); |
| 996 |
//connect(hw_stereo,SIGNAL(triggered()),chgl,SLOT(hardwareStereo())); |
| 997 |
connect(no_stereo,SIGNAL(triggered()),chgl,SLOT(nostereo())); |
| 998 |
stereoGroup = new QActionGroup(this); |
| 999 |
//stereoGroup->addAction(zm_stereo); |
| 1000 |
stereoGroup->addAction(pe_stereo); |
| 1001 |
stereoGroup->addAction(xe_stereo); |
| 1002 |
stereoGroup->addAction(an_stereo); |
| 1003 |
//stereoGroup->addAction(hw_stereo); |
| 1004 |
stereoGroup->addAction(no_stereo); |
| 1005 |
//zm_stereo->setCheckable(true); |
| 1006 |
pe_stereo->setCheckable(true); |
| 1007 |
xe_stereo->setCheckable(true); |
| 1008 |
an_stereo->setCheckable(true); |
| 1009 |
//hw_stereo->setCheckable(true); |
| 1010 |
no_stereo->setCheckable(true); |
| 1011 |
no_stereo->setChecked(true); |
| 1012 |
viewMenu->insertMenu(actionEP,stereoMenu); |
| 1013 |
viewMenu->insertSeparator(actionEP); |
| 1014 |
*/ |
| 1015 |
moveMenu = new QMenu("Move Menu"); |
| 1016 |
moveMenu->addAction(tr("Zoom in") ,this,SLOT(zoomin ()), QKeySequence(Qt::ALT | Qt::Key_PageUp) ); |
| 1017 |
moveMenu->addAction(tr("Zoom out") ,this,SLOT(zoomout()), QKeySequence(Qt::ALT | Qt::Key_PageDown)); |
| 1018 |
moveMenu->addAction(tr("Rotate left") ,this,SLOT(rotl ()), QKeySequence(Qt::ALT | Qt::Key_Left) ); |
| 1019 |
moveMenu->addAction(tr("Rotate right") ,this,SLOT(rotr ()), QKeySequence(Qt::ALT | Qt::Key_Right) ); |
| 1020 |
moveMenu->addAction(tr("Rotate upwards") ,this,SLOT(rotu ()), QKeySequence(Qt::ALT | Qt::Key_Up) ); |
| 1021 |
moveMenu->addAction(tr("Rotate downwards") ,this,SLOT(rotd ()), QKeySequence(Qt::ALT | Qt::Key_Down) ); |
| 1022 |
moveMenu->addAction(sma); |
| 1023 |
moveMenu->addAction("test test 1 2",this, SLOT(testOGL()),QKeySequence(Qt::META|Qt::SHIFT|Qt::Key_A) ); |
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
//printf("line %d\n",__LINE__); |
| 1028 |
moveMenu->addAction("Zoom out", chgl, SLOT(zoomOut()), QKeySequence(Qt::ALT | Qt::CTRL | Qt::Key_Z)); |
| 1029 |
moveMenu->addAction("View along z direction",chgl,SLOT(along001())); |
| 1030 |
viewMenu->insertMenu(actionEP,moveMenu); |
| 1031 |
|
| 1032 |
|
| 1033 |
//printf("line %d\n",__LINE__); |
| 1034 |
QIcon icke=QIcon(theIconPath+"ideal.svg"); |
| 1035 |
chgl->hideBeLo=viewMenu->addAction(icke,"Toggle BEDE and LONE objects (IDEAL)",chgl,SLOT(update())); |
| 1036 |
chgl->hideBeLo->setCheckable(true); |
| 1037 |
chgl->hideBeLo->setChecked(true); |
| 1038 |
chgl->hideBeLo->setVisible(false); |
| 1039 |
belocube = viewMenu->addAction("Compute and visualize BODD in direct space (IDEAL)" ,this,SLOT(beloWriteCube())); |
| 1040 |
belocube->setVisible(false); |
| 1041 |
belocube->setObjectName("BeLoCube"); |
| 1042 |
belocube->setShortcut(Qt::CTRL|Qt::Key_I); |
| 1043 |
a=dialogMenu->addAction("HFIX only on suitable atoms", this, SLOT(toggleHFSAO(bool))); |
| 1044 |
a->setCheckable(true); |
| 1045 |
a->setChecked(mole.HFixSuitableAtomsOnly); |
| 1046 |
|
| 1047 |
//printf("line %d\n",__LINE__); |
| 1048 |
dialogMenu->addAction("Style BEDE and LONE objects (IDEAL)",this,SLOT(configBeLos())); |
| 1049 |
chgl->shortLabels=viewMenu->addAction("Short Labels",chgl,SLOT(makeLabels())); |
| 1050 |
chgl->shortLabels->setCheckable(true); |
| 1051 |
chgl->shortLabels->setChecked(true); |
| 1052 |
chgl->shortLabels->setShortcut(Qt::SHIFT | Qt::ALT | Qt::Key_L); |
| 1053 |
|
| 1054 |
vito->addAction(astdlg); |
| 1055 |
a=togAtom =viewMenu->addAction(QIcon(theIconPath+"atoms.svg"), |
| 1056 |
tr("Toggle Atoms"), chgl, SLOT(setAtoms(bool)), QKeySequence("Alt+A")); |
| 1057 |
a->setCheckable(true); |
| 1058 |
a->setChecked(true); |
| 1059 |
vito->addAction(a); |
| 1060 |
a=chgl->tubes = vito->addAction(QIcon(theIconPath+"tubes.svg"),"Tubes",chgl,SLOT(update())); |
| 1061 |
a=chgl->ballStick = vito->addAction(QIcon(theIconPath+"ballstick.svg"),"Ball-Stick",chgl,SLOT(update())); |
| 1062 |
tubeGroup = new QActionGroup(this); |
| 1063 |
tubeGroup->addAction(chgl->tubes); |
| 1064 |
tubeGroup->addAction(chgl->ballStick); |
| 1065 |
chgl->ballStick->setCheckable(true); |
| 1066 |
chgl->ballStick->setChecked(true); |
| 1067 |
connect(chgl->ballStick, SIGNAL(triggered()), chgl, SLOT(makeLegendAtoms())); |
| 1068 |
|
| 1069 |
chgl->tubes->setCheckable(true); |
| 1070 |
chgl->tubes->setChecked(false); |
| 1071 |
connect(chgl->tubes, SIGNAL(triggered()), chgl, SLOT(makeLegendAtoms())); |
| 1072 |
|
| 1073 |
//printf("line %d\n",__LINE__); |
| 1074 |
{ |
| 1075 |
QIcon icke=QIcon(theIconPath+"adp.svg"); |
| 1076 |
//icke.addFile(theIconPath+"adp23.svg"); |
| 1077 |
a=chgl->adp =viewMenu->addAction(icke, tr("Toggle ADPs"), chgl, SLOT(update()), QKeySequence("Alt+E")); |
| 1078 |
connect(chgl->adp, SIGNAL(triggered()), chgl, SLOT(makeLegendAtoms())); |
| 1079 |
} |
| 1080 |
a->setCheckable(true); |
| 1081 |
a->setChecked(true); |
| 1082 |
vito->addAction(a); |
| 1083 |
a=togBond =viewMenu->addAction(QIcon(theIconPath+"bonds.svg"), |
| 1084 |
tr("Toggle Bonds"), chgl, SLOT(setBonds(bool)), QKeySequence("Alt+B")); |
| 1085 |
a->setCheckable(true); |
| 1086 |
a->setChecked(true); |
| 1087 |
vito->addAction(a); |
| 1088 |
a=togLabel=viewMenu->addAction(QIcon(theIconPath+"labels.svg"), |
| 1089 |
tr("Toggle Labels"),chgl,SLOT(setLabels(bool)),QKeySequence("Alt+L")); |
| 1090 |
a->setCheckable(true); |
| 1091 |
a->setChecked(true); |
| 1092 |
vito->addAction(a); |
| 1093 |
|
| 1094 |
//printf("line %d\n",__LINE__); |
| 1095 |
/* |
| 1096 |
a=viewMenu->addAction(QIcon(theIconPath+"laplus.svg"), |
| 1097 |
tr("Increase label fontsize"),chgl,SLOT(incFontSize()), |
| 1098 |
QKeySequence("Alt++")); |
| 1099 |
a=viewMenu->addAction(QIcon(theIconPath+"laminus.svg"), |
| 1100 |
tr("Decrease label fontsize"),chgl,SLOT(decFontSize()), |
| 1101 |
QKeySequence("Alt+-"));*/ |
| 1102 |
|
| 1103 |
//printf("line %d\n", __LINE__); |
| 1104 |
a=chgl->togUnit =viewMenu->addAction(QIcon(theIconPath+"unitcell.svg"), |
| 1105 |
tr("Toggle Unit Cell"),chgl,SLOT(update()),QKeySequence("Alt+C")); |
| 1106 |
a->setCheckable(true); |
| 1107 |
a->setChecked(false); |
| 1108 |
vito->addAction(a); |
| 1109 |
//printf("line %d %p\n", __LINE__,viewMenu,chgl->h_bonds); |
| 1110 |
a=chgl->h_bonds=viewMenu->addAction(QIcon(theIconPath+"hbrs.svg"), |
| 1111 |
tr("Toggle H-bonds"),chgl,SLOT(update()),QKeySequence("Alt+H")); |
| 1112 |
a->setCheckable(true); |
| 1113 |
a->setChecked(true); |
| 1114 |
vito->addAction(a); |
| 1115 |
//printf("line %d %p %d\n", __LINE__, chgl->h_bonds, chgl->h_bonds->isVisible()); |
| 1116 |
a=chgl->atomLegend=viewMenu->addAction(QIcon(theIconPath+"legend.svg"), |
| 1117 |
tr("Toggle Atom Legend"),chgl,SLOT(update()), QKeySequence("Alt+K")); |
| 1118 |
a->setCheckable(true); |
| 1119 |
a->setChecked(true); |
| 1120 |
vito->addAction(a); |
| 1121 |
|
| 1122 |
//printf("line %d\n",__LINE__); |
| 1123 |
fxle= new FourXle(&mole, chgl, vito); |
| 1124 |
|
| 1125 |
//printf("line %d\n",__LINE__); |
| 1126 |
fxle->mapcontrol=dialogMenu->addAction(QIcon(theIconPath+"mapcontrol.svg"),tr("Open Map Control"), fxle, SLOT(openMapControl())); |
| 1127 |
vito->addAction(fxle->mapcontrol); |
| 1128 |
fxle->mapcontrol->setVisible(false); |
| 1129 |
connect(chgl,SIGNAL(destroyed()),fxle ,SLOT(killFourXleFirst()));//maybe tidy up before die |
| 1130 |
connect(fxle,SIGNAL(reloadRes()),this ,SLOT(loadAFile())); |
| 1131 |
connect(fxle->jnkButton,SIGNAL(pressed()),this,SLOT(jnk())); |
| 1132 |
fxle->keepiso = dialogMenu->addAction("Keep Map Iso Values Fixed", fxle, SLOT(keepIsoValues(bool ))); |
| 1133 |
fxle->keepiso->setCheckable(true); |
| 1134 |
fxle->keepiso->setChecked(fxle->keepIso->isChecked());//diffent CaSe ! |
| 1135 |
/*a=viewMenu->addAction(tr("Toggle MSAA"),chgl,SLOT(setMSAA(bool)),QKeySequence("F4")); |
| 1136 |
a->setCheckable(true); |
| 1137 |
a->setChecked(true);*/ |
| 1138 |
a=equivHighlighting=viewMenu->addAction("Highlight Symmetry Equivalents",this,SLOT(toggleEQHighlighting(bool))); |
| 1139 |
equivHighlighting->setCheckable(true); |
| 1140 |
equivHighlighting->setChecked(true); |
| 1141 |
a=togBackGr=viewMenu->addAction(tr("Toggle Background Gradient"), chgl, SLOT(setBGGradient(bool)), QKeySequence("F6")); |
| 1142 |
a->setCheckable(true); |
| 1143 |
a->setChecked(true); |
| 1144 |
viewMenu->addAction(dock->toggleViewAction()); |
| 1145 |
viewMenu->addAction(shxEditorDock->toggleViewAction()); |
| 1146 |
//viewMenu->addAction(chgl->wireButt); |
| 1147 |
viewMenu->addAction(chgl->rainbowPlot); |
| 1148 |
/*=togDepthCueing=viewMenu->addAction(tr("toggle DepthCueing (mist)"),chgl,SLOT(setDepthCueing(bool)), QKeySequence(Qt::ALT | Qt::Key_M));//=togDepthCueing |
| 1149 |
a->setCheckable(true); |
| 1150 |
a->setChecked(false);*/ |
| 1151 |
//printf("line %d\n",__LINE__); |
| 1152 |
viewMenu->addSeparator(); |
| 1153 |
ydleStart=viewMenu->addAction("Start rotation", this, SLOT(idleRotStart()), QKeySequence(Qt::ALT | Qt::Key_Y)); |
| 1154 |
ydleStop=viewMenu->addAction("Stop rotation", this, SLOT(idleRotStop()), QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Space)); |
| 1155 |
ydleStop->setVisible(false); |
| 1156 |
|
| 1157 |
QAction *moviMaker = viewMenu->addAction("Create a Rotation Movie", this,SLOT(makeRotMovi())); |
| 1158 |
moviMaker->setShortcut(Qt::CTRL | Qt::Key_M); |
| 1159 |
|
| 1160 |
viewMenu->addSeparator(); |
| 1161 |
viewMenu->addAction("Redraw Structure", this, SLOT(effuenf()), QKeySequence("F5")); |
| 1162 |
viewMenu->addAction("Reload Structure From Current File", this,SLOT(loadAFile()), QKeySequence("Ctrl+F5")); |
| 1163 |
{ |
| 1164 |
QAction *a= |
| 1165 |
viewMenu->addAction("Create Voronoi Polyeders of Asymmetric Unit",this,SLOT(makeVoro())); |
| 1166 |
a->setData(-1); |
| 1167 |
} |
| 1168 |
{ |
| 1169 |
QAction *a=clearVoro= |
| 1170 |
viewMenu->addAction("Remove Voronoi Polyeder(s) ",this,SLOT(clearVoros())); |
| 1171 |
a->setData(-1); |
| 1172 |
clearVoro->setVisible(false); |
| 1173 |
} |
| 1174 |
//viewMenu->addAction("hide me!",this, SLOT(hide()),QKeySequence("F12")); |
| 1175 |
//viewMenu->addAction("show must go on!",this, SLOT(show()),QKeySequence("F10")); |
| 1176 |
|
| 1177 |
if (!QString(PROGRAM_NAME).compare("shelXle"))//olny in standalone shelXle |
| 1178 |
viewMenu->addAction("Fullscreen Mode", this, SLOT(toggleFullScreen()), QKeySequence("F11")); |
| 1179 |
|
| 1180 |
} |
| 1181 |
{ |
| 1182 |
QAction *a; |
| 1183 |
QToolBar *tb=bottomToolBar= new QToolBar("Atom Selection Tools",this); |
| 1184 |
tb->setObjectName("AtomTB"); |
| 1185 |
tb->setMovable(false); |
| 1186 |
tb->setAllowedAreas(Qt::BottomToolBarArea|Qt::TopToolBarArea); |
| 1187 |
tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
| 1188 |
QMenu *m= new QMenu("Configure selection toolbar"); |
| 1189 |
a=m->addAction("Text Only",this,SLOT(configureBottomToolbar())); |
| 1190 |
a->setData(Qt::ToolButtonTextOnly); |
| 1191 |
a=m->addAction("Icon Only",this,SLOT(configureBottomToolbar())); |
| 1192 |
a->setData(Qt::ToolButtonIconOnly); |
| 1193 |
a=m->addAction("Text Beside Icon",this,SLOT(configureBottomToolbar())); |
| 1194 |
a->setData(Qt::ToolButtonTextBesideIcon); |
| 1195 |
a=m->addAction("Text Under Icon",this,SLOT(configureBottomToolbar())); |
| 1196 |
a->setData(Qt::ToolButtonTextUnderIcon); |
| 1197 |
m->addSeparator(); |
| 1198 |
a=m->addAction("Place on Top",this,SLOT(configureBottomToolbar())); |
| 1199 |
a->setData(static_cast<int>(Qt::TopToolBarArea) + 32); |
| 1200 |
a=m->addAction("Place on Bottom",this,SLOT(configureBottomToolbar())); |
| 1201 |
a->setData(static_cast<int>(Qt::BottomToolBarArea) + 32); |
| 1202 |
useNativeDlg=dialogMenu->addAction("Use Native Dialog for File Open/Save",this,SLOT(fileNative())); |
| 1203 |
useNativeDlg->setCheckable(true); |
| 1204 |
useNativeDlg->setChecked(true); |
| 1205 |
|
| 1206 |
darkTheme=dialogMenu->addAction("Use Dark Colors Theme",this,SLOT(darkEdit())); |
| 1207 |
darkTheme->setCheckable(true); |
| 1208 |
darkTheme->setChecked(false); |
| 1209 |
if (QString(PROGRAM_NAME).compare("shelXle")){ |
| 1210 |
darkTheme->setVisible(false); |
| 1211 |
} |
| 1212 |
|
| 1213 |
a=dialogMenu->addAction(QIcon(theIconPath+"configure-toolbars.svg"),"Configure Selection Toolbar"); |
| 1214 |
a->setToolTip("Configure Selection Toolbar icon/text style"); |
| 1215 |
a->setMenu(m); |
| 1216 |
chgl->toggleDockWidgets= a = tb->addAction(QIcon(theIconPath+"hidedockwdg.svg"), "Hide Text Windows",this,SLOT(toggDocWid(bool))); |
| 1217 |
a->setCheckable(true); |
| 1218 |
a->setChecked(false); |
| 1219 |
a->setVisible(false); |
| 1220 |
chgl->toggleOrthoView = a = tb->addAction(QIcon(theIconPath+"ortho.svg"), "Ortho-projection",this,SLOT(toggleOrtho(bool))); |
| 1221 |
a->setCheckable(true); |
| 1222 |
a->setChecked(false); |
| 1223 |
a->setToolTip("toggle Orthographic Projection / Central Perspective Projection"); |
| 1224 |
chgl->grow=a=tb->addAction(QIcon(theIconPath+"grow.svg"),"GROW ",this,SLOT(grow())); |
| 1225 |
a->setShortcut(Qt::ALT | Qt::Key_G); |
| 1226 |
packMenu->addAction(a); |
| 1227 |
a->setToolTip("Complete the Molecule(s)"); |
| 1228 |
a->setVisible(false); |
| 1229 |
chgl->fuse=a=tb->addAction(QIcon(theIconPath+"fuse.svg"),"FUSE ",this,SLOT(fuse())); |
| 1230 |
a->setShortcut(Qt::ALT | Qt::Key_F); |
| 1231 |
packMenu->addAction(a); |
| 1232 |
a->setVisible(false); |
| 1233 |
a->setToolTip("Show the Asymmetric Unit Only"); |
| 1234 |
recalcSDM=a=packMenu->addAction(QIcon(theIconPath+"grow.svg"),"Recalculate Distance Matrices",this,SLOT(sdm())); |
| 1235 |
recalcSDM->setShortcut(Qt::CTRL | Qt::Key_R); |
| 1236 |
QToolBar *sptb=new QToolBar(); |
| 1237 |
sptb->addAction(recalcSDM); |
| 1238 |
renamUpdateAct=sptb->addAction("Update RESIdue Class ComboBox",this,SLOT(renamUpdate(bool))); |
| 1239 |
renamUpdateAct->setCheckable(true); |
| 1240 |
renamUpdateAct->setChecked(false); |
| 1241 |
chgl->pickRadSpin=new QDoubleSpinBox(sptb); |
| 1242 |
chgl->pickRadSpin->setMinimum(5.0); |
| 1243 |
chgl->pickRadSpin->setMaximum(50.0); |
| 1244 |
chgl->pickRadSpin->setDecimals(0); |
| 1245 |
chgl->pickRadSpin->setValue(chgl->pickRad()); |
| 1246 |
chgl->pickRadSpin->setPrefix("pick radius"); |
| 1247 |
chgl->pickRadSpin->setSuffix("px"); |
| 1248 |
connect(chgl->pickRadSpin,SIGNAL(valueChanged(double)),chgl,SLOT(setPickRad(double))); |
| 1249 |
sptb->addWidget(chgl->pickRadSpin); |
| 1250 |
rnla->addWidget(sptb); |
| 1251 |
a=packMenu->addAction("Symmetry Manager",this,SLOT(symmetryManager())); |
| 1252 |
a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_M); |
| 1253 |
tb->addAction(enterRenameMode); |
| 1254 |
enterRenameMode->setIcon(QIcon(theIconPath+"rename.svg")); |
| 1255 |
enterRenameMode->setVisible(false); |
| 1256 |
tb->addAction(showQPeakLegend); |
| 1257 |
showQPeakLegend->setVisible(false); |
| 1258 |
//printf("line %d\n",__LINE__); |
| 1259 |
a=tb->addAction(QIcon(theIconPath+"qbond.svg"),"Q-Peak-Bonds",chgl,SLOT(update())); |
| 1260 |
a->setCheckable(true); |
| 1261 |
a->setChecked(true); |
| 1262 |
a->setVisible(false); |
| 1263 |
chgl->qPeakBonds=a; |
| 1264 |
sinaAct->setVisible(false); |
| 1265 |
chgl->addBond=a=tb->addAction(QIcon(theIconPath+"bind.svg"),"Bind Selected Atoms",editor,SLOT(insertBind())); |
| 1266 |
a->setVisible(false); |
| 1267 |
chgl->killBond=a=tb->addAction(QIcon(theIconPath+"free.svg"),"Free Selected Atoms",editor,SLOT(insertFree())); |
| 1268 |
a->setVisible(false); |
| 1269 |
chgl->clearSelection=a=tb->addAction(QIcon(theIconPath+"deselect.svg"),"Deselect",chgl,SLOT(disSelection())); |
| 1270 |
a->setVisible(false); |
| 1271 |
chgl->centroid=a=tb->addAction(QIcon(theIconPath+"centroid.svg"), "Create Centroid", this , SLOT(createCentroid())); |
| 1272 |
a->setVisible(false); |
| 1273 |
chgl->cntrPlot = a = tb->addAction(QIcon(theIconPath+"cont.svg"),"Create Contour Plot",this, SLOT(contourPlot())); |
| 1274 |
a->setVisible(false); |
| 1275 |
chgl->nocntrPlot = a = tb->addAction(QIcon(theIconPath+"nocont.svg"),"Remove Contour Plot",this, SLOT(nocontourPlot())); |
| 1276 |
a->setVisible(false); |
| 1277 |
chgl->centerSelection=a=tb->addAction(QIcon(theIconPath+"center.svg"),"Center Selected Atoms",chgl,SLOT(homeXY())); |
| 1278 |
a->setCheckable(true); |
| 1279 |
a->setChecked(false); |
| 1280 |
a->setVisible(false); |
| 1281 |
chgl->invSelection=a=tb->addAction(QIcon(theIconPath+"invsel.svg"),"Invert Selection",chgl,SLOT(invertSelection())); |
| 1282 |
a->setVisible(false); |
| 1283 |
chgl->hideNotSelection=a=tb->addAction(QIcon(theIconPath+"hide.svg"),"Hide Other Atoms",chgl,SLOT(hideNonSelected())); |
| 1284 |
a->setVisible(false); |
| 1285 |
a=chgl->hideHydrogen=tb->addAction(QIcon(theIconPath+"hideh.svg"),"Hide Hydrogen Atoms",chgl,SLOT(hideHydrogens())); |
| 1286 |
a->setVisible(false); |
| 1287 |
chgl->unhide=a=tb->addAction(QIcon(theIconPath+"show.svg"),"Show All Hidden",chgl,SLOT(showHidden())); |
| 1288 |
connect(a,SIGNAL(triggered()),qpv,SLOT(unhide())); |
| 1289 |
a->setVisible(false); |
| 1290 |
chgl->invhide=a=tb->addAction(QIcon(theIconPath+"invshow.svg"),"Toggle Visibility ",chgl,SLOT(invertHidden())); |
| 1291 |
a->setVisible(false); |
| 1292 |
chgl->shpm1=a=tb->addAction(QIcon(theIconPath+"part-1.svg"),"Hide PART -N Ghost",chgl,SLOT(hidePartMinusOne(bool ))); |
| 1293 |
a->setCheckable(true); |
| 1294 |
a->setChecked(false); |
| 1295 |
a->setVisible(false); |
| 1296 |
a->setToolTip("Hide PART -N symmetry equivalent as ghost Atoms"); |
| 1297 |
//printf("line %d\n",__LINE__); |
| 1298 |
|
| 1299 |
chgl->highlightParts=a=tb->addAction(QIcon(theIconPath+"parts.svg"),"Highlight PARTs",chgl,SLOT(update())); |
| 1300 |
a->setCheckable(true); |
| 1301 |
a->setChecked(false); |
| 1302 |
a->setVisible(false); |
| 1303 |
a=chgl->delSelAt = tb->addAction(QIcon(theIconPath+"killselected.svg"),"Delete Selected Atoms",this,SLOT(deleteSelectedAtoms())); |
| 1304 |
a->setData(-1); |
| 1305 |
a->setShortcut(Qt::CTRL|Qt::Key_Delete); |
| 1306 |
a->setVisible(false); |
| 1307 |
addToolBarBreak(); |
| 1308 |
addToolBar(Qt::TopToolBarArea,tb); |
| 1309 |
} |
| 1310 |
{ |
| 1311 |
QAction *a; |
| 1312 |
a=packMenu->addAction("Pack cell",this,SLOT(fillCell())); |
| 1313 |
a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_U); |
| 1314 |
a=packMenu->addAction("Expand all contacts",this,SLOT(expandAll())); |
| 1315 |
a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_X); |
| 1316 |
//a=packMenu->addAction("Complete asymmetric unit" ,this,SLOT(grow_plus())); |
| 1317 |
a=packMenu->addAction("Complete" ,this,SLOT(complete())); |
| 1318 |
a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_C); |
| 1319 |
a=packMenu->addAction("Pack inside given limits",this,SLOT(packInLimits())); |
| 1320 |
a->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_I); |
| 1321 |
} |
| 1322 |
menuBar()->addMenu(fileMenu); |
| 1323 |
menuBar()->addMenu(editMenu); |
| 1324 |
menuBar()->addMenu(dialogMenu); |
| 1325 |
menuBar()->addMenu(viewMenu); |
| 1326 |
menuBar()->addMenu(packMenu); |
| 1327 |
menuBar()->addMenu(runMenu); |
| 1328 |
menuBar()->addMenu(extraMenu); |
| 1329 |
fcvsfoAct=fcoMenu->addAction("Fc vs Fo",this,SLOT(foversusfc())); |
| 1330 |
fcvsfoAct->setDisabled(true); |
| 1331 |
calcAct=fcoMenu->addAction("Crystallographic Calculator",this,SLOT(calculator())); |
| 1332 |
calcAct->setEnabled(true); |
| 1333 |
fcoMenu->addAction("Fractal Dimension Analysis (Henn-Meindl-plot)",this,SLOT(jnk())); |
| 1334 |
fcoMenu->addAction("Plot Atomic Scattering Factors SFAC ", editor, SLOT(plotSFAC())); |
| 1335 |
dsrAct = fcoMenu->addAction("DSR Plugin",this,SLOT(create_DSRGui())); |
| 1336 |
dsrAct->setEnabled(true); |
| 1337 |
dsrAct->setShortcut(Qt::ALT | Qt::Key_D); |
| 1338 |
menuBar()->addMenu(fcoMenu); |
| 1339 |
//printf("line %d\n",__LINE__); |
| 1340 |
|
| 1341 |
|
| 1342 |
{ |
| 1343 |
helpMenu = new QMenu(tr("Help"), this); |
| 1344 |
menuBar()->addMenu(helpMenu); |
| 1345 |
helpMenu->addAction("Help ", this, SLOT(linkHelp())); |
| 1346 |
helpMenu->addAction(QWhatsThis::createAction(this)); |
| 1347 |
helpMenu->addAction(tr("About"), this, SLOT(aboutXLE())); |
| 1348 |
helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); |
| •1349 |
//helpMenu->addAction("Check for New Versions Now",this,SLOT(checkForUpdates())); |
| 1350 |
helpMenu->addAction("Show Key Bindings", this, SLOT(hereAreMyKeys())); |
| 1351 |
} |
| 1352 |
|
| 1353 |
chgl->rCenter = new QToolButton(); |
| 1354 |
chgl->rCenter->setText("Reset Rotation Center"); |
| 1355 |
connect(chgl->rCenter,SIGNAL(clicked()), chgl,SLOT( rotCenter())); |
| 1356 |
chgl->rCenter->hide(); |
| 1357 |
|
| 1358 |
chgl->invertMouseZoom = new QToolButton(this); |
| 1359 |
chgl->invertMouseZoom->setIcon(QIcon(theIconPath+"invzoom.svg")); |
| 1360 |
chgl->invertMouseZoom->setCheckable(true); |
| 1361 |
chgl->invertMouseZoom->setChecked(false); |
| 1362 |
chgl->invertMouseZoom->setText("Invert Mouse Zoom"); |
| 1363 |
chgl->invertMouseZoom->setToolTip("invert mouse zoom (right mouse click and drag up or down"); |
| 1364 |
|
| 1365 |
//* |
| 1366 |
quickReLoadButton = new QToolButton(this); |
| 1367 |
QIcon qrlic =QIcon(); |
| 1368 |
qrlic.addFile(theIconPath+"quick-re-load.png",QSize(), QIcon::Normal, QIcon::Off ); |
| 1369 |
qrlic.addFile(theIconPath+"quick-re-load_on.png",QSize(), QIcon::Normal, QIcon::On ); |
| 1370 |
quickReLoadButton->setIcon(qrlic); |
| 1371 |
quickReLoadButton->setCheckable(true); |
| 1372 |
//Too many problems with this feature 11.03.2021 |
| 1373 |
quickReLoadButton->setChecked(false); |
| 1374 |
quickReLoadButton->hide(); |
| 1375 |
quickReLoadButton->setText("Enable QuickReLoad"); |
| 1376 |
quickReLoadButton->setToolTip("QuickReLoad updates the structure instead of fresh reloading it"); |
| 1377 |
//*/ |
| 1378 |
homeMe = new QToolButton(this); |
| 1379 |
homeMe->setIcon(QIcon(theIconPath+"home.svg")); |
| 1380 |
homeMe->setText("home"); |
| 1381 |
homeMe->setToolTip("move molecules home"); |
| 1382 |
connect(homeMe,SIGNAL(clicked()),chgl,SLOT(homeXY())); |
| 1383 |
qGrowPeak = new QCheckBox("grow Q-peaks"); |
| 1384 |
connect(qGrowPeak,SIGNAL(toggled(bool)),this,SLOT(growQPeaks(bool))); |
| 1385 |
search4duplicates = new QCheckBox("search for duplicates"); |
| 1386 |
search4duplicates->setChecked(true); |
| 1387 |
connect(search4duplicates,SIGNAL(toggled(bool)),this,SLOT(duplicates())); |
| 1388 |
//printf("line %d\n",__LINE__); |
| 1389 |
|
| 1390 |
sLabel = new QLabel; |
| 1391 |
sLabel->setFrameStyle(QFrame::Panel ); |
| 1392 |
sLabel->setLineWidth(2); |
| 1393 |
sLabel->setText(QString("%1").arg(PROGRAM_NAME)); |
| 1394 |
zoomIn = new QToolButton (this); |
| 1395 |
zoomIn-> setIcon(QIcon(theIconPath+"zoom-in.svg")); |
| 1396 |
zoomIn->setText("Zoom +"); |
| 1397 |
zoomIn->setToolTip("Zoom +"); |
| 1398 |
zoomIn->setAutoRepeat(true); |
| 1399 |
zoomIn->setAutoRepeatDelay(150); |
| 1400 |
zoomIn->setAutoRepeatInterval(3); |
| 1401 |
zoomOut = new QToolButton(this); |
| 1402 |
zoomOut->setIcon(QIcon(theIconPath+"zoom-out.svg")); |
| 1403 |
zoomOut->setText("Zoom -"); |
| 1404 |
zoomOut->setToolTip("Zoom -"); |
| 1405 |
zoomOut->setAutoRepeat(true); |
| 1406 |
zoomOut->setAutoRepeatDelay(150); |
| 1407 |
zoomOut->setAutoRepeatInterval(3); |
| 1408 |
connect(zoomIn,SIGNAL(pressed ()),this,SLOT(zoomin())); |
| 1409 |
connect(zoomOut,SIGNAL(pressed ()),this,SLOT(zoomout())); |
| 1410 |
//connect(chgl,SIGNAL(no_hw_st()),no_stereo,SLOT(toggle())); |
| 1411 |
fvused = new QLabel(""); |
| 1412 |
|
| 1413 |
QCheckBox *autoupdate = new QCheckBox("?FPS?"); |
| 1414 |
autoupdate->setChecked(false); |
| 1415 |
connect(autoupdate, &QCheckBox::stateChanged, chgl, &PlayOpenGL::toggleAutoUpdate); |
| 1416 |
|
| 1417 |
lodsp = new QSpinBox(); |
| 1418 |
lodsp->setPrefix("LOD = "); |
| 1419 |
lodsp->setRange(2, 8); |
| 1420 |
lodsp->setValue(chgl->mol->LOD); |
| 1421 |
#if (QT_VERSION >= 0x050f10) |
| 1422 |
connect(lodsp, &QSpinBox::valueChanged, chgl, &PlayOpenGL::setLOD); |
| 1423 |
#else |
| 1424 |
connect(lodsp, SIGNAL(valueChanged(int)), chgl, SLOT(setLOD(int))); |
| 1425 |
#endif |
| 1426 |
|
| 1427 |
statusBar(); |
| 1428 |
statusBar()->addPermanentWidget(fvused); |
| 1429 |
statusBar()->addPermanentWidget(autoupdate); |
| 1430 |
statusBar()->addPermanentWidget(lodsp); |
| 1431 |
//statusBar()->addPermanentWidget(chgl->pickRadSpin); |
| 1432 |
statusBar()->addPermanentWidget(chgl->rCenter); |
| 1433 |
statusBar()->addPermanentWidget(chgl->enviButt); |
| 1434 |
statusBar()->addPermanentWidget(chgl->enviSelect); |
| 1435 |
statusBar()->addPermanentWidget(qGrowPeak); |
| 1436 |
statusBar()->addPermanentWidget(search4duplicates); |
| 1437 |
statusBar()->addPermanentWidget(zoomIn); |
| 1438 |
statusBar()->addPermanentWidget(zoomOut); |
| 1439 |
statusBar()->addPermanentWidget(homeMe); |
| 1440 |
statusBar()->addPermanentWidget(chgl->invertMouseZoom); |
| 1441 |
statusBar()->addPermanentWidget(quickReLoadButton); |
| 1442 |
statusBar()->addPermanentWidget(fxle->keepIso); |
| 1443 |
statusBar()->addPermanentWidget(fxle->doMaps); |
| 1444 |
statusBar()->addPermanentWidget(fxle->ownfcf6); |
| 1445 |
QCheckBox *hideToolBars = new QCheckBox("Hide Tool Bars"); |
| 1446 |
hideToolBars->setChecked(false); |
| 1447 |
connect(hideToolBars,SIGNAL(toggled(bool)),this,SLOT(hideToolz(bool))); |
| 1448 |
statusBar()->addPermanentWidget(hideToolBars); |
| 1449 |
statusBar()->addPermanentWidget(sLabel); |
| 1450 |
connect(fxle,SIGNAL(bigmessage(const QString&)),this,SLOT(infoKanalNews(const QString&))); |
| 1451 |
shxEditorDock->hide(); |
| 1452 |
printf("now settings\n"); |
| 1453 |
////////////////////////////// SETTINGS ///////////////////////////////////////////////////////////////////////// |
| 1454 |
|
| 1455 |
mole.loadSettings(); |
| 1456 |
einstellung->beginGroup("Window"); |
| 1457 |
useNativeDlg->setChecked(einstellung->value("nativeDialogs",true).toBool()); |
| 1458 |
chgl->invertMouseZoom->setChecked( einstellung->value("InvertMouseZoom").toBool()); |
| 1459 |
//Too many issues with this feature 11.03.2021 |
| 1460 |
//quickReLoadButton->setChecked( einstellung->value("QuickReLoad",true).toBool()); |
| 1461 |
//connect(quickReLoadButton, SIGNAL(toggled(bool)), this, SLOT(loadAFile())); |
| 1462 |
bool bbb=true; |
| 1463 |
chgl->SDM_Limit=einstellung->value("SDM-LIMIT", 350).toInt(); |
| 1464 |
if (einstellung->contains("HighlightEquivalents")){ |
| 1465 |
bool bb; |
| 1466 |
equivHighlighting->setChecked(bb=einstellung->value("HighlightEquivalents").toBool()); |
| 1467 |
mole.highlightEquivalents=bb; |
| 1468 |
} |
| 1469 |
//printf("line %d\n",__LINE__); |
| 1470 |
if (einstellung->contains("ADPs")) |
| 1471 |
chgl->adp->setChecked(bbb=einstellung->value("ADPs").toBool()); |
| 1472 |
if (einstellung->contains("Tubes")) |
| 1473 |
chgl->tubes->setChecked(bbb=einstellung->value("Tubes").toBool()); |
| 1474 |
if (einstellung->contains("Legend")) |
| 1475 |
chgl->atomLegend->setChecked(einstellung->value("Legend").toBool()); |
| 1476 |
if (einstellung->contains("ShowLabels")) |
| 1477 |
togLabel->setChecked(bbb=einstellung->value("ShowLabels").toBool()); |
| 1478 |
chgl->setLabels(togLabel->isChecked()); |
| 1479 |
|
| 1480 |
//printf("line %d\n",__LINE__); |
| 1481 |
if (einstellung->contains("ShortLabels")) |
| 1482 |
chgl->shortLabels->setChecked(bbb=einstellung->value("ShortLabels").toBool()); |
| 1483 |
if (einstellung->contains("BackGroundGradient")) |
| 1484 |
togBackGr->setChecked(bbb=einstellung->value("BackGroundGradient").toBool()); |
| 1485 |
chgl->setBGGradient(togBackGr->isChecked()); |
| 1486 |
/* |
| 1487 |
if (einstellung->contains("WireModelOnRotate")) |
| 1488 |
chgl->wireButt->setChecked(einstellung->value("WireModelOnRotate").toBool()); |
| 1489 |
*/ |
| 1490 |
shelxlPath="shelxl"; |
| 1491 |
if (einstellung->contains("SHELXL-PATH")) |
| 1492 |
shelxlPath=einstellung->value("SHELXL-PATH").toString(); |
| 1493 |
shelxlArgs=""; |
| 1494 |
if (einstellung->contains("SHELXL-OPTION")) |
| 1495 |
shelxlArgs=einstellung->value("SHELXL-OPTION").toString(); |
| 1496 |
useMyBArray = false; // If true, ShelXle does not override b-array value |
| 1497 |
if (einstellung->contains("SHELXL-BARRAY")) { |
| 1498 |
useMyBArray=einstellung->value("SHELXL-BARRAY").toBool(); |
| 1499 |
} |
| 1500 |
einstellung->endGroup(); |
| 1501 |
|
| 1502 |
//printf("line %d\n",__LINE__); |
| 1503 |
einstellung->beginGroup("Files"); |
| 1504 |
dirName = einstellung->value("lastFile").toString(); |
| 1505 |
|
| 1506 |
QStringList files = einstellung->value("recentFileList").toStringList(); |
| 1507 |
foreach (QWidget *widget, QApplication::topLevelWidgets()) { |
| 1508 |
Window *mainWin = qobject_cast<Window *>(widget); |
| 1509 |
if (mainWin) |
| 1510 |
mainWin->updateRecentFileActions(); |
| 1511 |
} |
| 1512 |
|
| 1513 |
einstellung->endGroup(); |
| 1514 |
einstellung->beginGroup("Colors"); |
| 1515 |
chgl->backGroundColor=einstellung->value("BackGroundColor",QColor("lightskyblue")).value<QColor>(); |
| 1516 |
chgl->labelColor=einstellung->value("LabelColor").value<QColor>(); |
| 1517 |
chgl->labelBGColor = einstellung->value("LabelBGColor", QColor(0,0,0,0)).value<QColor>(); |
| 1518 |
chgl->focusedLabelBGColor = einstellung->value("focusedLabelBGColor", QColor(0,0,0,10)).value<QColor>(); |
| 1519 |
chgl->focusedLabelColor = einstellung->value("focusedLabelColor", QColor(255,255,0,255)).value<QColor>(); |
| 1520 |
chgl->selectedLabelBGColor = einstellung->value("selectedLabelBGColor", QColor(0,0,0,51)).value<QColor>(); |
| 1521 |
chgl->selectedLabelColor = einstellung->value("selectedLabelColor", QColor(135, 206, 235 ,255)).value<QColor>(); |
| 1522 |
/*printf("alphas %x %x %x %x %x %X", |
| 1523 |
chgl->labelBGColor.alpha(), |
| 1524 |
chgl->focusedLabelBGColor.alpha(), |
| 1525 |
chgl->selectedLabelBGColor.alpha(), |
| 1526 |
chgl->selectedLabelColor.alpha(), |
| 1527 |
chgl->focusedLabelColor.alpha(), |
| 1528 |
QColor(0u).alpha());*/ |
| 1529 |
if (QString(PROGRAM_NAME).compare("shelXle")==0){ |
| 1530 |
darkTheme->setChecked(einstellung->value("darkTheme","false").toBool()); |
| 1531 |
} |
| 1532 |
darkEdit(); |
| 1533 |
einstellung->endGroup(); |
| •1534 |
int ignore=QMessageBox::No; |
| 1535 |
einstellung->beginGroup("Updates"); |
| 1536 |
if (einstellung->contains("IgnoreUpdates")) |
| 1537 |
ignore=einstellung->value("IgnoreUpdates").toInt(); |
| 1538 |
einstellung->endGroup(); |
| 1539 |
net = new QNetworkAccessManager(this); |
| 1540 |
if (ignore!=QMessageBox::No){ |
| •1541 |
checkForUpdates(); |
| 1542 |
//connect(net, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); |
| 1543 |
//reply = net->get(QNetworkRequest(QUrl("http://shelxle.org/shelx/revision.php"))); |
| 1544 |
} |
| 1545 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1546 |
|
| 1547 |
|
| 1548 |
extraProgramNames.clear(); |
| 1549 |
extraProgramPaths.clear(); |
| 1550 |
extraArguments.clear(); |
| 1551 |
extraExtensions.clear(); |
| 1552 |
extraResIns.clear(); |
| 1553 |
extraOpenFileDialogBefore.clear(); |
| 1554 |
extraIconOverlay.clear(); |
| 1555 |
extraOverlayPointSize.clear(); |
| 1556 |
einstellung->beginGroup("Extra"); |
| 1557 |
int siz=0; |
| 1558 |
siz=einstellung->beginReadArray("ProgramNames"); |
| 1559 |
for (int i = 0; i < siz; i++) { |
| 1560 |
einstellung->setArrayIndex(i); |
| 1561 |
extraProgramNames.append(einstellung->value("Name","").toString()); |
| 1562 |
} |
| 1563 |
einstellung->endArray(); |
| 1564 |
einstellung->endGroup(); |
| 1565 |
|
| 1566 |
einstellung->beginGroup("Extra"); |
| 1567 |
einstellung->beginReadArray("ProgramPaths"); |
| 1568 |
for (int i = 0; i < siz; i++) { |
| 1569 |
einstellung->setArrayIndex(i); |
| 1570 |
extraProgramPaths.append(einstellung->value("Path","").toString()); |
| 1571 |
} |
| 1572 |
einstellung->endArray(); |
| 1573 |
einstellung->endGroup(); |
| 1574 |
|
| 1575 |
einstellung->beginGroup("Extra"); |
| 1576 |
einstellung->beginReadArray("ProgramArgs"); |
| 1577 |
for (int i = 0; i < siz; i++) { |
| 1578 |
einstellung->setArrayIndex(i); |
| 1579 |
extraArguments.append((Qt::CheckState) einstellung->value("Arg").toInt()); |
| 1580 |
} |
| 1581 |
einstellung->endArray(); |
| 1582 |
einstellung->endGroup(); |
| 1583 |
|
| 1584 |
einstellung->beginGroup("Extra"); |
| 1585 |
einstellung->beginReadArray("ProgramExtensions"); |
| 1586 |
for (int i = 0; i < siz; i++) { |
| 1587 |
einstellung->setArrayIndex(i); |
| 1588 |
extraExtensions.append((Qt::CheckState)einstellung->value("Ext",0).toInt()); |
| 1589 |
} |
| 1590 |
einstellung->endArray(); |
| 1591 |
einstellung->endGroup(); |
| 1592 |
|
| 1593 |
einstellung->beginGroup("Extra"); |
| 1594 |
einstellung->beginReadArray("ProgramResIns"); |
| 1595 |
for (int i = 0; i < siz; i++) { |
| 1596 |
einstellung->setArrayIndex(i); |
| 1597 |
extraResIns.append((Qt::CheckState)einstellung->value("Res2Ins",0).toInt()); |
| 1598 |
} |
| 1599 |
einstellung->endArray(); |
| 1600 |
einstellung->endGroup(); |
| 1601 |
|
| 1602 |
|
| 1603 |
einstellung->beginGroup("Extra"); |
| 1604 |
einstellung->beginReadArray("FileDialog"); |
| 1605 |
for (int i = 0; i < siz; i++) { |
| 1606 |
einstellung->setArrayIndex(i); |
| 1607 |
extraOpenFileDialogBefore.append((Qt::CheckState)einstellung->value("fd",0).toInt()); |
| 1608 |
} |
| 1609 |
einstellung->endArray(); |
| 1610 |
einstellung->endGroup(); |
| 1611 |
|
| 1612 |
|
| 1613 |
einstellung->beginGroup("Extra"); |
| 1614 |
einstellung->beginReadArray("IconOverlay"); |
| 1615 |
for (int i = 0; i < siz; i++) { |
| 1616 |
einstellung->setArrayIndex(i); |
| 1617 |
extraIconOverlay.append((Qt::CheckState)einstellung->value("icov",2).toInt()); |
| 1618 |
} |
| 1619 |
einstellung->endArray(); |
| 1620 |
einstellung->endGroup(); |
| 1621 |
|
| 1622 |
einstellung->beginGroup("Extra"); |
| 1623 |
einstellung->beginReadArray("OverlayPointSize"); |
| 1624 |
for (int i = 0; i < siz; i++) { |
| 1625 |
einstellung->setArrayIndex(i); |
| 1626 |
extraOverlayPointSize.append(einstellung->value("icov",36).toInt()); |
| 1627 |
} |
| 1628 |
einstellung->endArray(); |
| 1629 |
einstellung->endGroup(); |
| 1630 |
|
| 1631 |
einstellung->beginGroup("Extra"); |
| 1632 |
einstellung->beginReadArray("AltExtraIconPaths"); |
| 1633 |
for (int i = 0; i < siz; i++) { |
| 1634 |
einstellung->setArrayIndex(i); |
| 1635 |
altExtraIconPaths.append(einstellung->value("altIcon","").toString()); |
| 1636 |
} |
| 1637 |
einstellung->endArray(); |
| 1638 |
einstellung->endGroup(); |
| 1639 |
|
| 1640 |
einstellung->beginGroup("Extra"); |
| 1641 |
einstellung->beginReadArray("ProgramDetached"); |
| 1642 |
for (int i = 0; i < siz; i++) { |
| 1643 |
einstellung->setArrayIndex(i); |
| 1644 |
extraDetach.append((Qt::CheckState)einstellung->value("Detach",0).toInt()); |
| 1645 |
} |
| 1646 |
einstellung->endArray(); |
| 1647 |
einstellung->endGroup(); |
| 1648 |
|
| 1649 |
einstellung->beginGroup("Extra"); |
| 1650 |
einstellung->beginReadArray("AlternativeExtensions"); |
| 1651 |
for (int i = 0; i < siz; i++) { |
| 1652 |
einstellung->setArrayIndex(i); |
| 1653 |
extraExt2.append(einstellung->value("ext","").toString()); |
| 1654 |
} |
| 1655 |
einstellung->endArray(); |
| 1656 |
einstellung->endGroup(); |
| 1657 |
|
| 1658 |
einstellung->beginGroup("Extra"); |
| 1659 |
einstellung->beginReadArray("CommandLineOptions"); |
| 1660 |
for (int i = 0; i < siz; i++) { |
| 1661 |
einstellung->setArrayIndex(i); |
| 1662 |
extraOptions.append(einstellung->value("opt","").toString()); |
| 1663 |
} |
| 1664 |
einstellung->endArray(); |
| 1665 |
einstellung->endGroup(); |
| 1666 |
|
| 1667 |
|
| 1668 |
einstellung->beginGroup("Extra"); |
| 1669 |
einstellung->beginReadArray("AbsolutePathRequired"); |
| 1670 |
for (int i = 0; i < siz; i++) { |
| 1671 |
einstellung->setArrayIndex(i); |
| 1672 |
extraAbsolutePath.append(static_cast<Qt::CheckState>(einstellung->value("absolute",0).toInt())); |
| 1673 |
} |
| 1674 |
einstellung->endArray(); |
| 1675 |
einstellung->endGroup(); |
| 1676 |
|
| 1677 |
/* |
| 1678 |
einstellung->beginGroup("SaveHint"); |
| 1679 |
if (einstellung->contains("ShowRenameHint")) |
| 1680 |
hintL->setVisible(einstellung->value("ShowRenameHint").toBool()); |
| 1681 |
einstellung->endGroup(); |
| 1682 |
*/ |
| 1683 |
hintL->hide(); |
| 1684 |
{ |
| 1685 |
extraMenu->addAction("add or remove external programs",this,SLOT(extraSettings())); |
| 1686 |
} |
| 1687 |
if (extraProgramNames.size()) extraMenu->addSeparator(); |
| 1688 |
QFileIconProvider *epic = new QFileIconProvider(); |
| 1689 |
extraTB= new QToolBar("External Program Tool Bar",this); |
| 1690 |
extraTB->setObjectName("ExtraTB"); |
| 1691 |
extraTB->setToolButtonStyle(Qt::ToolButtonIconOnly); |
| 1692 |
for (int i=0; i<extraProgramNames.size(); i++){ |
| 1693 |
QAction *a; |
| 1694 |
QString icopa=extraProgramPaths.at(i); |
| 1695 |
QIcon ico = epic->icon(QFileInfo(icopa)); |
| 1696 |
//qDebug()<<ico.availableSizes()<<ico.actualSize(QSize(32,32)); |
| 1697 |
QPixmap fmap = ico.pixmap(32,32); |
| 1698 |
if (QFile::exists(altExtraIconPaths.at(i))) fmap=QIcon(altExtraIconPaths.at(i)).pixmap(64,64); |
| 1699 |
if (extraIconOverlay.at(i)==Qt::Checked){ |
| 1700 |
QPainter *paint = new QPainter(&fmap); |
| 1701 |
paint->setPen(QPen(QColor("#FFFFFF"))); |
| 1702 |
QFont ifont=chgl->myFont; |
| 1703 |
ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); |
| 1704 |
paint->setFont(ifont); |
| 1705 |
paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); |
| 1706 |
paint->setPen(QPen(QColor("#000000"))); |
| 1707 |
paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); |
| 1708 |
paint->end(); |
| 1709 |
} |
| 1710 |
extraIcon=QIcon(fmap); |
| 1711 |
a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); |
| 1712 |
a->setData(i); |
| 1713 |
extraTB->addAction(a); |
| 1714 |
} |
| 1715 |
delete epic; |
| 1716 |
addToolBar(extraTB); |
| 1717 |
extraOutput = new QDialog(this); |
| 1718 |
lt = new QVBoxLayout(); |
| 1719 |
extraOutPut = new QTextEdit(); |
| 1720 |
QFont mospfo(FONTFAM); |
| 1721 |
extraOutPut->setFont(mospfo); |
| 1722 |
#if (QT_VERSION >=0x050000) |
| 1723 |
extraOutput->setMinimumWidth( |
| 1724 |
QFontMetrics(extraOutPut->font()) |
| 1725 |
.horizontalAdvance("###########################################################################################")); |
| 1726 |
#else |
| 1727 |
extraOutput->setMinimumWidth( |
| 1728 |
QFontMetrics(extraOutPut->font()) |
| 1729 |
.width("###########################################################################################")); |
| 1730 |
#endif |
| 1731 |
extraOutPut->setLineWrapMode(QTextEdit::NoWrap); |
| 1732 |
lt->addWidget(extraOutPut); |
| 1733 |
extraOutput->setLayout(lt); |
| 1734 |
|
| 1735 |
#if defined (Q_OS_MAC) |
| 1736 |
//printf("%d\n",__LINE__); |
| 1737 |
setCentralWidget(container); |
| 1738 |
#else |
| 1739 |
setCentralWidget(chgl); |
| 1740 |
#endif |
| 1741 |
//chgl->setMSAA(true); |
| 1742 |
// chgl->update(); |
| 1743 |
//printf("%d\n",__LINE__); |
| 1744 |
einstellung->beginGroup("Window"); |
| 1745 |
bool EditorHasOwnToolBar = einstellung->value("EditorHasOwnToolBar",false).toBool(); |
| 1746 |
if (EditorHasOwnToolBar) shxMW->addToolBar(editToolBar); |
| 1747 |
else addToolBar(editToolBar); |
| 1748 |
adoptAct->setChecked(EditorHasOwnToolBar); |
| 1749 |
QByteArray ba,ba_state = einstellung->value("state").toByteArray(); |
| 1750 |
bool ba_state_ok = false; |
| 1751 |
if (!ba_state.isEmpty()) ba_state_ok = restoreState(ba_state); |
| 1752 |
printf("ba_state_ok ? %d \n",ba_state_ok); |
| 1753 |
QByteArray estate = einstellung->value("EditorState").toByteArray(); |
| 1754 |
if (!estate.isEmpty()) { |
| 1755 |
printf("<< %s %d\n",editor->font().family().toStdString().c_str(),editor->font().pointSize()); |
| 1756 |
shxMW->restoreState(estate); |
| 1757 |
printf(">> %s %d\n",editor->font().family().toStdString().c_str(),editor->font().pointSize()); |
| 1758 |
printf("state: %d\n", estate.size()); |
| 1759 |
//qDebug()<<estate; |
| 1760 |
} |
| 1761 |
ba=einstellung->value("geometry").toByteArray(); |
| 1762 |
//qDebug()<<ba.toHex()<<"##"<<ba_state.toHex(); |
| 1763 |
bool geook=false; |
| 1764 |
if (!ba.isEmpty()) geook=restoreGeometry(ba); |
| 1765 |
else { |
| 1766 |
QSize size ; |
| 1767 |
size=QSize(640,480); |
| 1768 |
ediSize=QSize(640,480); |
| 1769 |
ediPos=QPoint(0,0); |
| 1770 |
if ((size.height())<45||(size.width()<108)) size=QSize(640,480); |
| 1771 |
QPoint pos; |
| 1772 |
pos=QPoint(1,1); |
| 1773 |
move(pos); |
| 1774 |
if(size.isNull()) |
| 1775 |
resize(640, 480); |
| 1776 |
else |
| 1777 |
resize(size); |
| 1778 |
} |
| 1779 |
if (!geook){ |
| 1780 |
printf("Geometry in ini was not ok?\n"); |
| 1781 |
QSize size ; |
| 1782 |
#if (QT_VERSION >=0x050000) |
| 1783 |
size=QSize(screen->geometry().width()-2,screen->geometry().height()-2); |
| 1784 |
#else |
| 1785 |
size=QSize(QApplication::desktop()->screenGeometry().width()-2,QApplication::desktop()->screenGeometry().height()-2); |
| 1786 |
#endif |
| 1787 |
ediSize=QSize(640,480); |
| 1788 |
ediPos=QPoint(0,0); |
| 1789 |
if ((size.height())<45||(size.width()<108)) size=QSize(640,480); |
| 1790 |
QPoint pos; |
| 1791 |
pos=QPoint(1,1); |
| 1792 |
move(pos); |
| 1793 |
if(size.isNull()) |
| 1794 |
resize(640, 480); |
| 1795 |
else |
| 1796 |
resize(size); |
| 1797 |
} |
| 1798 |
einstellung->endGroup(); |
| 1799 |
//printf("%d\n",__LINE__); |
| 1800 |
|
| 1801 |
einstellung->beginGroup("Fonts"); |
| 1802 |
if (einstellung->contains("LabelFont")){ |
| 1803 |
chgl->myFont = einstellung->value("LabelFont").value<QFont>(); |
| 1804 |
chgl->myFont.setPointSize(einstellung->value("LabelFontSize", 24).toInt()); |
| 1805 |
} |
| 1806 |
if (einstellung->contains("EditorFont")){ |
| 1807 |
QFont fnt; |
| 1808 |
int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); |
| 1809 |
QString family = QFontDatabase::applicationFontFamilies(id).at(0); |
| 1810 |
fnt = QFont(family); |
| 1811 |
fnt = einstellung->value("EditorFont").value<QFont>(); |
| 1812 |
//editor->setFont(fnt); |
| 1813 |
//QFontInfo finfo(fnt); |
| 1814 |
/*if (!fnt.exactMatch()){ |
| 1815 |
printf("Font family; Point size; Pixel size; Style hint; Font weight; Font style; " |
| 1816 |
"Underline; Strike out; Fixed pitch; Always 0; Capitalization; Letter spacing; " |
| 1817 |
"Word spacing; Stretch; Style strategy; Font style (omitted when unavailable)\n"); |
| 1818 |
printf("Font: %s\nFont: %s\n", fnt.toString().toStdString().c_str(), editor->font().toString().toStdString().c_str()); |
| 1819 |
//qDebug()<<fnt.substitutions(); |
| 1820 |
int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); |
| 1821 |
QString family = QFontDatabase::applicationFontFamilies(id).at(0); |
| 1822 |
fnt = QFont(family); |
| 1823 |
printf("Font: %s\nFont: %s\n", fnt.toString().toStdString().c_str(), editor->font().toString().toStdString().c_str()); |
| 1824 |
|
| 1825 |
}else printf("font fits\n"); */ |
| 1826 |
int fosi = einstellung->value("EditorFontSize", 10).toInt(); |
| 1827 |
fnt.setPointSize(fosi); |
| 1828 |
//#if (QT_VERSION >= 0x040700) |
| 1829 |
// fnt.setStyleStrategy(QFont::ForceIntegerMetrics);//not a member anymore |
| 1830 |
//#endif |
| 1831 |
editor->setFont(fnt); |
| 1832 |
printf("Font: %s\nFont: %s\n", fnt.toString().toStdString().c_str(), editor->font().toString().toStdString().c_str()); |
| 1833 |
xlPutor->setFont(fnt); |
| 1834 |
printf("Font from settings %s %d\n", fnt.family().toStdString().c_str(),fnt.pointSize()); |
| 1835 |
} |
| 1836 |
einstellung->endGroup(); |
| 1837 |
|
| 1838 |
|
| 1839 |
einstellung->beginGroup("ToolBar"); |
| 1840 |
if (einstellung->contains("SelectionToolBarStyle")) |
| 1841 |
bottomToolBar->setToolButtonStyle((Qt::ToolButtonStyle) einstellung->value("SelectionToolBarStyle").toInt()); |
| 1842 |
einstellung->endGroup(); |
| 1843 |
einstellung->beginGroup("DoNotAskFileSave"); |
| 1844 |
if (einstellung->contains("DoNotAnnoyMe")) |
| 1845 |
doNotAnnoyMe=einstellung->value("DoNotAnnoyMe",false).toBool(); |
| 1846 |
einstellung->endGroup(); |
| 1847 |
einstellung->beginGroup("Sorting"); |
| 1848 |
if (einstellung->contains("SortingOption")){ |
| 1849 |
editor->sortierWeise = einstellung->value("SortingOption").toInt(); |
| 1850 |
} |
| 1851 |
einstellung->endGroup(); |
| 1852 |
//printf("%d\n",__LINE__); |
| 1853 |
|
| 1854 |
{ |
| 1855 |
sortGroup = new QActionGroup(this); |
| 1856 |
sortMenu = new QMenu("Change sort order",this); |
| 1857 |
QAction *a = sortMenu->addAction("label number > atomic number > label suffix"); |
| 1858 |
sortGroup->addAction(a); |
| 1859 |
a->setCheckable(true); |
| 1860 |
if (editor->sortierWeise==1)a->setChecked(true); |
| 1861 |
a->setData(1); |
| 1862 |
a = sortMenu->addAction("atomic number > label number > label suffix"); |
| 1863 |
sortGroup->addAction(a); |
| 1864 |
a->setCheckable(true); |
| 1865 |
if (editor->sortierWeise==2)a->setChecked(true); |
| 1866 |
a->setData(2); |
| 1867 |
a = sortMenu->addAction("SFAC number > label number > label suffix"); |
| 1868 |
sortGroup->addAction(a); |
| 1869 |
a->setCheckable(true); |
| 1870 |
if (editor->sortierWeise==3)a->setChecked(true); |
| 1871 |
a->setData(3); |
| 1872 |
a = sortMenu->addAction("label suffix > atomic number > label number"); |
| 1873 |
sortGroup->addAction(a); |
| 1874 |
a->setCheckable(true); |
| 1875 |
if (editor->sortierWeise==4)a->setChecked(true); |
| 1876 |
a->setData(4); |
| 1877 |
a = sortMenu->addAction("fragment> atomic number > label number > label suffix"); |
| 1878 |
sortGroup->addAction(a); |
| 1879 |
a->setCheckable(true); |
| 1880 |
if (editor->sortierWeise==5)a->setChecked(true); |
| 1881 |
a->setData(5); |
| 1882 |
|
| 1883 |
|
| 1884 |
a = sortMenu->addAction("U equivalent"); |
| 1885 |
sortGroup->addAction(a); |
| 1886 |
a->setCheckable(true); |
| 1887 |
if (editor->sortierWeise==6)a->setChecked(true); |
| 1888 |
a->setData(6); |
| 1889 |
connect(sortGroup,SIGNAL(triggered(QAction*)), editor,SLOT(changeSortierWeise(QAction*))); |
| 1890 |
runMenu->insertMenu(soact,sortMenu); |
| 1891 |
} |
| 1892 |
einstellung->beginGroup("Labeling"); |
| 1893 |
if (einstellung->contains("AutoUnused")){ |
| 1894 |
rufModeBox->setChecked(einstellung->value("AutoUnused").toBool()); |
| 1895 |
} |
| 1896 |
einstellung->endGroup(); |
| 1897 |
tbiconSize=32; |
| 1898 |
einstellung->beginGroup("ToolBarIcons"); |
| 1899 |
if (einstellung->contains("ToolBarIconSize")){ |
| 1900 |
tbiconSize=einstellung->value("ToolBarIconSize").toInt(); |
| 1901 |
} |
| 1902 |
einstellung->endGroup(); |
| 1903 |
tbiconSize=qMin(tbiconSize,96); |
| 1904 |
tbiconSize=qMax(tbiconSize,16); |
| 1905 |
fito->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1906 |
editToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1907 |
refineToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1908 |
vito->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1909 |
extraTB->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1910 |
bottomToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1911 |
chgl->invertMouseZoom->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1912 |
quickReLoadButton->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1913 |
homeMe->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1914 |
zoomIn->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1915 |
zoomOut->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 1916 |
/// |
| 1917 |
{ |
| 1918 |
scalDlg = new QDialog(this); |
| 1919 |
scalDlg->setWindowTitle("Change screen-shot scalefactor"); |
| 1920 |
scalla = new QGridLayout(); |
| 1921 |
scalwla = new QLabel("Width: "); |
| 1922 |
scalhla = new QLabel("Height: "); |
| 1923 |
scalsla = new QLabel("Scalefactor: "); |
| 1924 |
widthBox = new QSpinBox(); |
| 1925 |
heightBox = new QSpinBox(); |
| 1926 |
scalefBox = new QDoubleSpinBox(); |
| 1927 |
widthBox->setMinimum(32); |
| 1928 |
widthBox->setMaximum(10000); |
| 1929 |
widthBox->setSuffix(" pixels"); |
| 1930 |
widthBox->setObjectName("widthBox"); |
| 1931 |
heightBox->setMinimum(32); |
| 1932 |
heightBox->setMaximum(10000); |
| 1933 |
heightBox->setSuffix(" pixels"); |
| 1934 |
heightBox->setObjectName("heightBox"); |
| 1935 |
scalefBox->setMinimum(1); |
| 1936 |
scalefBox->setMaximum(400.0); |
| 1937 |
scalefBox->setSuffix(" %"); |
| 1938 |
scalefBox->setValue(scalePic*100.0); |
| 1939 |
scalefBox->setObjectName("scalefBox"); |
| 1940 |
header = new QLabel("<h3>Change screen-shot scalefactor</h3>"); |
| 1941 |
scalla->addWidget(header ,0,0,1,3); |
| 1942 |
scalla->addWidget(scalwla ,1,0); |
| 1943 |
scalla->addWidget(widthBox ,1,1); |
| 1944 |
scalla->addWidget(scalhla ,2,0); |
| 1945 |
scalla->addWidget(heightBox,2,1); |
| 1946 |
scalla->addWidget(scalsla ,3,0); |
| 1947 |
scalla->addWidget(scalefBox,3,1); |
| 1948 |
scalDlg->setLayout(scalla); |
| 1949 |
scalDlg->hide(); |
| 1950 |
connect(widthBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); |
| 1951 |
connect(heightBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); |
| 1952 |
connect(scalefBox,SIGNAL(valueChanged(double)),this,SLOT(updateScaleDlg())); |
| 1953 |
} |
| 1954 |
///////////// |
| 1955 |
toggDocWid(true); |
| 1956 |
raise(); |
| 1957 |
double vang=0; |
| 1958 |
|
| 1959 |
#if (QT_VERSION >= 0x040600) |
| 1960 |
dirName = (QProcessEnvironment::systemEnvironment ().value("PWD",dirName)); |
| 1961 |
#else |
| 1962 |
{ |
| 1963 |
QStringList env = QProcess::systemEnvironment(); |
| 1964 |
int da = env.indexOf(QRegularExpression("^PWD=.*$")); |
| 1965 |
if (da>-1) { |
| 1966 |
dirName = QString(env.at(da)).remove(0,4); |
| 1967 |
} |
| 1968 |
} |
| 1969 |
#endif |
| 1970 |
QString ffna=""; |
| 1971 |
startFused=false; |
| 1972 |
int argc=QCoreApplication::arguments().size(); |
| 1973 |
if (argc>1){ |
| 1974 |
for (int i=1;i<argc;i++){ |
| 1975 |
if ((QCoreApplication::arguments().at(i)=="-fcf6")) fxle->MYFCF=true; |
| 1976 |
if ((QCoreApplication::arguments().at(i).endsWith(".ins",Qt::CaseInsensitive)) || |
| 1977 |
(QCoreApplication::arguments().at(i).endsWith(".res",Qt::CaseInsensitive))) |
| 1978 |
ffna=QCoreApplication::arguments().at(i); |
| 1979 |
if ((QCoreApplication::arguments().at(i)=="-fused")) startFused=true; |
| 1980 |
if ((QCoreApplication::arguments().at(i)=="-HKLMAX")) fxle->HKLMX = QCoreApplication::arguments().at(i+1).toInt(); |
| 1981 |
if ((QCoreApplication::arguments().at(i)=="-viewangle")) vang = QCoreApplication::arguments().at(i+1).toDouble(); |
| 1982 |
if ((QCoreApplication::arguments().at(i)=="-voxel")) fxle->voxelstr = QCoreApplication::arguments().at(i+1); |
| 1983 |
if ((QCoreApplication::arguments().at(i)=="-shaderInfo")) shaderInfo=true; |
| 1984 |
//if ((QCoreApplication::arguments().at(i)=="-wt")) { chgl->dratpause = QCoreApplication::arguments().at(i+1).toInt();} |
| 1985 |
} |
| 1986 |
} |
| 1987 |
|
| 1988 |
//printf("%d\n",__LINE__); |
| 1989 |
//chgl->update(); |
| 1990 |
//if (vang>0.0) chgl->setViewAngle(vang); |
| 1991 |
|
| 1992 |
einstellung->beginGroup("ViewSettings"); |
| 1993 |
if (einstellung->contains("OrthographicProjection")) { |
| 1994 |
bool b=einstellung->value("OrthographicProjection").toBool(); |
| 1995 |
chgl->toggleOrthoView->setChecked(b); |
| 1996 |
chgl->toggleOrtho(b); |
| 1997 |
//toggleOrtho(b); |
| 1998 |
} |
| 1999 |
einstellung->endGroup(); |
| 2000 |
//printf("%d\n",__LINE__); |
| 2001 |
|
| 2002 |
qPeakDock->setVisible(true); |
| 2003 |
shxEditorDock->hide(); |
| 2004 |
shxOutputDock->hide(); |
| 2005 |
if (!ffna.isEmpty()) { |
| 2006 |
dirName=ffna; |
| 2007 |
printf("I will load this: %s.\n",ffna.toStdString().c_str()); |
| 2008 |
//connect(chgl, SIGNAL(initialized()), this, SLOT(loadAFile())); |
| 2009 |
connect(chgl, SIGNAL(initialized()), this, SLOT(delayedLoad())); |
| 2010 |
} |
| 2011 |
printf("Window constructor finished.\n"); |
| 2012 |
#include "WhatsThisAndWhere.h" |
| 2013 |
lastDirName=""; |
| 2014 |
//printf("%d\n",__LINE__); |
| 2015 |
|
| 2016 |
} |
| 2017 |
|
| 2018 |
Window::~Window() { |
| 2019 |
//printf("close?? this %p calcmenu %p dsr %p sortmenu%p hidwillpse %p fxle%p chgl%p\n", this,calcmenu,dsr,sortMenu,hidwillpse,fxle,chgl); |
| 2020 |
if (fxle!=NULL) delete fxle; |
| 2021 |
//printf("OK!%d\n",__LINE__); |
| 2022 |
if (calcmenu!=NULL) { |
| 2023 |
calcmenu->close(); |
| 2024 |
delete calcmenu;//only delete it if it has been created. (seg fault) |
| 2025 |
} |
| 2026 |
if (dsr!=NULL) { |
| 2027 |
dsr->close(); |
| 2028 |
delete dsr; |
| 2029 |
} |
| 2030 |
//printf("OK!%d\n",__LINE__); |
| 2031 |
} |
| 2032 |
|
| 2033 |
int Window::Version(){ |
| 2034 |
return Revision; |
| 2035 |
} |
| 2036 |
|
| 2037 |
void Window::hereAreMyKeys(){ |
| 2038 |
actionInfo.clear(); |
| 2039 |
actionInfo.append("<table>"); |
| 2040 |
QWidgetList wl = QApplication::allWidgets(); |
| 2041 |
QStringList shorts; |
| 2042 |
for (int i=0; i<wl.size(); i++){ |
| 2043 |
QList<QAction *> acs = wl.at(i)->actions(); |
| 2044 |
for (int j=0; j<acs.size(); j++){ |
| 2045 |
QString st=acs.at(j)->shortcut().toString(); |
| 2046 |
QIcon ic=acs.at(j)->icon(); |
| 2047 |
if (!st.isEmpty()){ |
| 2048 |
QString kb=acs.at(j)->shortcut().toString().replace(QRegularExpression("\\+"),"] + ["); |
| 2049 |
kb=kb.replace("+ [] + [","+ [+"); |
| 2050 |
#if defined (Q_OS_MAC) |
| 2051 |
kb=kb.replace("Ctrl","⌘");//clover CMD |
| 2052 |
kb=kb.replace("Meta","⌃");//Ctrl |
| 2053 |
kb=kb.replace("Alt","⌥");//Opt |
| 2054 |
kb=kb.replace("Shift","⇧");//shift/ |
| 2055 |
#endif |
| 2056 |
QString ac=acs.at(j)->text(); |
| 2057 |
int und=ac.indexOf('&'); |
| 2058 |
if (und!=-1) { |
| 2059 |
ac=ac.insert(und+2,"</u>"); |
| 2060 |
ac=ac.replace('&',"<u>"); |
| 2061 |
} |
| 2062 |
ac[0]=ac[0].toUpper(); |
| 2063 |
ac=ac.replace(' '," "); |
| 2064 |
shorts.append(QString("<td><b>[%2]</b></td><td>%1</td>").arg(ac).arg(kb)); |
| 2065 |
} |
| 2066 |
} |
| 2067 |
} |
| 2068 |
shorts.sort(); |
| 2069 |
shorts.removeDuplicates(); |
| 2070 |
for (int i=0; i<shorts.size();i++){ |
| 2071 |
if ((i%2)==0) actionInfo.append(QString("<tr>%1\n").arg(shorts.at(i))); |
| 2072 |
else actionInfo.append(QString("%1</tr>\n").arg(shorts.at(i))); |
| 2073 |
} |
| 2074 |
actionInfo.append("</table><br>Try Whats This on empty menu parts for more."); |
| 2075 |
QMessageBox::information(this, "ShelXle Key Bindings", actionInfo); |
| 2076 |
} |
| 2077 |
|
| 2078 |
void Window::fileNative(){ |
| 2079 |
einstellung->beginGroup("Window"); |
| 2080 |
einstellung->setValue("nativeDialogs",useNativeDlg->isChecked()); |
| 2081 |
einstellung->endGroup(); |
| 2082 |
} |
| 2083 |
|
| 2084 |
void Window::darkEdit(){ |
| 2085 |
|
| 2086 |
bool b=darkTheme->isChecked(); |
| 2087 |
bool classic=false; |
| 2088 |
if (QString(PROGRAM_NAME).compare("shelXle")){ |
| 2089 |
//this is BrukerShelXle so we do not use any syle sheets |
| 2090 |
b=false; |
| 2091 |
classic=true; |
| 2092 |
editor->highlighter->loadHighlightPatterns(inspatternfile); |
| 2093 |
xlPutor->highlighter->loadHighlightPatterns(lstpatternfile); |
| 2094 |
qpv->dark=b; |
| 2095 |
return; |
| 2096 |
} |
| 2097 |
maybeSave(); |
| 2098 |
editor->dark=xlPutor->dark=b; |
| 2099 |
qpv->dark=b; |
| 2100 |
if (b){ |
| 2101 |
editor->highlighter->loadHighlightPatterns(inspatternfile_dark); |
| 2102 |
xlPutor->highlighter->loadHighlightPatterns(lstpatternfile_dark); |
| 2103 |
QFile f(":dark/dstyle.qss"); |
| 2104 |
|
| 2105 |
if (!f.exists()) { |
| 2106 |
printf("Unable to set stylesheet, file not found\n"); |
| 2107 |
} |
| 2108 |
else { |
| 2109 |
f.open(QFile::ReadOnly | QFile::Text); |
| 2110 |
QTextStream ts(&f); |
| 2111 |
QString stle=ts.readAll(); |
| 2112 |
if (!classic){ |
| 2113 |
qApp->setStyleSheet(stle); |
| 2114 |
//printf("darkstyle dark!\n"); |
| 2115 |
} |
| 2116 |
|
| 2117 |
} |
| 2118 |
QPalette p = editor->palette(); |
| 2119 |
p.setColor(QPalette::Base,QColor(0xff1e1e1eu)); |
| 2120 |
p.setColor(QPalette::WindowText,QColor(0xffc8c8c8u)); |
| 2121 |
p.setColor(QPalette::Text,QColor(0xffc8c8c8u)); |
| 2122 |
editor->setPalette (p ); |
| 2123 |
p = xlPutor->palette(); |
| 2124 |
p.setColor(QPalette::Base,QColor(0xff1e1e1eu)); |
| 2125 |
p.setColor(QPalette::WindowText,QColor(0xffc8c8c8u)); |
| 2126 |
p.setColor(QPalette::Text,QColor(0xffc8c8c8u)); |
| 2127 |
xlPutor->setPalette (p ); |
| 2128 |
xlPutor->setStyleSheet("QPlainTextEdit {\nbackground-color: #19232D;\ncolor: #E0E1E3;\nborder-radius: 4px;\nborder: 1px solid #455364;\n}"); |
| 2129 |
}else{ |
| 2130 |
editor->highlighter->loadHighlightPatterns(inspatternfile); |
| 2131 |
xlPutor->highlighter->loadHighlightPatterns(lstpatternfile); |
| 2132 |
QFile f(":light/lstyle.qss"); |
| 2133 |
|
| 2134 |
if (!f.exists()) { |
| 2135 |
printf("Unable to set stylesheet, file not found\n"); |
| 2136 |
} |
| 2137 |
else { |
| 2138 |
f.open(QFile::ReadOnly | QFile::Text); |
| 2139 |
QTextStream ts(&f); |
| 2140 |
QString stle=ts.readAll(); |
| 2141 |
if (!classic){ |
| 2142 |
qApp->setStyleSheet(stle); |
| 2143 |
//printf("darkstyle light!\n"); |
| 2144 |
} |
| 2145 |
|
| 2146 |
} |
| 2147 |
QPalette p = xlPutor->palette(); |
| 2148 |
p.setColor(QPalette::WindowText,QColor(0xff000000u)); |
| 2149 |
p.setColor(QPalette::Text,QColor(0xff000000u)); |
| 2150 |
p.setColor(QPalette::Base,QColor(0xffffffffu)); |
| 2151 |
editor->setPalette (p ); |
| 2152 |
p.setColor(QPalette::Base,QColor(0xffffffe6u)); |
| 2153 |
xlPutor->setStyleSheet("QPlainTextEdit {\nbackground-color: #FFFFE6;\ncolor: #19232D;\nborder-radius: 4px;\nborder: 1px solid #C9CDD0;\n}"); |
| 2154 |
xlPutor->setPalette (p ); |
| 2155 |
} |
| 2156 |
einstellung->beginGroup("Colors"); |
| 2157 |
einstellung->setValue("darkTheme",darkTheme->isChecked()); |
| 2158 |
einstellung->endGroup(); |
| 2159 |
if (editor->isVisible()){ |
| 2160 |
printf("reload file!\n"); |
| 2161 |
loadAFile(); |
| 2162 |
} |
| 2163 |
einstellung->beginGroup("Fonts"); |
| 2164 |
if (einstellung->contains("EditorFont")){ |
| 2165 |
QFont fnt; |
| 2166 |
int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); |
| 2167 |
QString family = QFontDatabase::applicationFontFamilies(id).at(0); |
| 2168 |
fnt = QFont(family); |
| 2169 |
fnt = einstellung->value("EditorFont").value<QFont>(); |
| 2170 |
/*QFontInfo finfo(fnt); |
| 2171 |
if (!finfo.exactMatch()){ |
| 2172 |
int id = QFontDatabase::addApplicationFont(theIconPath+"SourceCodePro-Regular.ttf"); |
| 2173 |
QString family = QFontDatabase::applicationFontFamilies(id).at(0); |
| 2174 |
fnt = QFont(family); |
| 2175 |
|
| 2176 |
}*/ |
| 2177 |
int fosi = einstellung->value("EditorFontSize", 10).toInt(); |
| 2178 |
fnt.setPointSize(fosi); |
| 2179 |
printf("Dark? Font from settings %s %d\n", fnt.family().toStdString().c_str(),fnt.pointSize()); |
| 2180 |
// #if (QT_VERSION >= 0x040700) |
| 2181 |
// fnt.setStyleStrategy(QFont::ForceIntegerMetrics); |
| 2182 |
// #endif |
| 2183 |
editor->setFont(fnt); |
| 2184 |
xlPutor->setFont(fnt); |
| 2185 |
} |
| 2186 |
einstellung->endGroup(); |
| 2187 |
update(); |
| 2188 |
} |
| 2189 |
|
| 2190 |
bool Window::doWeHaveHKLF5here(QStringList &hk5s){ |
| 2191 |
QString dn=dirName.section('/',0,-2); |
| 2192 |
QStringList filter; |
| 2193 |
filter.append("*.hkl"); |
| 2194 |
QStringList files; |
| 2195 |
files = QDir(dn).entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 2196 |
int cread=-1,bn=0;//chars read |
| 2197 |
//* |
| 2198 |
//Joergs suggestion |
| 2199 |
char buffer[260*2]; |
| 2200 |
memset(buffer, '\0', sizeof(buffer)); |
| 2201 |
char *cline=buffer, *pline=buffer+260, *temp; |
| 2202 |
char batchstr[10]; |
| 2203 |
memset(batchstr, '\0', sizeof(batchstr)); |
| 2204 |
for (int i=0; i<files.size();i++){ |
| 2205 |
int bnmax=0,bnmin=0;//,nb=0;//nl=0, |
| 2206 |
bool is_hklf5=false; |
| 2207 |
QFile hkl(QString("%1/%2").arg(dn).arg(files.at(i))); |
| 2208 |
hkl.open(QIODevice::Text|QIODevice::ReadOnly); |
| 2209 |
int no=-1; |
| 2210 |
do{ |
| 2211 |
cread = hkl.readLine(cline,sizeof(buffer)/2); |
| 2212 |
if (0==memcmp(cline," 0 0 0",12)) break; |
| 2213 |
if (cread>28) { |
| 2214 |
//nb++; |
| 2215 |
//strncpy |
| 2216 |
memcpy(batchstr,cline+28,4); |
| 2217 |
batchstr[4]='\0'; |
| 2218 |
bn=atoi(batchstr); |
| 2219 |
bnmax=fmax(bn,bnmax); |
| 2220 |
bnmin=fmin(bn,bnmin); |
| 2221 |
} |
| 2222 |
if ((no != i) && (bnmin < 0) && (0 == memcmp(cline+12, pline+12, 16)) ) {//memcmp(cline+12, pline+12, 16))//strncmp(cline+12, pline+12,16) |
| 2223 |
is_hklf5=true; |
| 2224 |
//printf("|%s|%s|################\n%s",cline+12, pline+12,cline); |
| 2225 |
no=i; |
| 2226 |
hk5s.append(files.at(i)); |
| 2227 |
} |
| 2228 |
temp = pline; pline = cline; cline = temp; |
| 2229 |
}while ((!is_hklf5)&&(cread>0)); |
| 2230 |
//Joergs suggestion |
| 2231 |
// */ |
| 2232 |
/* |
| 2233 |
char line[260],batchpart[120],isigpart[120],asig[120]; |
| 2234 |
for (int j=0; j< 120;j++) {batchpart[j]='\0';isigpart[j]='\0';asig[j]='\0';} |
| 2235 |
//int cread=-1,bn=0;//chars read |
| 2236 |
for (int i=0; i<files.size();i++){ |
| 2237 |
int bnmax=0,bnmin=0,nl=0,nb=0; |
| 2238 |
bool is_hklf5=false; |
| 2239 |
QFile hkl(QString("%1/%2").arg(dn).arg(files.at(i))); |
| 2240 |
hkl.open(QIODevice::Text|QIODevice::ReadOnly); |
| 2241 |
int no=-1; |
| 2242 |
do{ |
| 2243 |
for (int j=0; j< 120;j++) {batchpart[j]='\0';isigpart[j]='\0';} |
| 2244 |
cread = hkl.readLine(line,sizeof(line)); |
| 2245 |
if (0==strncmp(line," 0 0 0",12)) break; |
| 2246 |
//printf("[%d]%s\n",cread,line); |
| 2247 |
nl++; |
| 2248 |
if (cread>12) { |
| 2249 |
for (int j=12,k=0; j< 28;j++) isigpart[k++]=line[j]; |
| 2250 |
} |
| 2251 |
if (cread>28) { |
| 2252 |
int maxbatch=fmin(cread,32); |
| 2253 |
for (int j=28,k=0; j< maxbatch;j++) batchpart[k++]=line[j]; |
| 2254 |
nb++; |
| 2255 |
//if (cread>33) printf("%d\n%s\n\ %s\n",cread,line,batchpart); |
| 2256 |
bn=atoi(batchpart); |
| 2257 |
bnmax=fmax(bn,bnmax); |
| 2258 |
bnmin=fmin(bn,bnmin); |
| 2259 |
} |
| 2260 |
if ((no!=i)&&(0==strncmp(isigpart,asig,16))&&(bnmin<0)) { |
| 2261 |
is_hklf5=true; |
| 2262 |
no=i; |
| 2263 |
hk5s.append(files.at(i)); |
| 2264 |
//printf("HKLF5 ?? %d %d i=%d bn=%d\n", hk5s.size(), hklf5files.size(), i, bn); |
| 2265 |
} |
| 2266 |
for (int j=0; j< 16;j++) asig[j]=isigpart[j]; |
| 2267 |
}while (cread>0); |
| 2268 |
//*/ |
| 2269 |
/*printf("%s %d lines read bn max %d bn min %d (%d). Think this%s a HKLF5\n", |
| 2270 |
files.at(i).toStdString().c_str(), |
| 2271 |
nl, |
| 2272 |
bnmax, |
| 2273 |
bnmin, |
| 2274 |
nb, |
| 2275 |
(is_hklf5)?"":" not");// */ |
| 2276 |
} |
| 2277 |
return !hk5s.isEmpty(); |
| 2278 |
} |
| 2279 |
|
| 2280 |
void Window::connectEdior(){ |
| 2281 |
//printf("\n\n\nconnectEdior()-->\n"); |
| 2282 |
//editor->dumpObjectInfo (); |
| 2283 |
bool disok=false; |
| 2284 |
disok=editor->disconnect(SIGNAL(saveMe(bool,bool)),this,SLOT(fileSave(bool,bool))); |
| 2285 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2286 |
disok=editor->disconnect(SIGNAL(updateLabel()),this,SLOT(updateLabel())); |
| 2287 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2288 |
disok=editor->disconnect(SIGNAL(textChanged ()),this,SLOT(spellCheck())); |
| 2289 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2290 |
disok=editor->disconnect(SIGNAL(cursorPositionChanged ()),this,SLOT(updateLC())); |
| 2291 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2292 |
disok=editor->disconnect(SIGNAL(findInStructure(const QString&)),this,SLOT(findInStructure(const QString &))); |
| 2293 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2294 |
disok=editor->disconnect(SIGNAL(openIncludeFile(const QString&)),this,SLOT(openIncludeFile(const QString &))); |
| 2295 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2296 |
disok=editor->disconnect(SIGNAL(electInStructure(const QString&)),this,SLOT(selectInStructure(const QString &))); |
| 2297 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2298 |
disok=editor->disconnect(SIGNAL(textChanged()),this,SLOT(updateSelectResi())); |
| 2299 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2300 |
disok=editor->disconnect(SIGNAL(cursorPositionChanged()),this,SLOT(resiSelectorCheck())); |
| 2301 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2302 |
disok=editor->disconnect( SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); |
| 2303 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2304 |
disok=editor->disconnect( SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); |
| 2305 |
//printf("%d %s\n",__LINE__,(disok)?"ok":"no"); |
| 2306 |
|
| 2307 |
//printf("<--connectEdior()-->\n"); |
| 2308 |
//editor->dumpObjectInfo (); |
| 2309 |
//actionUndo->disconnect(); |
| 2310 |
//actionRedo->disconnect(); |
| 2311 |
//actionCut->disconnect(); |
| 2312 |
//actionCopy->disconnect(); |
| 2313 |
//actionPaste->disconnect(); |
| 2314 |
connect(editor,SIGNAL(saveMe(bool,bool)),this,SLOT(fileSave(bool,bool))); |
| 2315 |
connect(editor,SIGNAL(updateLabel()),this,SLOT(updateLabel())); |
| 2316 |
connect(editor,SIGNAL(textChanged ()),this,SLOT(spellCheck())); |
| 2317 |
connect(editor,SIGNAL(cursorPositionChanged ()),this,SLOT(updateLC())); |
| 2318 |
connect(editor,SIGNAL(findInStructure(const QString&)),this,SLOT(findInStructure(const QString &))); |
| 2319 |
connect(editor,SIGNAL(openIncludeFile(const QString&)),this,SLOT(openIncludeFile(const QString &))); |
| 2320 |
connect(editor,SIGNAL(electInStructure(const QString&)),this,SLOT(selectInStructure(const QString &))); |
| 2321 |
connect(editor,SIGNAL(textChanged()),this,SLOT(updateSelectResi())); |
| 2322 |
connect(editor,SIGNAL(cursorPositionChanged()),this,SLOT(resiSelectorCheck())); |
| 2323 |
|
| 2324 |
connect(editor->document(), SIGNAL(modificationChanged(bool)), |
| 2325 |
actionSave, SLOT(setEnabled(bool))); |
| 2326 |
connect(editor->document(), SIGNAL(modificationChanged(bool)), |
| 2327 |
actionHFix, SLOT(setDisabled(bool))); |
| 2328 |
connect(editor->document(), SIGNAL(modificationChanged(bool)), |
| 2329 |
this, SLOT(setWindowModified(bool))); |
| 2330 |
connect(editor->document(), SIGNAL(undoAvailable(bool)), |
| 2331 |
actionUndo, SLOT(setEnabled(bool))); |
| 2332 |
connect(editor->document(), SIGNAL(undoCommandAdded ()), |
| 2333 |
this, SLOT(wasRename())); |
| 2334 |
connect(editor->document(), SIGNAL(undoCommandAdded()),this,SLOT(wasDelete())); |
| 2335 |
connect(editor->document(), SIGNAL(redoAvailable(bool)), |
| 2336 |
actionRedo, SLOT(setEnabled(bool))); |
| 2337 |
connect(actionUndo, SIGNAL(triggered()), editor, SLOT(undo())); |
| 2338 |
connect(actionUndo,SIGNAL(triggered()),this,SLOT(undoRename())); |
| 2339 |
connect(actionRedo, SIGNAL(triggered()), editor, SLOT(redo())); |
| 2340 |
connect(actionRedo, SIGNAL(triggered()),this, SLOT(redoRename())); |
| 2341 |
connect(actionCut, SIGNAL(triggered()), editor, SLOT(mcut())); |
| 2342 |
connect(actionCopy, SIGNAL(triggered()), editor, SLOT(copy())); |
| 2343 |
connect(actionPaste, SIGNAL(triggered()), editor, SLOT(mpaste())); |
| 2344 |
connect(editor, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); |
| 2345 |
connect(editor, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); |
| 2346 |
connect(editor,SIGNAL(deleteSelected()),this,SLOT(deleteSelectedAtoms())); |
| 2347 |
//editor->dumpObjectInfo (); |
| 2348 |
//printf("<--connectEdior()\n"); |
| 2349 |
} |
| 2350 |
|
| 2351 |
void Window::updateTwinTest(){ |
| 2352 |
//printf("\n\nUPDATE TWIN TEST\n"); |
| 2353 |
Matrix M[6]; |
| 2354 |
M[0] =Matrix ( 0, 1, 0, 1, 0, 0, 0, 0, -1); |
| 2355 |
M[1] =Matrix ( 0, -1, 0, -1, 0, 0, 0, 0, -1); |
| 2356 |
M[2] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, 1); |
| 2357 |
M[3] =Matrix ( 1, 0, 0, 0, -1, 0, 0, 0, -1); |
| 2358 |
M[4] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, -1); |
| 2359 |
M[5] =Matrix ( 1, 0, 0, 0, 1, 0, 0, 0, 1); |
| 2360 |
QString dn=dirName.section('/',0,-2); |
| 2361 |
QString wd=QString("%1/twintest/").arg(dn); |
| 2362 |
bool didsomething=false; |
| 2363 |
for (int m=0; m<6; m++){ |
| 2364 |
if (twinRedundant.at(m)) continue; |
| 2365 |
if (twinDone.at(m)) continue; |
| 2366 |
didsomething=true; |
| 2367 |
//QString insnam=QString("%1test%2.ins").arg(wd).arg(m); |
| 2368 |
//QString insnambase=QString("test%1").arg(m); |
| 2369 |
|
| 2370 |
QString resnam=QString("%1test%2.res").arg(wd).arg(m); |
| 2371 |
QFile res(resnam); |
| 2372 |
if (res.open(QIODevice::ReadOnly|QIODevice::Text)){ |
| 2373 |
//printf("resname=%s\n",resnam.toStdString().c_str()); |
| 2374 |
QString inhalt=res.readAll(); |
| 2375 |
res.close(); |
| 2376 |
if (inhalt.isEmpty()) continue; |
| 2377 |
QStringList basfs=inhalt.section("\nBASF ",1).section("\n",0,0).trimmed().split(" ",skipEmptyParts); |
| 2378 |
bool maybe=true; |
| 2379 |
if (!basfs.isEmpty()) { |
| 2380 |
double basf=basfs.at(0).toDouble(); |
| 2381 |
//printf("BASF %f\n",basf); |
| 2382 |
maybe=((basf>0.04)&&(basf<0.96)); |
| 2383 |
} |
| 2384 |
inhalt = inhalt.section("\nHKLF ",1); |
| 2385 |
|
| 2386 |
QStringList sl2 = inhalt.section("REM wR2 =",1).section("\n",0,0).trimmed().split(",",skipEmptyParts); |
| 2387 |
//REM R1 = 0.0150 for 6927 Fo > 4sig(Fo) and 0.0160 for all 7220 data |
| 2388 |
QStringList sl = inhalt.section("REM R1 =",1).section("\n",0,0).trimmed().split(" ",skipEmptyParts); |
| 2389 |
if (sl.size()<11)continue; |
| 2390 |
if (sl2.size()<1) maybe=maybe&&(sl.at(0).toDouble()*100.0<=(rvalue2beat+0.075)); |
| 2391 |
else maybe=maybe&&(sl2.at(0).toDouble()*100.0<=(wr2value2beat+0.075)); |
| 2392 |
/*printf("m=%d R1 %5.2f %d all %5.2f %d %s (%f)\n", |
| 2393 |
m, |
| 2394 |
sl.at(0).toDouble()*100.0, |
| 2395 |
sl.at(2).toInt(), |
| 2396 |
sl.at(7).toDouble()*100.0, |
| 2397 |
sl.at(10).toInt(), |
| 2398 |
(maybe)?"probably a twin":"not realy likely a suitabe twin law", |
| 2399 |
rvalue2beat |
| 2400 |
);*/ |
| 2401 |
QString Label= QString("TWIN %1 %2 %3 %4 %5 %6 %7 %8 %9 %10") |
| 2402 |
.arg(M[m].m11).arg(M[m].m21).arg(M[m].m31) |
| 2403 |
.arg(M[m].m12).arg(M[m].m22).arg(M[m].m32) |
| 2404 |
.arg(M[m].m13).arg(M[m].m23).arg(M[m].m33) |
| 2405 |
.arg((m==5)?"= no twin law for comparison":""); |
| 2406 |
QGroupBox *gpx2 = new QGroupBox(Label,twinDlg); |
| 2407 |
|
| 2408 |
gpx2->setAlignment(Qt::AlignRight); |
| 2409 |
gpx2->setCheckable(true); |
| 2410 |
gpx2->setChecked(maybe); |
| 2411 |
|
| 2412 |
QVBoxLayout *v = new QVBoxLayout(gpx2); |
| 2413 |
QHBoxLayout *hbl1 = new QHBoxLayout(); |
| 2414 |
double basfv=basfs.at(0).toDouble(); |
| 2415 |
QLabel *R1lab = new QLabel(QString("R1=%1\nafter applying\ntwin law").arg(sl.at(0).toDouble()*100.0,0,'f',2),twinDlg); |
| 2416 |
R1lab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(hw->rwert_farbverlauf(sl.at(0).toDouble()*300.0).name())); |
| 2417 |
if (sl2.size()>0){ |
| 2418 |
QLabel *wR2lab = new QLabel(QString("wR2=%1\nafter applying\ntwin law").arg(sl2.at(0).toDouble()*100.0,0,'f',2),twinDlg); |
| 2419 |
wR2lab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(hw->rwert_farbverlauf(sl2.at(0).toDouble()*300.0).name())); |
| 2420 |
QLabel *beatlab = new QLabel(QString("curent \nR1 =%1\nwR2= %2").arg(rvalue2beat,0,'f',2).arg(wr2value2beat,0,'f',2),twinDlg); |
| 2421 |
beatlab->setStyleSheet(QString("QLabel { background-color : qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 %1, stop: 1 %2); color : white; }") |
| 2422 |
.arg(hw->rwert_farbverlauf(rvalue2beat*3.0).name()) |
| 2423 |
.arg(hw->rwert_farbverlauf(wr2value2beat*3.0).name())); |
| 2424 |
|
| 2425 |
QLabel *BASFlab = new QLabel(QString("BASF = %1").arg(basfv,0,'f',4),twinDlg); |
| 2426 |
BASFlab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(((basfv>0.04)&&(basfv<0.96))?"#009933":"#990033")); |
| 2427 |
hbl1->addWidget(beatlab); |
| 2428 |
hbl1->addWidget(R1lab); |
| 2429 |
hbl1->addWidget(wR2lab); |
| 2430 |
hbl1->addWidget(BASFlab); |
| 2431 |
}else{// old xl versions do not rem the wR2 value |
| 2432 |
QLabel *beatlab = new QLabel(QString("curent \nR1 =%1").arg(rvalue2beat,0,'f',2),twinDlg); |
| 2433 |
beatlab->setStyleSheet(QString("QLabel { background-color : %1; white; }") |
| 2434 |
.arg(hw->rwert_farbverlauf(rvalue2beat*3.0).name()) |
| 2435 |
); |
| 2436 |
|
| 2437 |
QLabel *BASFlab = new QLabel(QString("BASF = %1").arg(basfv,0,'f',4),twinDlg); |
| 2438 |
BASFlab->setStyleSheet(QString("QLabel { background-color : %1; color : white; }").arg(((basfv>0.04)&&(basfv<0.96))?"#009933":"#990033")); |
| 2439 |
hbl1->addWidget(beatlab); |
| 2440 |
hbl1->addWidget(R1lab); |
| 2441 |
hbl1->addWidget(BASFlab); |
| 2442 |
} |
| 2443 |
//if (maybe){ |
| 2444 |
QAction *tryThisTwin = new QAction("insert this twin \nlaw in res file",twinDlg); |
| 2445 |
tryThisTwin->setEnabled(maybe); |
| 2446 |
tryThisTwin->setData(QString("%1\nBASF %2\n").arg(Label).arg(basfv,0,'f',4)); |
| 2447 |
connect(tryThisTwin,SIGNAL(triggered()),this,SLOT(insertTwin())); |
| 2448 |
connect(tryThisTwin,SIGNAL(triggered()),twinDlg,SLOT(reject())); |
| 2449 |
QToolButton *button =new QToolButton(twinDlg); |
| 2450 |
button->setDefaultAction(tryThisTwin); |
| 2451 |
connect(gpx2,SIGNAL(toggled(bool)),button,SLOT(setEnabled(bool))); |
| 2452 |
if (m==5) { |
| 2453 |
gpx2->setChecked(false); |
| 2454 |
gpx2->setCheckable(false); |
| 2455 |
button->setEnabled(false); |
| 2456 |
} |
| 2457 |
//button->setEnabled(maybe); |
| 2458 |
hbl1->addWidget(button); |
| 2459 |
//} |
| 2460 |
v->addLayout(hbl1); |
| 2461 |
|
| 2462 |
twinvbl->addWidget(gpx2); |
| 2463 |
|
| 2464 |
twinDone[m]=true; |
| 2465 |
twingpx->adjustSize(); |
| 2466 |
} |
| 2467 |
}// */ |
| 2468 |
if (didsomething){ |
| 2469 |
twinDlg->update(); |
| 2470 |
twinDlg->show(); |
| 2471 |
}else {twinpatlab->hide();} |
| 2472 |
} |
| 2473 |
|
| 2474 |
void Window::testMerohedral(){ |
| 2475 |
Matrix M[6]; |
| 2476 |
M[0] =Matrix ( 0, 1, 0, 1, 0, 0, 0, 0, -1); |
| 2477 |
M[1] =Matrix ( 0, -1, 0, -1, 0, 0, 0, 0, -1); |
| 2478 |
M[2] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, 1); |
| 2479 |
M[3] =Matrix ( 1, 0, 0, 0, -1, 0, 0, 0, -1); |
| 2480 |
M[4] =Matrix (-1, 0, 0, 0, -1, 0, 0, 0, -1); |
| 2481 |
M[5] =Matrix ( 1, 0, 0, 0, 1, 0, 0, 0, 1); |
| 2482 |
twinRedundant.clear(); |
| 2483 |
twinDone.clear(); |
| 2484 |
for (int i=0; i<mole.cell.symmops.size(); i++){ |
| 2485 |
for (int m=0; m<6;m++){ |
| 2486 |
twinRedundant.append(false); |
| 2487 |
twinDone.append(false); |
| 2488 |
if ((m==4)&&(mole.cell.centeric)) twinRedundant[m]=true; |
| 2489 |
Matrix tm=M[m]*mole.cell.symmops.at(i); |
| 2490 |
|
| 2491 |
if (m!=5) for (int n=0; n<m; n++){ |
| 2492 |
if ((i>0)&&(m!=n)&&(tm==M[n])) {printf("Matrix %d %d %d is redundant\n",m,i,n); |
| 2493 |
twinRedundant[m]=true; |
| 2494 |
printf("\nX%9.3f %9.3f %9.3f\nX%9.3f %9.3f %9.3f\nX%9.3f %9.3f %9.3f\n\n" |
| 2495 |
,tm.m11 |
| 2496 |
,tm.m21 |
| 2497 |
,tm.m31 |
| 2498 |
,tm.m12 |
| 2499 |
,tm.m22 |
| 2500 |
,tm.m32 |
| 2501 |
,tm.m13 |
| 2502 |
,tm.m23 |
| 2503 |
,tm.m33 |
| 2504 |
); |
| 2505 |
} |
| 2506 |
} |
| 2507 |
} |
| 2508 |
} |
| 2509 |
|
| 2510 |
QFile res(dirName); |
| 2511 |
res.open(QIODevice::ReadOnly|QIODevice::Text); |
| 2512 |
QString inhalt=res.readAll(); |
| 2513 |
res.close(); |
| 2514 |
inhalt = inhalt.section("\nHKLF ",1); |
| 2515 |
//REM wR2 = 0.176801, GooF = S = 1.14341, Restrained GooF = 1.14341 for all data |
| 2516 |
QStringList sl2 = inhalt.section("REM wR2 =",1).section("\n",0,0).trimmed().split(",",skipEmptyParts); |
| 2517 |
//REM R1 = 0.0150 for 6927 Fo > 4sig(Fo) and 0.0160 for all 7220 data |
| 2518 |
QStringList sl = inhalt.section("REM R1 =",1).section("\n",0,0).trimmed().split(" ",skipEmptyParts); |
| 2519 |
rvalue2beat=99.0; |
| 2520 |
wr2value2beat=99.0; |
| 2521 |
if (sl.size()>10) rvalue2beat=sl.at(0).toDouble()*100.0; |
| 2522 |
if (sl2.size()>1) wr2value2beat=sl2.at(0).toDouble()*100.0; |
| 2523 |
QString dn=dirName.section('/',0,-2); |
| 2524 |
QString hkl=dirName; |
| 2525 |
hkl=hkl.replace(resorins,".hkl"); |
| 2526 |
QString wd=QString("%1/twintest/").arg(dn); |
| 2527 |
QDir work=QDir(wd); |
| 2528 |
if (!work.exists()) work.mkdir(wd); |
| 2529 |
else{ |
| 2530 |
QStringList filter; |
| 2531 |
filter << QString("*.*"); |
| 2532 |
QStringList files; |
| 2533 |
files=work.entryList(filter,QDir::Files); |
| 2534 |
for (int i=0; i<files.size(); i++){ |
| 2535 |
printf("remove %s ok=%d\n",files.at(i).toStdString().c_str(), |
| 2536 |
work.remove(files.at(i))); |
| 2537 |
} |
| 2538 |
} |
| 2539 |
//shelxl->setWorkingDirectory(wd); |
| 2540 |
//qDebug()<<shelxlPath; |
| 2541 |
for (int m=0; m<6; m++){ |
| 2542 |
if (twinRedundant.at(m)) continue; |
| 2543 |
QString insnam=QString("%1test%2.ins").arg(wd).arg(m); |
| 2544 |
QFile::copy(dirName,insnam); |
| 2545 |
//printf("COPY %s to %s.\n",dirName.toStdString().c_str(),insnam.toStdString().c_str()); |
| 2546 |
QFile::copy(hkl,QString("%1test%2.hkl").arg(wd).arg(m)); |
| 2547 |
} |
| 2548 |
if (twinDlg) { |
| 2549 |
twinDlg->hide(); |
| 2550 |
delete twinDlg; |
| 2551 |
} |
| 2552 |
twinDlg = new QDialog(this); |
| 2553 |
|
| 2554 |
twingpx =new QGroupBox("Possible twin laws for this structure:",twinDlg); |
| 2555 |
twinvbl = new QVBoxLayout(); |
| 2556 |
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Cancel,Qt::Horizontal,twinDlg); |
| 2557 |
connect(bb, SIGNAL(rejected()), twinDlg, SLOT(reject())); |
| 2558 |
twingpx->setLayout(twinvbl); |
| 2559 |
QVBoxLayout *la = new QVBoxLayout(); |
| 2560 |
QScrollArea *qsa = new QScrollArea(twinDlg); |
| 2561 |
twingpx->setMinimumSize(590,650); |
| 2562 |
qsa->setWidget(twingpx); |
| 2563 |
qsa->setMinimumSize(600,660); |
| 2564 |
la->addWidget(qsa); |
| 2565 |
la->addWidget(bb); |
| 2566 |
twinDlg->setLayout(la); |
| 2567 |
twinvbl->addWidget(twinpatlab = new QLabel("...please wait until some twin laws are checked...")); |
| 2568 |
updateTwinTest(); |
| 2569 |
//QList<QCheckBox *> alleboxen; |
| 2570 |
//QSignalMapper *map = new QSignalMapper(this); |
| 2571 |
|
| 2572 |
|
| 2573 |
|
| 2574 |
|
| 2575 |
|
| 2576 |
|
| 2577 |
for (int m=0; m<6; m++){ |
| 2578 |
if (twinRedundant.at(m)) continue; |
| 2579 |
QString insnam=QString("%1test%2.ins").arg(wd).arg(m); |
| 2580 |
QString insnambase=QString("test%1").arg(m); |
| 2581 |
QProcess *shelxl0 = new QProcess(this); |
| 2582 |
shelxl0->setWorkingDirectory(wd); |
| 2583 |
QFile f(insnam); |
| 2584 |
f.open(QIODevice::ReadOnly|QIODevice::Text); |
| 2585 |
QString all = f.readAll(); |
| 2586 |
f.close(); |
| 2587 |
all=all.replace(QRegularExpression("\nACTA[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no acta! |
| 2588 |
all=all.replace(QRegularExpression("\nTWIN[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no TWIN! |
| 2589 |
all=all.replace(QRegularExpression("\nBASF[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no basf! |
| 2590 |
all=all.replace(QRegularExpression("\nAFIX[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no afix! |
| 2591 |
all=all.replace(QRegularExpression("\nL.S.[^\n]*\n", QRegularExpression::CaseInsensitiveOption),"\n");//no L.S.! |
| 2592 |
|
| 2593 |
int unitpos=all.indexOf("UNIT",0,Qt::CaseInsensitive); |
| 2594 |
int afterunitpos=all.indexOf("\n",unitpos); |
| 2595 |
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") |
| 2596 |
.arg(M[m].m11).arg(M[m].m21).arg(M[m].m31) |
| 2597 |
.arg(M[m].m12).arg(M[m].m22).arg(M[m].m32) |
| 2598 |
.arg(M[m].m13).arg(M[m].m23).arg(M[m].m33)); |
| 2599 |
f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 2600 |
f.write(all.toLatin1()); |
| 2601 |
f.close(); |
| 2602 |
QStringList al; |
| 2603 |
al.append(insnambase); |
| 2604 |
connect(shelxl0,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateTwinTest())); |
| 2605 |
connect(shelxl0,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateTwinTest())); |
| 2606 |
shelxl0->start(shelxlPath,al); |
| 2607 |
//shelxl0->waitForFinished(); |
| 2608 |
//fprintf(stderr,"\n!![%s]\n",shelxl0->readAllStandardOutput().data()); |
| 2609 |
//fprintf(stderr,"\n!![%s]\n",shelxl0->readAllStandardError().data()); |
| 2610 |
|
| 2611 |
} |
| 2612 |
QTimer::singleShot(5000,twinpatlab,SLOT(hide())); |
| 2613 |
|
| 2614 |
} |
| 2615 |
void Window::insertTwin(){ |
| 2616 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 2617 |
QString insertthis; |
| 2618 |
if (action) |
| 2619 |
insertthis=action->data().toString(); |
| 2620 |
else return; |
| 2621 |
QTextDocument *document = editor->document(); |
| 2622 |
QTextCursor cursor = editor->textCursor(); |
| 2623 |
cursor.beginEditBlock(); |
| 2624 |
editor->replace->setText(""); |
| 2625 |
editor->searchLE->setText("^TWIN"); |
| 2626 |
editor->wholeLine->setChecked(true); |
| 2627 |
editor->replaceAll(); |
| 2628 |
editor->searchLE->setText("^BASF"); |
| 2629 |
editor->replaceAll(); |
| 2630 |
editor->replace->setText(""); |
| 2631 |
editor->searchLE->setText(""); |
| 2632 |
editor->wholeLine->setChecked(false); |
| 2633 |
cursor.movePosition(QTextCursor::Start); |
| 2634 |
cursor = document->find(unitinst,cursor); |
| 2635 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 2636 |
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); |
| 2637 |
cursor.insertText(insertthis); |
| 2638 |
cursor.endEditBlock(); |
| 2639 |
|
| 2640 |
} |
| 2641 |
void Window::idleRotStart(){ |
| 2642 |
if ((ydleStart!=NULL)&&(ydleStop!=NULL)){ |
| 2643 |
ydleStart->setVisible(false); |
| 2644 |
ydleStop->setVisible(true); |
| 2645 |
ydleStart->setEnabled(false); |
| 2646 |
ydleStop->setEnabled(true); |
| 2647 |
} |
| 2648 |
chgl->idl = new QTimer(this); |
| 2649 |
chgl->idl_end = new QTimer(this); |
| 2650 |
connect(chgl->idl, SIGNAL(timeout()), chgl, SLOT(rotateIdle( ))); |
| 2651 |
connect(this,SIGNAL(movedByUser()), this, SLOT(idleRotStop())); |
| 2652 |
if (chgl!=NULL) connect(chgl,SIGNAL(movedByUser()), this, SLOT(idleRotStop()));//we have a signal in chgl as well |
| 2653 |
chgl->idl->start(5); |
| 2654 |
chgl->idl_end->singleShot(36000,this,SLOT(idleRotStop()));//stop this after ca 10 rotations 360/0.5 * 5 *10 |
| 2655 |
// printf("start rotation %d\n",chgl->idl->timerId()); |
| 2656 |
} |
| 2657 |
|
| 2658 |
void Window::idleRotStop(){ |
| 2659 |
if ((ydleStart!=NULL)&&(ydleStop!=NULL)){ |
| 2660 |
ydleStart->setVisible(true); |
| 2661 |
ydleStop->setVisible(false); |
| 2662 |
ydleStart->setEnabled(true); |
| 2663 |
ydleStop->setEnabled(false); |
| 2664 |
} |
| 2665 |
disconnect(this,SIGNAL(movedByUser()),this, SLOT(idleRotStop())); |
| 2666 |
if (chgl!=NULL) { |
| 2667 |
disconnect(chgl,SIGNAL(movedByUser()), this, SLOT(idleRotStop()));//we have a signal in chgl as well |
| 2668 |
if (chgl->idl==NULL) return; |
| 2669 |
} |
| 2670 |
chgl->idl->stop(); |
| 2671 |
chgl->idl->disconnect(); |
| 2672 |
chgl->idl->deleteLater(); |
| 2673 |
// printf("stop rotation\n"); |
| 2674 |
} |
| 2675 |
|
| 2676 |
void Window::setMonoQ(bool vis){ |
| 2677 |
mole.monoQrom=!vis; |
| 2678 |
|
| 2679 |
chgl->update(); |
| 2680 |
} |
| 2681 |
|
| 2682 |
void Window::foversusfc(){ |
| 2683 |
|
| 2684 |
QString fcfname = dirName; |
| 2685 |
fcfname.replace(resorins,".fcf"); |
| 2686 |
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); |
| 2687 |
connect(d,SIGNAL(weg(const QString &)), editor,SLOT(omitsome(const QString &))); |
| 2688 |
d->exec(); |
| 2689 |
delete d; |
| 2690 |
} |
| 2691 |
|
| 2692 |
void Window::toggleHFSAO(bool on){ |
| 2693 |
mole.HFixSuitableAtomsOnly=on; |
| 2694 |
einstellung->beginGroup("HFIX"); |
| 2695 |
//HFixSuitableAtomsOnly= |
| 2696 |
einstellung->setValue("HFixSuitableAtomsOnly0",on); |
| 2697 |
einstellung->endGroup(); |
| 2698 |
} |
| 2699 |
|
| 2700 |
void Window::togOMIT(bool b){ |
| 2701 |
QGroupBox *gpx = findChild<QGroupBox *>("worstReflectionsGPX"); |
| 2702 |
if (gpx!=nullptr){ |
| 2703 |
QList<QCheckBox *> ck = gpx->findChildren<QCheckBox *>(); |
| 2704 |
for (int i=0; i<ck.size();i++){ |
| 2705 |
ck[i]->setChecked(b); |
| 2706 |
} |
| 2707 |
update(); |
| 2708 |
//printf("toggled %d boxes...\n",ck.size()); |
| 2709 |
}else{ |
| 2710 |
printf("cant't find worstReflectionsGPX"); |
| 2711 |
} |
| 2712 |
} |
| 2713 |
|
| 2714 |
void Window::selOmitG5(){ |
| 2715 |
QGroupBox *gpx = findChild<QGroupBox *>("worstReflectionsGPX"); |
| 2716 |
if (gpx!=nullptr){ |
| 2717 |
QList<QCheckBox *> ck = gpx->findChildren<QCheckBox *>(); |
| 2718 |
for (int i=0; i<ck.size();i++){ |
| 2719 |
ck[i]->setChecked(false); |
| 2720 |
QString s=ck[i]->text(); |
| 2721 |
QStringList num = s.split(" ",skipEmptyParts); |
| 2722 |
if ((num.size()==8)&&(num.at(5).toDouble()>5.0)){ |
| 2723 |
ck[i]->setChecked(true); |
| 2724 |
} |
| 2725 |
} |
| 2726 |
update(); |
| 2727 |
}else{ |
| 2728 |
printf("cant't find worstReflectionsGPX"); |
| 2729 |
} |
| 2730 |
} |
| 2731 |
|
| 2732 |
void Window::selOmitG10(){ |
| 2733 |
QGroupBox *gpx = findChild<QGroupBox *>("worstReflectionsGPX"); |
| 2734 |
if (gpx!=nullptr){ |
| 2735 |
QList<QCheckBox *> ck = gpx->findChildren<QCheckBox *>(); |
| 2736 |
for (int i=0; i<ck.size();i++){ |
| 2737 |
ck[i]->setChecked(false); |
| 2738 |
QString s=ck[i]->text(); |
| 2739 |
QStringList num = s.split(" ",skipEmptyParts); |
| 2740 |
if ((num.size()==8)&&(num.at(5).toDouble()>10.0)){ |
| 2741 |
ck[i]->setChecked(true); |
| 2742 |
} |
| 2743 |
} |
| 2744 |
update(); |
| 2745 |
}else{ |
| 2746 |
printf("cant't find worstReflectionsGPX"); |
| 2747 |
} |
| 2748 |
} |
| 2749 |
|
| 2750 |
void Window::omitRfl(){ |
| 2751 |
QGroupBox *gpx = findChild<QGroupBox *>("worstReflectionsGPX"); |
| 2752 |
if (gpx!=nullptr){ |
| 2753 |
QList<QCheckBox *> ck = gpx->findChildren<QCheckBox *>(); |
| 2754 |
QString omitstring; |
| 2755 |
for (int i=0; i<ck.size();i++){ |
| 2756 |
if (ck[i]->isChecked()){ |
| 2757 |
QString s=ck[i]->text(); |
| 2758 |
QStringList num = s.split(" ",skipEmptyParts); |
| 2759 |
omitstring.append(QString("OMIT %1 %2 %3\n").arg(num.at(0)).arg(num.at(1)).arg(num.at(2))); |
| 2760 |
} |
| 2761 |
} |
| 2762 |
editor->omitsome(omitstring); |
| 2763 |
}else{ |
| 2764 |
printf("cant't find worstReflectionsGPX"); |
| 2765 |
} |
| 2766 |
} |
| 2767 |
|
| 2768 |
void Window::worstReflections(){ |
| 2769 |
QString listName=dirName; |
| 2770 |
listName.replace(punktins,".lst"); |
| 2771 |
listName.replace(punktres,".lst"); |
| 2772 |
QFile lstf(listName); |
| 2773 |
if (lstf.open(QIODevice::ReadOnly|QIODevice::Text)){ |
| 2774 |
QDialog *mdr = new QDialog(this); |
| 2775 |
QScrollArea *qsa = new QScrollArea(mdr); |
| 2776 |
//mdr->set |
| 2777 |
QGroupBox *gpx = new QGroupBox("Check Refelextions to omit.",mdr); |
| 2778 |
gpx->setObjectName("worstReflectionsGPX"); |
| 2779 |
QVBoxLayout *lt = new QVBoxLayout(gpx); |
| 2780 |
QVBoxLayout *la = new QVBoxLayout(); |
| 2781 |
QFont font; |
| 2782 |
font.setFamily("Droid Sans Mono"); |
| 2783 |
la->addWidget(new QLabel("Most Disagreeable Reflections (* if suppressed or used for Rfree).\n\ |
| 2784 |
Error/esd is calculated as sqrt(wD^2/<wD^2>) where w is given by the weight\n\ |
| 2785 |
formula, D = Fo^2-Fc^2 and <> refers to the average over all reflections.",mdr)); |
| 2786 |
QCheckBox *allx; |
| 2787 |
lt->addWidget(allx = new QCheckBox(QString(" h k l Fo^2 Fc^2 Error/esd Fc/Fc(max) Resolution(A)"))); |
| 2788 |
connect(allx,SIGNAL(toggled(bool)),this, SLOT(togOMIT(bool))); |
| 2789 |
allx->setFont(font); |
| 2790 |
QStringList liste=QString(lstf.readAll()).split('\n'); |
| 2791 |
int moststart=liste.indexOf(" h k l Fo^2 Fc^2 Error/esd Fc/Fc(max) Resolution(A)"); |
| 2792 |
if (moststart>0)for (int i=moststart+2; i<liste.size();i++){ |
| 2793 |
QStringList num=liste.at(i).split(" ",skipEmptyParts); |
| 2794 |
if (num.size()==8){ |
| 2795 |
QCheckBox *bx; |
| 2796 |
lt->addWidget(bx = new QCheckBox(QString("%1%2%3 %4 %5 %6 %7 %8") |
| 2797 |
.arg(num.at(0).toInt(),4) |
| 2798 |
.arg(num.at(1).toInt(),4) |
| 2799 |
.arg(num.at(2).toInt(),4) |
| 2800 |
.arg(num.at(3).toDouble(),10,'f',3) |
| 2801 |
.arg(num.at(4).toDouble(),10,'f',3) |
| 2802 |
.arg(num.at(5).toDouble(),10,'f',3) |
| 2803 |
.arg(num.at(6).toDouble(),10,'f',3) |
| 2804 |
.arg(num.at(7).toDouble(),10,'f',3))); |
| 2805 |
bx->setFont(font); |
| 2806 |
/* |
| 2807 |
printf("%4d%4d%4d %10.3f %10.3f %10.3f %10.3f %10.3f\n" |
| 2808 |
,num.at(0).toInt() |
| 2809 |
,num.at(1).toInt() |
| 2810 |
,num.at(2).toInt() |
| 2811 |
,num.at(3).toDouble() |
| 2812 |
,num.at(4).toDouble() |
| 2813 |
,num.at(5).toDouble() |
| 2814 |
,num.at(6).toDouble() |
| 2815 |
,num.at(7).toDouble());*/ |
| 2816 |
}else break; |
| 2817 |
} |
| 2818 |
//printf("Most Disagreeable Reflections %d %d\n", moststart,static_cast<int>(liste.size())); |
| 2819 |
gpx->setLayout(lt); |
| 2820 |
qsa->setWidget(gpx); |
| 2821 |
la->addWidget(qsa); |
| 2822 |
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Cancel,Qt::Horizontal,mdr); |
| 2823 |
QPushButton *omit = bb->addButton("OMIT selected Refelections",QDialogButtonBox::AcceptRole); |
| 2824 |
QPushButton *g5 = bb->addButton("select Refelections Error/esd > 5",QDialogButtonBox::ApplyRole); |
| 2825 |
QPushButton *g10 = bb->addButton("select Refelections Error/esd > 10",QDialogButtonBox::ApplyRole); |
| 2826 |
connect(omit,SIGNAL(clicked()),this,SLOT(omitRfl())); |
| 2827 |
connect(g10,SIGNAL(clicked()),this,SLOT(selOmitG10())); |
| 2828 |
connect(g5,SIGNAL(clicked()),this,SLOT(selOmitG5())); |
| 2829 |
connect(bb, SIGNAL(accepted()), mdr, SLOT(accept())); |
| 2830 |
connect(bb, SIGNAL(rejected()), mdr, SLOT(reject())); |
| 2831 |
la->addWidget(bb); |
| 2832 |
mdr->setLayout(la); |
| 2833 |
mdr->exec(); |
| 2834 |
mdr->deleteLater(); |
| 2835 |
} |
| 2836 |
} |
| 2837 |
|
| 2838 |
void Window::delayedLoad(){ |
| 2839 |
printf("...load in 150ms\n"); |
| 2840 |
tim = new QTimer(this); |
| 2841 |
tim->setSingleShot(true); |
| 2842 |
connect(tim,SIGNAL(timeout()),this,SLOT(loadAFile())); |
| 2843 |
tim->start(150); |
| 2844 |
} |
| 2845 |
|
| 2846 |
void Window::loadAFile(){ |
| 2847 |
/* |
| 2848 |
einstellung->beginGroup("Window"); |
| 2849 |
einstellung->setValue("QuickReLoad",quickReLoadButton->isChecked()); |
| 2850 |
einstellung->endGroup(); |
| 2851 |
*/ |
| 2852 |
|
| 2853 |
printf("...load now\n"); |
| 2854 |
|
| 2855 |
loadFile(dirName); |
| 2856 |
} |
| 2857 |
|
| 2858 |
void Window::openSaveHistory(){ |
| 2859 |
if ((dirName.isEmpty())||(!QFile::exists(dirName))) return; |
| 2860 |
SaveHistoryWidget *shw = new SaveHistoryWidget(dirName,(QString(PROGRAM_NAME).compare("shelXle")==0)?darkTheme->isChecked():false); |
| 2861 |
if (QDialog::Accepted==shw->exec()) { |
| 2862 |
if ((quickReLoadButton->isChecked())) sdm(); |
| 2863 |
loadFile(dirName); |
| 2864 |
if ((quickReLoadButton->isChecked())) sdm(); |
| 2865 |
} |
| 2866 |
delete shw; |
| 2867 |
} |
| 2868 |
|
| 2869 |
void Window::adoptEditToolBar(bool b){ |
| 2870 |
if (b) shxMW->addToolBar(editToolBar); |
| 2871 |
else addToolBar(editToolBar); |
| 2872 |
einstellung->beginGroup("Window"); |
| 2873 |
einstellung->setValue("EditorHasOwnToolBar",b); |
| 2874 |
einstellung->endGroup(); |
| 2875 |
update(); |
| 2876 |
} |
| 2877 |
|
| 2878 |
void Window::toggleEQHighlighting(bool b){ |
| 2879 |
mole.highlightEquivalents = b; |
| 2880 |
chgl->update(); |
| 2881 |
} |
| 2882 |
|
| 2883 |
void Window::toggleOrtho(bool ov){ |
| 2884 |
|
| 2885 |
|
| 2886 |
//printf("toggleOrtho %d\n",__LINE__); |
| 2887 |
chgl->toggleOrtho(ov); |
| 2888 |
chgl->update(); |
| 2889 |
/*if ((ov)&&(togDepthCueing->isChecked())){ |
| 2890 |
togDepthCueing->setChecked(false); |
| 2891 |
chgl->setDepthCueing(false); |
| 2892 |
//printf("toggleOrtho %d\n",__LINE__); |
| 2893 |
} |
| 2894 |
togDepthCueing->setDisabled(ov);*/ |
| 2895 |
//chgl->setViewAngle((ov)?0.1:29.0); |
| 2896 |
einstellung->beginGroup("ViewSettings"); |
| 2897 |
einstellung->setValue("OrthographicProjection",ov); |
| 2898 |
einstellung->endGroup(); |
| 2899 |
} |
| 2900 |
|
| 2901 |
int Window::getFvarCntr(int fvar){ |
| 2902 |
return fvarCntr.value(fvar); |
| 2903 |
} |
| 2904 |
|
| 2905 |
void Window::growQPeaks(bool qpg){ |
| 2906 |
mole.growQPeak=qpg; |
| 2907 |
|
| 2908 |
bool growYes=chgl->fuse->isVisible (); |
| 2909 |
chgl->mol->fuse(); |
| 2910 |
if (growYes) chgl->mol->grow(); |
| 2911 |
|
| 2912 |
loadMolInTest(); |
| 2913 |
chgl->update(); |
| 2914 |
} |
| 2915 |
|
| 2916 |
void Window::spellCheck(){ |
| 2917 |
QString t=editor->toPlainText(); |
| 2918 |
if (t==altText) return; |
| 2919 |
altText=t; |
| 2920 |
QRegularExpression rx=QRegularExpression("\\s|_"); |
| 2921 |
QRegularExpression nch=QRegularExpression("[^\"\\-~#%&$'`§()+\\*\\./@\\[\\]^\\\\{}\\|<>A-Za-z0-9]+"); |
| 2922 |
QString s,s0; |
| 2923 |
QString meld; |
| 2924 |
editor->errorInLine.clear(); |
| 2925 |
bool cont=false; |
| 2926 |
QStringList sl; |
| 2927 |
for (int i= 0;i< editor->blocks.size(); i++){ |
| 2928 |
sl = editor->blocks.at(i).split(" ",skipEmptyParts); |
| 2929 |
if (sl.isEmpty())continue; |
| 2930 |
if ((cont)&&(editor->blocks.at(i).contains(QRegularExpression("^\\S+")))){ |
| 2931 |
editor->errorInLine.append(i-1); |
| 2932 |
editor->errorInLine.append(i); |
| 2933 |
meld+=QString("ERROR in line %1: Bad continuation line!<br>").arg(i); |
| 2934 |
} |
| 2935 |
cont=false; |
| 2936 |
if (sl.isEmpty())continue; |
| 2937 |
cont= (!(sl.at(0).contains(QRegularExpression("(^REM)|(^TITL)",QRegularExpression::CaseInsensitiveOption)))&&(editor->blocks.at(i).contains(QRegularExpression("=\\s*$")))); |
| 2938 |
if((editor->blocks.at(i).size()>SX_LINE_LENGTH)&&(!editor->blocks.at(i).contains(QRegularExpression("^\\s+")))){ |
| 2939 |
editor->errorInLine.append(i); |
| 2940 |
meld+=QString("ERROR in line %1: Line is too long for SHELXL!<br>").arg(i+1); |
| 2941 |
} |
| 2942 |
if (editor->blocks.at(i).startsWith(" ")) continue; |
| 2943 |
if (isacommand(sl.at(0))==-1){ |
| 2944 |
s0=sl.at(0).section(rx,0,0); |
| 2945 |
if (s0.size()>4) { |
| 2946 |
meld+=QString("ERROR in line %1: Atom label too long %2!<br>").arg(i+1).arg(sl.at(0)); |
| 2947 |
editor->errorInLine.append(i); |
| 2948 |
} |
| 2949 |
if (sl.at(0).contains(nch)) { |
| 2950 |
meld+=QString("ERROR in line %1: Not allowed characters in atom label %2!<br>").arg(i+1).arg(sl.at(0)); |
| 2951 |
editor->errorInLine.append(i); |
| 2952 |
} |
| 2953 |
bool bb=true; |
| 2954 |
if (sl.size()>1) { |
| 2955 |
s=sl.at(1); |
| 2956 |
int ii = s.toInt(&bb); |
| 2957 |
if ((sl.size()>3)&&((ii<1)||(!bb))) { |
| 2958 |
meld+=QString("ERROR in line %1: Scatering-factor number is missing or out of range!<br>").arg(i+1); |
| 2959 |
editor->errorInLine.append(i); |
| 2960 |
} |
| 2961 |
} |
| 2962 |
} |
| 2963 |
} |
| 2964 |
FehlerTeufel= !meld.isEmpty(); |
| 2965 |
if (FehlerTeufel) infoKanalNews("<font color=red size=+1>"+meld+"</font>"); |
| 2966 |
else infoKanalNews(""); |
| 2967 |
spellCheckact->setVisible(FehlerTeufel); |
| 2968 |
spellCheckact2->setVisible(FehlerTeufel); |
| 2969 |
editor->update(); |
| 2970 |
} |
| 2971 |
|
| 2972 |
void Window::exportCoordinates(){ |
| 2973 |
QString exportName = dirName; |
| 2974 |
exportName.replace(resorins,"_EXPORTED.res"); |
| 2975 |
QString fn=QFileDialog::getSaveFileName(this, tr("Export all visible atoms"), exportName, tr("SHELX-files (*.res *.ins)")); |
| 2976 |
if (fn.isEmpty()) return; |
| 2977 |
QFile f(fn); |
| 2978 |
QString body; |
| 2979 |
body.append(QString("TITL %1\nCELL %2 %3 %4 %5 %6 %7 %8\n%9\n") |
| 2980 |
.arg(title) |
| 2981 |
.arg(mole.cell.wave ) |
| 2982 |
.arg(mole.cell.a ) |
| 2983 |
.arg(mole.cell.b ) |
| 2984 |
.arg(mole.cell.c ) |
| 2985 |
.arg(mole.cell.al ) |
| 2986 |
.arg(mole.cell.be ) |
| 2987 |
.arg(mole.cell.ga ) |
| 2988 |
.arg(mole.cell.Z ) |
| 2989 |
); |
| 2990 |
body.append(QString("LATT -1\n")); |
| 2991 |
for (int i=1; i<mole.cell.symmops.size();i++){ |
| 2992 |
body.append(QString("SYMM %1\n").arg(mole.symmcode2human(i))); |
| 2993 |
} |
| 2994 |
body.append(QString("SFAC ")); |
| 2995 |
for (int i=0; i<editor->sfac.size(); i++){ |
| 2996 |
body.append(QString("%1 ").arg(mole.pse(editor->sfac.at(i)))); |
| 2997 |
} |
| 2998 |
body.append("\n"); |
| 2999 |
body.append(editor->unitNeu); |
| 3000 |
body.append( |
| 3001 |
"\n\nREM ######################################################\n" |
| 3002 |
"REM This file exported by ShelXle is for information or \n" |
| 3003 |
"REM visualiztion purposes only. You may run into trouble \n" |
| 3004 |
"REM if you try to refine it against data.\n" |
| 3005 |
"REM DISABLE_REFINE\n" |
| 3006 |
"REM ######################################################\n\n"); |
| 3007 |
body.append("FVAR 1.00 "); |
| 3008 |
for (int i=0; i<fvar.size();i++){ |
| 3009 |
body.append(QString("%1 ").arg(fvar.at(i))); |
| 3010 |
} |
| 3011 |
body.append("\n\n"); |
| 3012 |
int part=0,resi=0; |
| 3013 |
chgl->rehide(); |
| 3014 |
for (int i=0; i< mole.showatoms.size(); i++){ |
| 3015 |
if (mole.showatoms.at(i).hidden) continue; |
| 3016 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 3017 |
if ((mole.showatoms.at(i).an!=-42)&&(mole.showatoms.at(i).resiNr!=resi)) |
| 3018 |
body.append(QString("RESI %1 %2\n").arg(mole.showatoms.at(i).resiNr).arg(mole.showatoms.at(i).ResiClass)); |
| 3019 |
if ((mole.showatoms.at(i).an!=-42)&&(mole.showatoms.at(i).part!=part)) |
| 3020 |
body.append(QString("PART %1\n").arg(mole.showatoms.at(i).part)); |
| 3021 |
if (mole.showatoms.at(i).an==-1) |
| 3022 |
body.append(QString("%1 %2 %3 %4 %5 %6 %7 %8\n") |
| 3023 |
.arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) |
| 3024 |
.arg(qMax(1,editor->sfac.indexOf(mole.showatoms.at(i).an)+1)) |
| 3025 |
.arg(mole.showatoms.at(i).frac.x,10,'f',6) |
| 3026 |
.arg(mole.showatoms.at(i).frac.y,10,'f',6) |
| 3027 |
.arg(mole.showatoms.at(i).frac.z,10,'f',6) |
| 3028 |
.arg(mole.showatoms.at(i).sof_org,9,'f',5) |
| 3029 |
.arg(mole.showatoms.at(i).uf.m33,9,'f',5) |
| 3030 |
.arg(mole.showatoms.at(i).peakHeight,9,'f',2) |
| 3031 |
); |
| 3032 |
else if (mole.showatoms.at(i).an==-42){ |
| 3033 |
Matrix uf = mole.b2u(mole.showatoms.at(i).uf); |
| 3034 |
body.append(QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12\n") |
| 3035 |
.arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) |
| 3036 |
.arg(2) |
| 3037 |
.arg(mole.showatoms.at(i).frac.x,10,'f',6) |
| 3038 |
.arg(mole.showatoms.at(i).frac.y,10,'f',6) |
| 3039 |
.arg(mole.showatoms.at(i).frac.z,10,'f',6) |
| 3040 |
.arg(mole.showatoms.at(i).sof_org,9,'f',5) |
| 3041 |
.arg(uf.m11,9,'f',5) |
| 3042 |
.arg(uf.m22,9,'f',5) |
| 3043 |
.arg(uf.m33,9,'f',5) |
| 3044 |
.arg(uf.m23,9,'f',5) |
| 3045 |
.arg(uf.m13,9,'f',5) |
| 3046 |
.arg(uf.m12,9,'f',5) |
| 3047 |
); |
| 3048 |
} |
| 3049 |
else {if (mole.showatoms.at(i).isIso){ |
| 3050 |
body.append(QString("%1 %2 %3 %4 %5 %6 %7!x\n") |
| 3051 |
.arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) |
| 3052 |
.arg(qMax(1,editor->sfac.indexOf(mole.showatoms.at(i).an)+1)) |
| 3053 |
.arg(mole.showatoms.at(i).frac.x,10,'f',6) |
| 3054 |
.arg(mole.showatoms.at(i).frac.y,10,'f',6) |
| 3055 |
.arg(mole.showatoms.at(i).frac.z,10,'f',6) |
| 3056 |
.arg(mole.showatoms.at(i).sof_org,9,'f',5) |
| 3057 |
.arg(mole.showatoms.at(i).ufiso_org) |
| 3058 |
); |
| 3059 |
}else{ |
| 3060 |
body.append(QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12\n") |
| 3061 |
.arg(mole.showatoms.at(i).Label.section('_',0,0).section(QString::fromUtf8("»"),0,0),-5) |
| 3062 |
.arg(qMax(1,editor->sfac.indexOf(mole.showatoms.at(i).an)+1)) |
| 3063 |
.arg(mole.showatoms.at(i).frac.x,10,'f',6) |
| 3064 |
.arg(mole.showatoms.at(i).frac.y,10,'f',6) |
| 3065 |
.arg(mole.showatoms.at(i).frac.z,10,'f',6) |
| 3066 |
.arg(mole.showatoms.at(i).sof_org,9,'f',5) |
| 3067 |
.arg(mole.showatoms.at(i).uf.m11,9,'f',5) |
| 3068 |
.arg(mole.showatoms.at(i).uf.m22,9,'f',5) |
| 3069 |
.arg(mole.showatoms.at(i).uf.m33,9,'f',5) |
| 3070 |
.arg(mole.showatoms.at(i).uf.m23,9,'f',5) |
| 3071 |
.arg(mole.showatoms.at(i).uf.m13,9,'f',5) |
| 3072 |
.arg(mole.showatoms.at(i).uf.m12,9,'f',5) |
| 3073 |
); |
| 3074 |
}} |
| 3075 |
part=mole.showatoms.at(i).part; |
| 3076 |
resi=mole.showatoms.at(i).resiNr; |
| 3077 |
} |
| 3078 |
|
| 3079 |
body.append("\n\n"); |
| 3080 |
QString eqi=mole.symmcode2human(mole.usedSymmetry); |
| 3081 |
eqi.replace("»","EQIV $"); |
| 3082 |
eqi.replace(":",""); |
| 3083 |
eqi.replace("<b>",""); |
| 3084 |
eqi.replace("</b>",""); |
| 3085 |
eqi.replace("<br>","\n"); |
| 3086 |
body.append(eqi); |
| 3087 |
body.append("\n\n"); |
| 3088 |
for (int i =0; i<mole.showbonds.size();i++){ |
| 3089 |
if (mole.showbonds.at(i).ato1->hidden) continue; |
| 3090 |
if (mole.showbonds.at(i).ato2->hidden) continue; |
| 3091 |
if ((mole.nopm1)&&(mole.showbonds.at(i).ato1->symmGroup)&&(mole.showbonds.at(i).ato1->part<0))continue; // |
| 3092 |
if ((mole.nopm1)&&(mole.showbonds.at(i).ato2->symmGroup)&&(mole.showbonds.at(i).ato2->part<0))continue; // ignore hidden parts (-1) |
| 3093 |
QString s1="",s2="",s3=""; |
| 3094 |
s1=mole.showbonds.at(i).ato1->Label; |
| 3095 |
s2=mole.showbonds.at(i).ato2->Label; |
| 3096 |
s1=s1.section(QString::fromUtf8("»"),0,0); |
| 3097 |
s2=s2.section(QString::fromUtf8("»"),0,0); |
| 3098 |
if ((mole.showbonds.at(i).ato2->symmGroup)||(mole.showbonds.at(i).ato1->symmGroup)) |
| 3099 |
s3.append(QString("_$%1").arg(qMax(mole.showbonds.at(i).ato1->symmGroup,mole.showbonds.at(i).ato2->symmGroup))); |
| 3100 |
body.append(QString("BIND%3 %1 %2\n") |
| 3101 |
.arg(s1) |
| 3102 |
.arg(s2) |
| 3103 |
.arg(s3)); |
| 3104 |
} |
| 3105 |
body.append("\nHKLF 0 !don't refine this\nEND\n"); |
| 3106 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 3107 |
if (success){ |
| 3108 |
f.write(body.toLatin1()); |
| 3109 |
f.close(); |
| 3110 |
} |
| 3111 |
} |
| 3112 |
|
| 3113 |
void Window::changeIconSize(){ |
| 3114 |
bool ok; |
| 3115 |
int tbs=tbiconSize; |
| 3116 |
|
| 3117 |
#if (QT_VERSION >= 0x040500) |
| 3118 |
tbs=QInputDialog::getInt(this,"Change tool bar icon size...","Tool bar icon size:",tbiconSize,16,96,1,&ok); |
| 3119 |
#else |
| 3120 |
tbs=QInputDialog::getInteger(this,"Change tool bar icon size...","Tool bar icon size:",tbiconSize,16,32,1,&ok); |
| 3121 |
#endif |
| 3122 |
if (ok) tbiconSize=tbs; |
| 3123 |
einstellung->beginGroup("ToolBarIcons"); |
| 3124 |
einstellung->setValue("ToolBarIconSize",tbiconSize); |
| 3125 |
einstellung->endGroup(); |
| 3126 |
fito->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3127 |
editToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3128 |
refineToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3129 |
vito->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3130 |
extraTB->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3131 |
bottomToolBar->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3132 |
chgl->invertMouseZoom->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3133 |
homeMe->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3134 |
zoomIn->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3135 |
zoomOut->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 3136 |
update(); |
| 3137 |
} |
| 3138 |
|
| 3139 |
void Window::changeQPeakLimit(){ |
| 3140 |
bool ok; |
| 3141 |
int limit=MaxNumberOfPeaks; |
| 3142 |
|
| 3143 |
#if (QT_VERSION >= 0x040500) |
| 3144 |
limit=QInputDialog::getInt(this,"Change maximum number of created Q-peaks","maximum number of created Q-peaks:",MaxNumberOfPeaks,1,600,1,&ok); |
| 3145 |
#else |
| 3146 |
limit=QInputDialog::getInteger(this,"Change maximum number of created Q-peaks","maximum number of created Q-peaks:",MaxNumberOfPeaks,1,600,1,&ok); |
| 3147 |
#endif |
| 3148 |
if (ok) MaxNumberOfPeaks=limit; |
| 3149 |
actionQPeakLimit->setText(QString("change maximum number of created Q-peaks (%1)").arg(MaxNumberOfPeaks)); |
| 3150 |
update(); |
| 3151 |
} |
| 3152 |
|
| 3153 |
void Window::jnk(){ |
| 3154 |
if (!fxle->doMaps->isChecked())fxle->doMaps->setChecked(true); |
| 3155 |
fxle->maptrunc=fxle->mapSchnitt->currentIndex (); |
| 3156 |
if ((fxle->rw!=fxle->weak->value())||(fxle->rr!=fxle->mapprec->value())){ |
| 3157 |
fxle->rr = fxle->mapprec->value(); |
| 3158 |
fxle->rw = fxle->weak->value(); |
| 3159 |
if (!fxle->loadFouAndPerform(fxle->fouName.toLocal8Bit(),false)){ |
| 3160 |
infoKanalNews(QString("<font color=red>Error while loading %1!</font><br>").arg(fxle->fouName)); |
| 3161 |
//printf("%d\n",__LINE__); |
| 3162 |
fxle->killmaps(); |
| 3163 |
//printf("%d\n",__LINE__); |
| 3164 |
} |
| 3165 |
} |
| 3166 |
chgl->lintrans = fxle->lineTrans->value(); |
| 3167 |
chgl->linwidth = fxle->lineWidth->value(); |
| 3168 |
fxle->map_radius = fxle->maprad->value(); |
| 3169 |
fxle->iso[0] = fxle->fomaps->value(); |
| 3170 |
fxle->iso[1] = -fxle->difmaps->value(); |
| 3171 |
fxle->jnk(); |
| 3172 |
} |
| 3173 |
|
| 3174 |
void Window::deleteAllQ(){ |
| 3175 |
|
| 3176 |
if (editor->sfac.isEmpty()) return; |
| 3177 |
bool isQ = false; |
| 3178 |
for (int o = 0; o < mole.asymm.size();o++){ |
| 3179 |
if (mole.asymm.at(o).an == -1){ |
| 3180 |
isQ = true; |
| 3181 |
break; |
| 3182 |
} |
| 3183 |
} |
| 3184 |
if (!isQ) return; |
| 3185 |
QTextCursor cursor = editor->textCursor(); |
| 3186 |
editor->wholeLine->setChecked(false); |
| 3187 |
editor->replace->setText(""); |
| 3188 |
editor->searchLE->setText("^Q\\S+\\s+1\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s*"); |
| 3189 |
for (int i = mole.asymm.size()-1; i>=0; i-- ){ |
| 3190 |
if (mole.asymm.at(i).an==-1){ |
| 3191 |
QString s = |
| 3192 |
QString("<font color=magenta>Deleted atom: %1 part:%2 residue:%3 %4 </font> Please save to update structure view.") |
| 3193 |
.arg(mole.asymm.at(i).Label) |
| 3194 |
.arg(mole.asymm.at(i).part) |
| 3195 |
.arg(mole.asymm.at(i).resiNr) |
| 3196 |
.arg(mole.asymm.at(i).ResiClass); |
| 3197 |
infoKanalNews(s); |
| 3198 |
deletedAtom.append(mole.asymm.at(i)); |
| 3199 |
mole.asymm.removeAt(i); |
| 3200 |
} |
| 3201 |
} |
| 3202 |
editor->replaceAll(); |
| 3203 |
editor->searchLE->setText(""); |
| 3204 |
|
| 3205 |
mole.showatoms.clear(); |
| 3206 |
mole.showbonds.clear(); |
| 3207 |
chgl->mol->showatoms.clear(); |
| 3208 |
chgl->mol->showbonds.clear(); |
| 3209 |
chgl->mol->selectedatoms.clear(); |
| 3210 |
|
| 3211 |
for (int o=0; o<mole.asymm.size();o++) |
| 3212 |
mole.showatoms.append(mole.asymm[o]); |
| 3213 |
mole.packer(mole.sdmcompleter()); |
| 3214 |
mole.showbonds = |
| 3215 |
mole.connecting(mole.showatoms); |
| 3216 |
bool growYes=chgl->fuse->isVisible (); |
| 3217 |
if (growYes) chgl->mol->grow(); |
| 3218 |
else chgl->mol->fuse(); |
| 3219 |
if ((chgl->rotze!=-1)&&(!chgl->enviPositions.isEmpty())){ |
| 3220 |
chgl->envi(); |
| 3221 |
} |
| 3222 |
chgl->mol->selectedatoms.clear(); |
| 3223 |
chgl->showHidden(); |
| 3224 |
|
| 3225 |
|
| 3226 |
// printf("%d\n",__LINE__); |
| 3227 |
|
| 3228 |
loadMolInTest(); |
| 3229 |
chgl->updateBondActions(); |
| 3230 |
chgl->update(); |
| 3231 |
update(); |
| 3232 |
chgl->update(); |
| 3233 |
} |
| 3234 |
|
| 3235 |
void Window::sdm(){ |
| 3236 |
if (!(chgl->fuse->isVisible()||chgl->grow->isVisible ())){ |
| 3237 |
chgl->fuse->setVisible(true); |
| 3238 |
chgl->grow->setVisible(false); |
| 3239 |
} |
| 3240 |
mole.showatoms.clear(); |
| 3241 |
mole.showbonds.clear(); |
| 3242 |
chgl->mol->showatoms.clear(); |
| 3243 |
chgl->mol->showbonds.clear(); |
| 3244 |
chgl->mol->selectedatoms.clear(); |
| 3245 |
for (int o=0; o<mole.asymm.size();o++) |
| 3246 |
mole.showatoms.append(mole.asymm[o]); |
| 3247 |
mole.packer(mole.sdmcompleter()); |
| 3248 |
mole.showbonds = |
| 3249 |
mole.connecting(mole.showatoms); |
| 3250 |
|
| 3251 |
chgl->mol->selectedatoms.clear(); |
| 3252 |
|
| 3253 |
bool growYes=chgl->fuse->isVisible (); |
| 3254 |
chgl->mol->fuse(); |
| 3255 |
if (growYes) chgl->mol->grow(); |
| 3256 |
|
| 3257 |
// printf("%d\n",__LINE__); |
| 3258 |
chgl->updateBondActions(); |
| 3259 |
infoKanalNews(mole.Fragments); |
| 3260 |
chgl->update(); |
| 3261 |
update(); |
| 3262 |
chgl->update(); |
| 3263 |
|
| 3264 |
loadMolInTest(); |
| 3265 |
} |
| 3266 |
|
| 3267 |
void Window::makeVoro(){ |
| 3268 |
int ind=-1; |
| 3269 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 3270 |
if (action!=NULL){ |
| 3271 |
ind=action->data().toInt(); |
| 3272 |
ind=qMax(ind,-1); |
| 3273 |
ind=qMin(ind,mole.asymm.size()-1); |
| 3274 |
} |
| 3275 |
clearVoro->setVisible(true); |
| 3276 |
/*if (tgl) tgl->ogl->voronoij(mole.asymm,ind); |
| 3277 |
else mole.voronoij(mole.asymm,ind);*/ |
| 3278 |
chgl->voronoij(mole.asymm,ind); |
| 3279 |
infoKanalNews(mole.voroMsg); |
| 3280 |
chgl->update(); |
| 3281 |
} |
| 3282 |
|
| 3283 |
void Window::clearVoros(){ |
| 3284 |
mole.vtriangles.clear(); |
| 3285 |
mole.vorobas=0; |
| 3286 |
chgl->voroDestruct(); |
| 3287 |
clearVoro->setVisible(false); |
| 3288 |
chgl->update(); |
| 3289 |
} |
| 3290 |
|
| 3291 |
void Window::deleteAllH(){ |
| 3292 |
if (editor->sfac.isEmpty()) return; |
| 3293 |
bool isH = false; |
| 3294 |
for (int o = 0; o < mole.asymm.size(); o++){ |
| 3295 |
if (mole.asymm.at(o).an == 0){ |
| 3296 |
isH = true; |
| 3297 |
break; |
| 3298 |
} |
| 3299 |
} |
| 3300 |
if (!isH) return; |
| 3301 |
/* maybeSave2(); |
| 3302 |
printf("deleteallh %d %d\n",mole.asymm.size(),chgl->mol->showatoms.size());*/ |
| 3303 |
chgl->mol->selectedatoms.clear(); |
| 3304 |
for (int o = 0; o < mole.asymm.size(); o++){ |
| 3305 |
if (mole.asymm.at(o).an == 0){ |
| 3306 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[o]); |
| 3307 |
chgl->mol->selectedatoms.last().style=o; |
| 3308 |
} |
| 3309 |
} |
| 3310 |
deleteSelectedAtoms(); |
| 3311 |
} |
| 3312 |
|
| 3313 |
void Window::deleteSelectedAtoms(){ |
| 3314 |
if (chgl->mol->selectedatoms.isEmpty()){ |
| 3315 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 3316 |
int index=-1; |
| 3317 |
if (action) |
| 3318 |
index=action->data().toInt(); |
| 3319 |
else index=-1; |
| 3320 |
if (index>mole.asymm.size()) index=-1; |
| 3321 |
if (index!=-1) { |
| 3322 |
chgl->mol->selectedatoms.clear(); |
| 3323 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[index]); |
| 3324 |
chgl->mol->selectedatoms.last().style=index; |
| 3325 |
} |
| 3326 |
} |
| 3327 |
if (chgl->mol->selectedatoms.isEmpty()) return; |
| 3328 |
|
| 3329 |
bool donotsymm=false; |
| 3330 |
QTextCursor cursor = editor->textCursor(); |
| 3331 |
QTextDocument *document = editor->document(); |
| 3332 |
cursor.beginEditBlock(); |
| 3333 |
int ende=chgl->mol->selectedatoms.size(); |
| 3334 |
for (int i = 0; i < ende; i++ ){ |
| 3335 |
if (chgl->mol->selectedatoms.at(i).symmGroup) continue; |
| 3336 |
if (chgl->mol->selectedatoms.at(i).Label.contains(QString::fromUtf8("»")))continue; |
| 3337 |
if ((chgl->mol->selectedatoms.at(i).afix>0)&&(chgl->mol->selectedatoms.at(i).an>0)) continue; |
| 3338 |
int wg=chgl->mol->selectedatoms.at(i).style; |
| 3339 |
QString label = mole.asymm.at(wg).orginalLine.left(80).trimmed(); |
| 3340 |
cursor.movePosition(QTextCursor::Start); |
| 3341 |
cursor = document->find(label,cursor); |
| 3342 |
if (cursor.isNull()){ |
| 3343 |
cursor = editor->textCursor(); |
| 3344 |
cursor.movePosition(QTextCursor::Start); |
| 3345 |
label.chop(10); |
| 3346 |
cursor = document->find(label,cursor); |
| 3347 |
if (cursor.isNull()) { |
| 3348 |
cursor = editor->textCursor(); |
| 3349 |
printf("hab was nicht %d/%d %d [%s]\n",i,ende,static_cast<int>(chgl->mol->selectedatoms.size()),label.toStdString().c_str()); |
| 3350 |
continue; |
| 3351 |
} |
| 3352 |
} |
| 3353 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 3354 |
//printf("wg2160->%d %s\n",wg,label.toStdString().c_str()); |
| 3355 |
bool afx=false; |
| 3356 |
if (editor->parenthesis.at(cursor.blockNumber())){ |
| 3357 |
afx=true; |
| 3358 |
do { |
| 3359 |
if (!cursor.block().text().contains("afix",Qt::CaseInsensitive)) wg--; |
| 3360 |
cursor.movePosition(QTextCursor::Up,QTextCursor::MoveAnchor); |
| 3361 |
}while(!cursor.block().text().contains("afix",Qt::CaseInsensitive)); |
| 3362 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 3363 |
} |
| 3364 |
//printf("wg2168->%d [%s] {%s}\n",wg,cursor.selectedText().toStdString().c_str(),cursor.block().text().toStdString().c_str()); |
| 3365 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 3366 |
while (cursor.selectedText().endsWith("=")) { |
| 3367 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 3368 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 3369 |
} |
| 3370 |
int haa=1; |
| 3371 |
if (afx) |
| 3372 |
while (!cursor.block().text().contains("afix",Qt::CaseInsensitive)){ |
| 3373 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 3374 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 3375 |
if ((!cursor.block().text().contains("afix",Qt::CaseInsensitive))&&(wg+haa)<chgl->mol->showatoms.size()){ |
| 3376 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms.at(wg+haa)); |
| 3377 |
chgl->mol->selectedatoms.last().style=wg+haa; |
| 3378 |
haa++; |
| 3379 |
} |
| 3380 |
/* printf("wg+ =%d %d/%d %d\n",wg+haa,cursor.blockNumber()+2,(editor->parenthesis.size()),editor->blockCount()); |
| 3381 |
printf("[[%s]]\n", cursor.selectedText().toStdString().c_str()); |
| 3382 |
printf("%d %d!\n",editor->parenthesis.at(cursor.blockNumber()+1),editor->parenthesis.at(cursor.blockNumber()+2)); |
| 3383 |
*/ |
| 3384 |
} |
| 3385 |
//printf("wg2191->[%s]\n",cursor.selectedText().toStdString().c_str()); |
| 3386 |
cursor.deleteChar(); |
| 3387 |
cursor.deleteChar(); |
| 3388 |
editor->updateAfix(); |
| 3389 |
} |
| 3390 |
|
| 3391 |
for (int i = chgl->mol->selectedatoms.size()-1; i>=0; i-- ){ |
| 3392 |
if (chgl->mol->selectedatoms.at(i).Label.contains(QString::fromUtf8("»"))){donotsymm=true;continue;} |
| 3393 |
if (chgl->mol->selectedatoms.at(i).symmGroup){donotsymm=true;continue;} |
| 3394 |
QString s = |
| 3395 |
QString("<font color=magenta>Deleted atom: %1 part:%2 residue:%3 %4 </font> Please save to update structure view.") |
| 3396 |
.arg(chgl->mol->selectedatoms.at(i).Label) |
| 3397 |
.arg(chgl->mol->selectedatoms.at(i).part) |
| 3398 |
.arg(chgl->mol->selectedatoms.at(i).resiNr) |
| 3399 |
.arg(chgl->mol->selectedatoms.at(i).ResiClass); |
| 3400 |
infoKanalNews(s); |
| 3401 |
int wg=mole.asymm.indexOf(chgl->mol->selectedatoms.at(i)); |
| 3402 |
if (wg<0) continue; |
| 3403 |
deletedAtom.append(mole.asymm.at(wg)); |
| 3404 |
mole.asymm.removeAt(wg); |
| 3405 |
} |
| 3406 |
|
| 3407 |
cursor.endEditBlock(); |
| 3408 |
|
| 3409 |
mole.showatoms.clear(); |
| 3410 |
mole.showbonds.clear(); |
| 3411 |
chgl->mol->showatoms.clear(); |
| 3412 |
chgl->mol->showbonds.clear(); |
| 3413 |
chgl->mol->selectedatoms.clear(); |
| 3414 |
for (int o=0; o<mole.asymm.size();o++) |
| 3415 |
mole.showatoms.append(mole.asymm[o]); |
| 3416 |
mole.packer(mole.sdmcompleter()); |
| 3417 |
mole.showbonds = |
| 3418 |
mole.connecting(mole.showatoms); |
| 3419 |
|
| 3420 |
chgl->setMolecule(&mole); |
| 3421 |
loadMolInTest(); |
| 3422 |
|
| 3423 |
|
| 3424 |
chgl->mol->selectedatoms.clear(); |
| 3425 |
|
| 3426 |
|
| 3427 |
bool growYes=chgl->fuse->isVisible (); |
| 3428 |
chgl->mol->fuse(); |
| 3429 |
if (growYes) chgl->mol->grow(); |
| 3430 |
|
| 3431 |
switch (duplicates()){ |
| 3432 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 3433 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 3434 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 3435 |
} |
| 3436 |
if (donotsymm) QMessageBox::information(0,"information","Only unique atoms can be deleted!"); |
| 3437 |
|
| 3438 |
// printf("%d\n",__LINE__); |
| 3439 |
|
| 3440 |
loadMolInTest(); |
| 3441 |
chgl->updateBondActions(); |
| 3442 |
chgl->update(); |
| 3443 |
update(); |
| 3444 |
chgl->update(); |
| 3445 |
/* |
| 3446 |
} |
| 3447 |
else {chgl->disSelection();}*/ |
| 3448 |
} |
| 3449 |
|
| 3450 |
void Window::createCentroid(){ |
| 3451 |
if (chgl->mol->selectedatoms.isEmpty()) return; |
| 3452 |
|
| 3453 |
QTextCursor cursor = editor->textCursor(); |
| 3454 |
QTextDocument *document = editor->document(); |
| 3455 |
cursor.beginEditBlock(); |
| 3456 |
int ctrcnt=1; |
| 3457 |
for (int i=0; i<mole.asymm.size();i++){ |
| 3458 |
if ((mole.asymm.at(i).an==-66)&&(mole.asymm.at(i).Label.startsWith("Cnt",Qt::CaseInsensitive))) |
| 3459 |
ctrcnt++; |
| 3460 |
} |
| 3461 |
int ende=chgl->mol->selectedatoms.size(); |
| 3462 |
V3 posc = V3(0,0,0), posf = V3(0,0,0); |
| 3463 |
QString creatorS; |
| 3464 |
for (int i = 0; i < ende; i++ ){ |
| 3465 |
posc+=chgl->mol->selectedatoms.at(i).pos; |
| 3466 |
creatorS.append(chgl->mol->selectedatoms.at(i).Label+", "); |
| 3467 |
if (creatorS.section('\n',-1).size()>50) creatorS.append("\nREM "); |
| 3468 |
} |
| 3469 |
posc*=1.0/ende; |
| 3470 |
mole.kart2frac(posc,posf); |
| 3471 |
MyAtom ctr ; |
| 3472 |
ctr.an=-66; |
| 3473 |
ctr.part=0; |
| 3474 |
ctr.peakHeight=9999.99; |
| 3475 |
ctr.resiNr=0; |
| 3476 |
ctr.hidden=0; |
| 3477 |
ctr.symmGroup=0; |
| 3478 |
ctr.sg=0; |
| 3479 |
ctr.scod=555;//the identity |
| 3480 |
ctr.auidx=-1; |
| 3481 |
ctr.uc.m12=ctr.uc.m23=ctr.uc.m13=0.0; |
| 3482 |
ctr.uc.m21=ctr.uc.m32=ctr.uc.m31=0.0; |
| 3483 |
ctr.uf.m12=ctr.uf.m23=ctr.uf.m13=0.0; |
| 3484 |
ctr.uf.m21=ctr.uf.m32=ctr.uf.m31=0.0; |
| 3485 |
ctr.pos=posc; |
| 3486 |
ctr.frac=posf; |
| 3487 |
if (!editor->sfac.contains(-66)){ |
| 3488 |
editor->sfac.append(-66); |
| 3489 |
editor->unitNeu.append(" 0"); |
| 3490 |
cursor.movePosition(QTextCursor::Start); |
| 3491 |
cursor = document->find(editor->unitAlt,cursor); |
| 3492 |
if (cursor.isNull()) { |
| 3493 |
cursor = editor->textCursor(); |
| 3494 |
cursor.endEditBlock (); |
| 3495 |
printf("can't find unit\n"); |
| 3496 |
update(); |
| 3497 |
return; |
| 3498 |
} |
| 3499 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 3500 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 3501 |
cursor.deleteChar(); |
| 3502 |
cursor.insertText(editor->unitNeu); |
| 3503 |
|
| 3504 |
cursor.movePosition(QTextCursor::Start); |
| 3505 |
cursor = document->find(editor->unitNeu,cursor); |
| 3506 |
cursor.clearSelection (); |
| 3507 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 3508 |
cursor.insertText("SFAC cnt 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 ! centroid dummy\n"); |
| 3509 |
} |
| 3510 |
cursor.movePosition(QTextCursor::Start); |
| 3511 |
cursor = document->find("HKLF",cursor); |
| 3512 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 3513 |
cursor.insertText(ctr.orginalLine=QString("Cnt%5 %1 %2 %3 %4 10.000 0.001 ! centroid\n") |
| 3514 |
.arg(editor->sfac.indexOf(-66)+1) |
| 3515 |
.arg(posf.x,10,'f',6) |
| 3516 |
.arg(posf.y,10,'f',6) |
| 3517 |
.arg(posf.z,10,'f',6) |
| 3518 |
.arg(ctrcnt,0,36)); |
| 3519 |
cursor.insertText(QString("REM Cnt%1 was created from: %2\n").arg(ctrcnt,0,36).arg(creatorS)); |
| 3520 |
|
| 3521 |
for (int i = 0; i < ende; i++ ){ |
| 3522 |
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))); |
| 3523 |
} |
| 3524 |
ctr.orginalLine= QString("Cnt%5 %1 %2 %3 %4 10.000 0.001\n") |
| 3525 |
.arg(editor->sfac.indexOf(-66)+1) |
| 3526 |
.arg(posf.x,10,'f',6) |
| 3527 |
.arg(posf.y,10,'f',6) |
| 3528 |
.arg(posf.z,10,'f',6) |
| 3529 |
.arg(ctrcnt,0,36); |
| 3530 |
ctr.Label=QString("Cnt%1").arg(ctrcnt,0,36); |
| 3531 |
cursor.endEditBlock (); |
| 3532 |
editor->setTextCursor(cursor); |
| 3533 |
editor->centerCursor () ; |
| 3534 |
cursor.clearSelection (); |
| 3535 |
editor->setTextCursor(cursor); |
| 3536 |
editor->setFocus () ; |
| 3537 |
mole.asymm.append(ctr); |
| 3538 |
|
| 3539 |
mole.showatoms.clear(); |
| 3540 |
mole.showbonds.clear(); |
| 3541 |
chgl->mol->showatoms.clear(); |
| 3542 |
chgl->mol->showbonds.clear(); |
| 3543 |
chgl->mol->selectedatoms.clear(); |
| 3544 |
for (int o=0; o<mole.asymm.size();o++){ |
| 3545 |
mole.showatoms.append(mole.asymm[o]); |
| 3546 |
} |
| 3547 |
mole.sdmcompleter(); |
| 3548 |
mole.showbonds = |
| 3549 |
mole.connecting(mole.showatoms); |
| 3550 |
chgl->setMolecule(&mole); |
| 3551 |
chgl->mol->selectedatoms.clear(); |
| 3552 |
|
| 3553 |
bool growYes=chgl->fuse->isVisible (); |
| 3554 |
chgl->mol->fuse(); |
| 3555 |
if (growYes) chgl->mol->grow(); |
| 3556 |
|
| 3557 |
// printf("%d\n",__LINE__); |
| 3558 |
loadMolInTest(); |
| 3559 |
|
| 3560 |
chgl->update(); |
| 3561 |
update(); |
| 3562 |
} |
| 3563 |
|
| 3564 |
void Window::moveSymmMateSel(){ |
| 3565 |
|
| 3566 |
QString kep,nextli; |
| 3567 |
QTextCursor cursor = editor->textCursor(); |
| 3568 |
QTextDocument *document = editor->document(); |
| 3569 |
cursor.beginEditBlock(); |
| 3570 |
for (int si=0; si<mole.selectedatoms.size();si++){ |
| 3571 |
QString source,target; |
| 3572 |
source=mole.selectedatoms.at(si).Label; |
| 3573 |
target=source.section(QString::fromUtf8("»"),0,0); |
| 3574 |
MyAtom ato=mole.selectedatoms.at(si); |
| 3575 |
ato.Label=target; |
| 3576 |
ato.symmGroup=0; |
| 3577 |
ato.sg=0; |
| 3578 |
ato.scod=555;//the identity |
| 3579 |
int that=mole.asymm.indexOf(ato); |
| 3580 |
ato.auidx=that; |
| 3581 |
if ((that>=mole.asymm.size())||(that<0)) return; |
| 3582 |
QString susu=mole.asymm.at(that).orginalLine; |
| 3583 |
cursor.movePosition(QTextCursor::Start); |
| 3584 |
cursor = document->find(susu,cursor); |
| 3585 |
if (mole.asymm.at(that).isIso){ |
| 3586 |
ato.ufiso_org = mole.asymm.at(that).ufiso_org; |
| 3587 |
kep=QString("%1 %2 %3 %4 %5 %6 %7") |
| 3588 |
.arg(ato.Label.section('_',0,0),-5) |
| 3589 |
.arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) |
| 3590 |
.arg(ato.frac.x,10,'f',6) |
| 3591 |
.arg(ato.frac.y,10,'f',6) |
| 3592 |
.arg(ato.frac.z,10,'f',6) |
| 3593 |
.arg(mole.asymm.at(that).sof_org,9,'f',5) |
| 3594 |
.arg(ato.ufiso_org) |
| 3595 |
; |
| 3596 |
ato.uf.m11=ato.uc.m11=ato.uc.m22=ato.uc.m33= mole.asymm.at(that).uf.m11; |
| 3597 |
ato.isIso=true; |
| 3598 |
ato.uc.m12=ato.uc.m13=ato.uc.m23=ato.uc.m21=ato.uc.m31=ato.uc.m32=0; |
| 3599 |
cursor.deleteChar(); |
| 3600 |
cursor.insertText(kep); |
| 3601 |
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); |
| 3602 |
editor->wholeLine->setChecked(false); |
| 3603 |
editor->replaceNext(); |
| 3604 |
}else{ |
| 3605 |
kep=QString("%1 %2 %3 %4 %5 %6 %7 %8 ") |
| 3606 |
.arg(ato.Label.section('_',0,0),-5) |
| 3607 |
.arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) |
| 3608 |
.arg(ato.frac.x,10,'f',6) |
| 3609 |
.arg(ato.frac.y,10,'f',6) |
| 3610 |
.arg(ato.frac.z,10,'f',6) |
| 3611 |
.arg(mole.asymm.at(that).sof_org,9,'f',5) |
| 3612 |
.arg(ato.uf.m11,9,'f',5) |
| 3613 |
.arg(ato.uf.m22,9,'f',5); |
| 3614 |
ato.sof_org=mole.asymm.at(that).sof_org; |
| 3615 |
cursor.deleteChar(); |
| 3616 |
cursor.insertText(kep); |
| 3617 |
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); |
| 3618 |
cursor.movePosition(QTextCursor::Down); |
| 3619 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 3620 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 3621 |
nextli=cursor.selectedText(); |
| 3622 |
cursor = document->find(nextli,cursor); |
| 3623 |
|
| 3624 |
cursor.deleteChar(); |
| 3625 |
cursor.insertText(QString(" %1 %2 %3 %4") |
| 3626 |
.arg(ato.uf.m33,9,'f',5) |
| 3627 |
.arg(ato.uf.m23,9,'f',5) |
| 3628 |
.arg(ato.uf.m13,9,'f',5) |
| 3629 |
.arg(ato.uf.m12,9,'f',5)); |
| 3630 |
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); |
| 3631 |
} |
| 3632 |
ato.orginalLine=kep.section("=",0,0); |
| 3633 |
mole.asymm[that]=ato; |
| 3634 |
} |
| 3635 |
|
| 3636 |
cursor = editor->textCursor(); |
| 3637 |
cursor.endEditBlock(); |
| 3638 |
|
| 3639 |
mole.showatoms.clear(); |
| 3640 |
mole.showbonds.clear(); |
| 3641 |
chgl->mol->showatoms.clear(); |
| 3642 |
chgl->mol->showbonds.clear(); |
| 3643 |
chgl->mol->selectedatoms.clear(); |
| 3644 |
for (int o=0; o<mole.asymm.size();o++) |
| 3645 |
mole.showatoms.append(mole.asymm[o]); |
| 3646 |
mole.sdmcompleter(); |
| 3647 |
mole.showbonds = |
| 3648 |
mole.connecting(mole.showatoms); |
| 3649 |
chgl->setMolecule(&mole); |
| 3650 |
chgl->mol->selectedatoms.clear(); |
| 3651 |
|
| 3652 |
bool growYes=chgl->fuse->isVisible (); |
| 3653 |
chgl->mol->fuse(); |
| 3654 |
if (growYes) chgl->mol->grow(); |
| 3655 |
editor->searchLE->setText(""); |
| 3656 |
editor->hideSearch(); |
| 3657 |
loadMolInTest(); |
| 3658 |
|
| 3659 |
// printf("%d\n",__LINE__); |
| 3660 |
chgl->update(); |
| 3661 |
update(); |
| 3662 |
} |
| 3663 |
|
| 3664 |
void Window::moveSymmMate(){ |
| 3665 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 3666 |
int index=0; |
| 3667 |
if (action) |
| 3668 |
index=action->data().toInt(); |
| 3669 |
else return; |
| 3670 |
QString source,target; |
| 3671 |
source=chgl->mol->showatoms.at(index).Label; |
| 3672 |
target=source.section(QString::fromUtf8("»"),0,0); |
| 3673 |
MyAtom ato=chgl->mol->showatoms.at(index); |
| 3674 |
ato.Label=target; |
| 3675 |
ato.symmGroup=0; |
| 3676 |
ato.sg=0; |
| 3677 |
ato.scod=555;//the identity |
| 3678 |
int that=mole.asymm.indexOf(ato); |
| 3679 |
ato.auidx=that; |
| 3680 |
if ((that>=mole.asymm.size())||(that<0)) return; |
| 3681 |
QString susu=mole.asymm.at(that).orginalLine; |
| 3682 |
editor->searchLE->setText(susu); |
| 3683 |
if (mole.asymm.at(that).isIso){ |
| 3684 |
ato.ufiso_org = mole.asymm.at(that).ufiso_org; |
| 3685 |
editor->replace->setText(QString("%1 %2 %3 %4 %5 %6 %7") |
| 3686 |
.arg(ato.Label.section('_',0,0),-5) |
| 3687 |
.arg(qMax(1, editor->sfac.indexOf(ato.an)+1)) |
| 3688 |
.arg(ato.frac.x,10,'f',6) |
| 3689 |
.arg(ato.frac.y,10,'f',6) |
| 3690 |
.arg(ato.frac.z,10,'f',6) |
| 3691 |
.arg(mole.asymm.at(that).sof_org,9,'f',5) |
| 3692 |
.arg(ato.ufiso_org) |
| 3693 |
); |
| 3694 |
ato.uf.m11=ato.uc.m11=ato.uc.m22=ato.uc.m33= mole.asymm.at(that).uf.m11; |
| 3695 |
ato.isIso=true; |
| 3696 |
ato.uc.m12=ato.uc.m13=ato.uc.m23=ato.uc.m21=ato.uc.m31=ato.uc.m32=0; |
| 3697 |
editor->wholeLine->setChecked(false); |
| 3698 |
editor->replaceNext(); |
| 3699 |
|
| 3700 |
}else{ |
| 3701 |
QString kep=QString("%1 %2 %3 %4 %5 %6 %7 %8 ") |
| 3702 |
.arg(ato.Label.section('_',0,0),-5) |
| 3703 |
.arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) |
| 3704 |
.arg(ato.frac.x,10,'f',6) |
| 3705 |
.arg(ato.frac.y,10,'f',6) |
| 3706 |
.arg(ato.frac.z,10,'f',6) |
| 3707 |
.arg(mole.asymm.at(that).sof_org,9,'f',5) |
| 3708 |
.arg(ato.uf.m11,9,'f',5) |
| 3709 |
.arg(ato.uf.m22,9,'f',5); |
| 3710 |
|
| 3711 |
editor->replace->setText(kep); |
| 3712 |
editor->wholeLine->setChecked(false); |
| 3713 |
editor->replaceNext(); |
| 3714 |
editor->searchLE->setText(editor->replace->text()); |
| 3715 |
editor->replace->setText(""); |
| 3716 |
editor->findNext(); |
| 3717 |
QTextCursor cursor = editor->textCursor(); |
| 3718 |
cursor.movePosition(QTextCursor::Down); |
| 3719 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 3720 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 3721 |
editor->searchLE->setText(cursor.selectedText()); |
| 3722 |
editor->replace->setText(QString(" %1 %2 %3 %4") |
| 3723 |
.arg(ato.uf.m33,9,'f',5) |
| 3724 |
.arg(ato.uf.m23,9,'f',5) |
| 3725 |
.arg(ato.uf.m13,9,'f',5) |
| 3726 |
.arg(ato.uf.m12,9,'f',5) |
| 3727 |
); |
| 3728 |
|
| 3729 |
editor->replaceNext(); |
| 3730 |
editor->replace->setText(kep); |
| 3731 |
} |
| 3732 |
editor->searchLE->setText(editor->replace->text()); |
| 3733 |
editor->replace->setText(""); |
| 3734 |
editor->findNext(); |
| 3735 |
QTextCursor cursor = editor->textCursor(); |
| 3736 |
ato.orginalLine=cursor.selectedText().section("=",0,0); |
| 3737 |
mole.asymm[that]=ato; |
| 3738 |
|
| 3739 |
|
| 3740 |
mole.showatoms.clear(); |
| 3741 |
mole.showbonds.clear(); |
| 3742 |
chgl->mol->showatoms.clear(); |
| 3743 |
chgl->mol->showbonds.clear(); |
| 3744 |
chgl->mol->selectedatoms.clear(); |
| 3745 |
for (int o=0; o<mole.asymm.size();o++) |
| 3746 |
mole.showatoms.append(mole.asymm[o]); |
| 3747 |
mole.sdmcompleter(); |
| 3748 |
mole.showbonds = |
| 3749 |
mole.connecting(mole.showatoms); |
| 3750 |
chgl->setMolecule(&mole); |
| 3751 |
chgl->mol->selectedatoms.clear(); |
| 3752 |
|
| 3753 |
bool growYes=chgl->fuse->isVisible (); |
| 3754 |
chgl->mol->fuse(); |
| 3755 |
if (growYes) chgl->mol->grow(); |
| 3756 |
editor->searchLE->setText(""); |
| 3757 |
editor->hideSearch(); |
| 3758 |
loadMolInTest(); |
| 3759 |
|
| 3760 |
// printf("%d\n",__LINE__); |
| 3761 |
chgl->update(); |
| 3762 |
update(); |
| 3763 |
} |
| 3764 |
|
| 3765 |
void Window::copySymmMate(){ |
| 3766 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 3767 |
int index=0; |
| 3768 |
if (action) |
| 3769 |
index=action->data().toInt(); |
| 3770 |
else return; |
| 3771 |
QString source,target; |
| 3772 |
source=chgl->mol->showatoms.at(index).Label; |
| 3773 |
target=source.section(QString::fromUtf8("»"),0,0); |
| 3774 |
MyAtom ato=chgl->mol->showatoms.at(index); |
| 3775 |
ato.Label=target; |
| 3776 |
ato.symmGroup=0; |
| 3777 |
ato.sg=0; |
| 3778 |
ato.scod=555;//the identity |
| 3779 |
int that=mole.asymm.indexOf(ato); |
| 3780 |
ato.auidx=that; |
| 3781 |
if ((that>=mole.asymm.size())||(that<0)) return; |
| 3782 |
QString susu=mole.asymm.at(that).orginalLine; |
| 3783 |
QTextCursor cursor = editor->textCursor(); |
| 3784 |
cursor.movePosition(QTextCursor::Start); |
| 3785 |
QTextDocument *document = editor->document(); |
| 3786 |
if (document->find(susu, cursor).isNull()) { |
| 3787 |
QMessageBox::information(0,"information","The File is out of sync with the model. Please save and try again!"); |
| 3788 |
return; |
| 3789 |
} |
| 3790 |
cursor.beginEditBlock(); |
| 3791 |
cursor.movePosition(QTextCursor::Start); |
| 3792 |
cursor = document->find("HKLF",cursor); |
| 3793 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 3794 |
cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); |
| 3795 |
if (editor->parenthesis.at(cursor.blockNumber())){ |
| 3796 |
cursor.select(QTextCursor::WordUnderCursor); |
| 3797 |
if ((cursor.selectedText().contains("RESI",Qt::CaseInsensitive))||(cursor.selectedText().contains("PART",Qt::CaseInsensitive))) |
| 3798 |
cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); |
| 3799 |
cursor.select(QTextCursor::WordUnderCursor); |
| 3800 |
if ((cursor.selectedText().contains("RESI",Qt::CaseInsensitive))||(cursor.selectedText().contains("PART",Qt::CaseInsensitive))) |
| 3801 |
cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); |
| 3802 |
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); |
| 3803 |
cursor.clearSelection(); |
| 3804 |
cursor.insertText("AFIX 0 \n"); |
| 3805 |
} |
| 3806 |
///////////////////////////// |
| 3807 |
cursor.movePosition(QTextCursor::Start); |
| 3808 |
cursor = document->find(susu, cursor); |
| 3809 |
cursor.movePosition(QTextCursor::Down); |
| 3810 |
cursor.movePosition(QTextCursor::StartOfLine); |
| 3811 |
if (mole.asymm.at(that).Label.contains(numbers)) { |
| 3812 |
int p=mole.asymm.at(that).an; |
| 3813 |
labelPSE=mole.pse(p); |
| 3814 |
|
| 3815 |
labelIndex=mole.asymm.at(that).Label.section(nonumbers,0,0,QString::SectionSkipEmpty).toInt(); |
| 3816 |
labelSuffix=mole.asymm.at(that).Label.section(numbers,1,1); |
| 3817 |
labelSuffix.remove(vorneweg); |
| 3818 |
} |
| 3819 |
else{ |
| 3820 |
int p=mole.asymm.at(that).an; |
| 3821 |
labelPSE=mole.pse(p); |
| 3822 |
labelIndex=-1; |
| 3823 |
labelSuffix=mole.asymm.at(that).Label; |
| 3824 |
labelSuffix.remove(0,labelPSE.size()); |
| 3825 |
labelSuffix.remove(vorneweg); |
| 3826 |
} |
| 3827 |
|
| 3828 |
partSpin->setValue(mole.asymm.at(that).part); |
| 3829 |
resiNrSpin->setValue(mole.asymm.at(that).resiNr); |
| 3830 |
resiResiClass->setText(mole.asymm.at(that).ResiClass); |
| 3831 |
pserbt[mole.asymm.at(that).an+1]->setChecked(true); |
| 3832 |
renamUpdate(false); |
| 3833 |
updateLabel(); |
| 3834 |
QString neues=nextLabel; |
| 3835 |
if (mole.asymm.at(that).isIso){ |
| 3836 |
cursor.insertText(QString("%1 %2 %3 %4 %5 %6 %7 !copy\n") |
| 3837 |
.arg(neues,-5)//1 |
| 3838 |
.arg(qMax(1,editor->sfac.indexOf(ato.an)+1))//2 |
| 3839 |
.arg(ato.frac.x,10,'f',6)//3 |
| 3840 |
.arg(ato.frac.y,10,'f',6)//4 |
| 3841 |
.arg(ato.frac.z,10,'f',6)//5 |
| 3842 |
.arg(mole.asymm.at(that).sof_org,9,'f',5)//6 |
| 3843 |
.arg(ato.uf.m33=mole.asymm.at(that).uf.m33,9,'f',5)//7 |
| 3844 |
); |
| 3845 |
|
| 3846 |
}else{ |
| 3847 |
cursor.movePosition(QTextCursor::Down); |
| 3848 |
cursor.movePosition(QTextCursor::StartOfLine); |
| 3849 |
while(editor->parenthesis.at(cursor.blockNumber()+1)){ |
| 3850 |
cursor.movePosition(QTextCursor::Down); |
| 3851 |
cursor.movePosition(QTextCursor::StartOfLine); |
| 3852 |
} |
| 3853 |
cursor.insertText(QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12 !copy\n") |
| 3854 |
.arg(neues,-5)//1 |
| 3855 |
.arg(qMax(1,editor->sfac.indexOf(ato.an)+1))//2 |
| 3856 |
.arg(ato.frac.x,10,'f',6)//3 |
| 3857 |
.arg(ato.frac.y,10,'f',6)//4 |
| 3858 |
.arg(ato.frac.z,10,'f',6)//5 |
| 3859 |
.arg(mole.asymm.at(that).sof_org,9,'f',5)//6 |
| 3860 |
.arg(ato.uf.m11,9,'f',5)//7 |
| 3861 |
.arg(ato.uf.m22,9,'f',5)//8 |
| 3862 |
.arg(ato.uf.m33,9,'f',5)//9 |
| 3863 |
.arg(ato.uf.m23,9,'f',5)//10 |
| 3864 |
.arg(ato.uf.m13,9,'f',5)//11 |
| 3865 |
.arg(ato.uf.m12,9,'f',5)//12 |
| 3866 |
); |
| 3867 |
|
| 3868 |
} |
| 3869 |
QString nn=QString("%1_%3%4") |
| 3870 |
.arg(nextLabel) |
| 3871 |
.arg((resiNrSpin->value())?QString::number(resiNrSpin->value()):"") |
| 3872 |
.arg((partSpin->value())?QString::number((partSpin->value()<0)? |
| 3873 |
36+partSpin->value(): |
| 3874 |
partSpin->value()+9,36):""); |
| 3875 |
ato.Label=nn; |
| 3876 |
mole.asymm.append(ato); |
| 3877 |
cursor.endEditBlock(); |
| 3878 |
renamUpdate(false); |
| 3879 |
updateLabel(); |
| 3880 |
|
| 3881 |
mole.showatoms.clear(); |
| 3882 |
mole.showbonds.clear(); |
| 3883 |
chgl->mol->showatoms.clear(); |
| 3884 |
chgl->mol->showbonds.clear(); |
| 3885 |
chgl->mol->selectedatoms.clear(); |
| 3886 |
for (int o=0; o<mole.asymm.size();o++) |
| 3887 |
mole.showatoms.append(mole.asymm[o]); |
| 3888 |
mole.sdmcompleter(); |
| 3889 |
mole.showbonds = |
| 3890 |
mole.connecting(mole.showatoms); |
| 3891 |
chgl->setMolecule(&mole); |
| 3892 |
chgl->mol->selectedatoms.clear(); |
| 3893 |
|
| 3894 |
bool growYes=chgl->fuse->isVisible (); |
| 3895 |
chgl->mol->fuse(); |
| 3896 |
if (growYes) chgl->mol->grow(); |
| 3897 |
loadMolInTest(); |
| 3898 |
|
| 3899 |
// printf("%d\n",__LINE__); |
| 3900 |
chgl->update(); |
| 3901 |
update(); |
| 3902 |
} |
| 3903 |
|
| 3904 |
void Window::updateTieFreeVar(){ |
| 3905 |
int part = partSpin->value(); |
| 3906 |
if (!part) { |
| 3907 |
tieOccL->hide(); |
| 3908 |
tieType->hide(); |
| 3909 |
tieType->setCurrentIndex(0); |
| 3910 |
tieFVNrL->hide(); |
| 3911 |
tieFVNr->hide(); |
| 3912 |
tieUsedL->hide(); |
| 3913 |
tieFix->hide(); |
| 3914 |
update(); |
| 3915 |
return; |
| 3916 |
} |
| 3917 |
tieOccL->show(); |
| 3918 |
tieType->show(); |
| 3919 |
|
| 3920 |
if (tieType->itemData(tieType->currentIndex()).toInt()){ |
| 3921 |
tieFVNrL->show(); |
| 3922 |
tieFVNr->show(); |
| 3923 |
tieUsedL->hide(); |
| 3924 |
tieFix->hide(); |
| 3925 |
int j=tieFVNr->value(); |
| 3926 |
tieUsedL->setText(QString("fv(%1)=%3 [%2x used]") |
| 3927 |
.arg(j) |
| 3928 |
.arg(fvarCntr.value(j)) |
| 3929 |
.arg((fvar.size()>(j-1))?fvar.at(j-1):0.666) ); |
| 3930 |
tieFVNr->setMaximum(fvar.size()+1); |
| 3931 |
if (j!=1) tieUsedL->show(); |
| 3932 |
else { |
| 3933 |
tieFix->show(); |
| 3934 |
tieType->hide(); |
| 3935 |
} |
| 3936 |
}else{ |
| 3937 |
tieFVNrL->hide(); |
| 3938 |
tieFVNr->hide(); |
| 3939 |
tieUsedL->hide(); |
| 3940 |
tieFix->hide(); |
| 3941 |
} |
| 3942 |
update(); |
| 3943 |
} |
| 3944 |
|
| 3945 |
void Window::clipboardDataChanged(){ |
| 3946 |
#ifndef QT_NO_CLIPBOARD |
| 3947 |
actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty()); |
| 3948 |
#endif |
| 3949 |
} |
| 3950 |
|
| 3951 |
void Window::shxActUpdate(bool vis){ |
| 3952 |
bool v = shxOutputDock->isVisible(); |
| 3953 |
editToolBar->setVisible(vis|v); |
| 3954 |
refineToolBar->setVisible(vis|v); |
| 3955 |
actionSearch->setVisible(vis|v); |
| 3956 |
actionNext->setVisible(vis|v); |
| 3957 |
actionPrev->setVisible(vis|v); |
| 3958 |
actionUndo->setVisible(vis); |
| 3959 |
actionRedo->setVisible(vis); |
| 3960 |
actionCut->setVisible(vis); |
| 3961 |
actionCopy->setVisible(vis); |
| 3962 |
actionPaste->setVisible(vis); |
| 3963 |
actionEP->setVisible(vis|v); |
| 3964 |
actionEM->setVisible(vis|v); |
| 3965 |
} |
| 3966 |
|
| 3967 |
void Window::shxOPTUpdate(bool vis){ |
| 3968 |
|
| 3969 |
bool v = shxEditorDock->isVisible(); |
| 3970 |
|
| 3971 |
xlPutor->hideSearch(); |
| 3972 |
editToolBar->setVisible(vis|v); |
| 3973 |
refineToolBar->setVisible(vis|v); |
| 3974 |
actionSearch->setVisible(vis|v); |
| 3975 |
actionNext->setVisible(vis|v); |
| 3976 |
actionPrev->setVisible(vis|v); |
| 3977 |
actionEP->setVisible(vis|v); |
| 3978 |
actionEM->setVisible(vis|v); |
| 3979 |
update(); |
| 3980 |
} |
| 3981 |
|
| 3982 |
void Window::renamUpdate(bool vis){ |
| 3983 |
/*QElapsedTimer tmr; |
| 3984 |
int ran=rand(); |
| 3985 |
tmr.start();*/ |
| 3986 |
//printf("==>%lld %d\n",tmr.elapsed(), ran); |
| 3987 |
enterRenameMode->setChecked(vis); |
| 3988 |
enterRenameMode->setText((vis)?"Exit Rename Mode":"Rename Mode"); |
| 3989 |
renamUpdateAct->setChecked(false); |
| 3990 |
updateTieFreeVar(); |
| 3991 |
labelSuffix = ""; |
| 3992 |
sufixBox->clearEditText(); |
| 3993 |
sufixBox->setCurrentIndex(1); |
| 3994 |
psew->hide(); |
| 3995 |
willpse->show(); |
| 3996 |
QStringList RCL;//ResiClassList |
| 3997 |
RCL.append(""); |
| 3998 |
QString curcls=resiResiClass->text(); |
| 3999 |
if (!curcls.isEmpty()) RCL.append(curcls); |
| 4000 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 4001 |
if (mole.asymm.at(i).an<0) continue; |
| 4002 |
if (!RCL.contains(mole.asymm.at(i).ResiClass))RCL.append(mole.asymm.at(i).ResiClass); |
| 4003 |
} |
| 4004 |
//printf("%d\n",RCL.size()); |
| 4005 |
resiResiClassCB->clear(); |
| 4006 |
resiResiClassCB->addItems(RCL); |
| 4007 |
if (!curcls.isEmpty()) resiResiClassCB->setCurrentIndex(resiResiClassCB->findText(curcls)); |
| 4008 |
renameRNchanged(resiNrSpin->value()); |
| 4009 |
resiResiClass->setText(curcls); |
| 4010 |
|
| 4011 |
if (vis) { |
| 4012 |
renamDock->show(); |
| 4013 |
renamDock->raise(); |
| 4014 |
if (dock->isVisible()) dock->hide(); |
| 4015 |
if (histDock->isVisible()) histDock->hide(); |
| 4016 |
//if (!renamDock->isVisible()) renamDock->show(); |
| 4017 |
machPlatz=true; |
| 4018 |
//printf("renamDock->raise()\n"); |
| 4019 |
renamDock->raise(); |
| 4020 |
//renamDock->raise(); |
| 4021 |
editToolBar->setVisible(vis); |
| 4022 |
refineToolBar->setVisible(vis); |
| 4023 |
actionSearch->setVisible(vis); |
| 4024 |
actionNext->setVisible(vis); |
| 4025 |
actionPrev->setVisible(vis); |
| 4026 |
actionUndo->setVisible(vis); |
| 4027 |
actionRedo->setVisible(vis); |
| 4028 |
actionCut->setVisible(vis); |
| 4029 |
actionCopy->setVisible(vis); |
| 4030 |
actionPaste->setVisible(vis); |
| 4031 |
actionEP->setVisible(vis); |
| 4032 |
actionEM->setVisible(vis); |
| 4033 |
//printf(" . da\n"); |
| 4034 |
|
| 4035 |
} |
| 4036 |
else if (enterRenameMode->text()=="Rename Mode"){ |
| 4037 |
if ((machPlatz)&&(!dock->isVisible())&&(!histDock->isVisible())) { |
| 4038 |
//printf(" da %d\n",vis); |
| 4039 |
dock->show(); |
| 4040 |
histDock->show(); |
| 4041 |
shxEditorDock->show(); |
| 4042 |
shxEditorDock->raise(); |
| 4043 |
machPlatz=false; |
| 4044 |
} |
| 4045 |
} |
| 4046 |
if (strcmp(PROGRAM_NAME,"shelXle")){ |
| 4047 |
if ((vis)&&(height()>hhh)) { |
| 4048 |
#if defined(linux) |
| 4049 |
showMaximized (); |
| 4050 |
showNormal (); |
| 4051 |
#endif |
| 4052 |
//printf("da\n"); |
| 4053 |
showMaximized (); |
| 4054 |
} |
| 4055 |
} |
| 4056 |
//printf("rename update %lld %s\n",tmr.elapsed(),(vis)?"true":"false"); |
| 4057 |
/* |
| 4058 |
if ((vis)&&(renamDock->isVisible())){chgl->updateLabelTextures(); |
| 4059 |
//printf("rename update textures %lld %d\n",tmr.elapsed(),ran); |
| 4060 |
}*/ |
| 4061 |
} |
| 4062 |
|
| 4063 |
void Window::addNewScatteringFactor(int oz, bool HisD){ |
| 4064 |
QString smbl=((oz==0) && HisD)?"D":chgl->mol->pse(oz); |
| 4065 |
changeElemetofLabel(smbl); |
| 4066 |
if (editor->sfacsmbl.contains(smbl)) { |
| 4067 |
pserbt[oz+1]->setChecked(true); |
| 4068 |
return; |
| 4069 |
} |
| 4070 |
editor->sfac.append(oz); |
| 4071 |
editor->sfacsmbl.append(smbl); |
| 4072 |
int an = ((oz==0) && HisD)?110:editor->sfac.last()+1; |
| 4073 |
|
| 4074 |
pserbt[an]->show(); |
| 4075 |
pserbt[an]->setChecked(true); |
| 4076 |
sfacBox->setFixedSize((editor->sfacsmbl.size()+1)*52,70); |
| 4077 |
|
| 4078 |
QTextDocument *document = editor->document(); |
| 4079 |
QTextCursor cursor = editor->textCursor(); |
| 4080 |
cursor.beginEditBlock(); |
| 4081 |
cursor.movePosition(QTextCursor::End); |
| 4082 |
cursor = document->find("sfac", cursor, QTextDocument::FindBackward); |
| 4083 |
if (!cursor.isNull()){ |
| 4084 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 4085 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 4086 |
QString sf = cursor.selectedText().trimmed(); |
| 4087 |
if (sf.size()<77) sf.append(QString(" %1").arg(smbl)); |
| 4088 |
cursor.deleteChar(); |
| 4089 |
cursor.insertText(sf); |
| 4090 |
} |
| 4091 |
cursor.movePosition(QTextCursor::End); |
| 4092 |
cursor = document->find("unit", cursor, QTextDocument::FindBackward); |
| 4093 |
if (!cursor.isNull()){ |
| 4094 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 4095 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 4096 |
QString sf = cursor.selectedText().trimmed(); |
| 4097 |
if (sf.size()<77) sf.append(" 1"); |
| 4098 |
cursor.deleteChar(); |
| 4099 |
cursor.insertText(sf); |
| 4100 |
} |
| 4101 |
cursor.endEditBlock(); |
| 4102 |
} |
| 4103 |
|
| 4104 |
void Window::setDefaultPath(){ //!<when the first recent file does not exists then open dialog starts here |
| 4105 |
QString dfpa=""; |
| 4106 |
einstellung->beginGroup("Files"); |
| 4107 |
if (einstellung->contains("defaultPath")) |
| 4108 |
dfpa= einstellung->value("defaultPath").toString(); |
| 4109 |
else |
| 4110 |
dfpa= QDir::homePath(); |
| 4111 |
einstellung->endGroup(); |
| 4112 |
dfpa=QFileDialog::getOpenFileName(this, |
| 4113 |
"set default file directory", |
| 4114 |
dfpa, |
| 4115 |
"SHELX-Files (*.res *.ins);;", |
| 4116 |
nullptr); |
| 4117 |
if (!dfpa.isEmpty()){ |
| 4118 |
einstellung->beginGroup("Files"); |
| 4119 |
einstellung->setValue("defaultPath",dfpa); |
| 4120 |
einstellung->endGroup(); |
| 4121 |
} |
| 4122 |
} |
| 4123 |
|
| 4124 |
void Window::openFile(){ |
| 4125 |
QString location=dirName; |
| 4126 |
if (!QFile::exists(dirName)) { |
| 4127 |
einstellung->beginGroup("Files"); |
| 4128 |
if (einstellung->contains("defaultPath")) |
| 4129 |
location = einstellung->value("defaultPath").toString(); |
| 4130 |
else |
| 4131 |
location = QDir::homePath(); |
| 4132 |
einstellung->endGroup(); |
| 4133 |
} |
| 4134 |
|
| 4135 |
QString fileName = QFileDialog::getOpenFileName(this, tr("Open shelX file "), location, |
| 4136 |
"SHELX-Files (*.res *.ins);;",nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 4137 |
if (!fileName.isEmpty()) { |
| 4138 |
|
| 4139 |
loadFile(fileName); |
| 4140 |
} |
| 4141 |
update(); |
| 4142 |
} |
| 4143 |
|
| 4144 |
void Window::setShelxlOptions(){ |
| 4145 |
QDialog *shxOptDLG = new QDialog(this); |
| 4146 |
shxOptDLG->setWindowTitle("SHELXL runtime options"); |
| 4147 |
QGridLayout *lt = new QGridLayout(shxOptDLG); |
| 4148 |
QLabel *PathL = new QLabel("Full path to executable",shxOptDLG); |
| 4149 |
shxPath = new QLineEdit(shxOptDLG); |
| 4150 |
QLabel *argumentsL = new QLabel("Commandline options",shxOptDLG); |
| 4151 |
QCheckBox *barray = new QCheckBox(tr("I want to set the B-array size myself")); |
| 4152 |
shxOptions = new QLineEdit(shxOptDLG); |
| 4153 |
shxPath->setText(shelxlPath); |
| 4154 |
shxOptions->setText(shelxlArgs); |
| 4155 |
if (useMyBArray == true) { |
| 4156 |
barray->setChecked(true); |
| 4157 |
} else { |
| 4158 |
barray->setChecked(false); |
| 4159 |
} |
| 4160 |
QPushButton *browsePath = new QPushButton("Browse",shxOptDLG); |
| 4161 |
connect(browsePath,SIGNAL(pressed ()),this, SLOT(setShelxlPath())); |
| 4162 |
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,Qt::Horizontal,shxOptDLG); |
| 4163 |
connect(buttonBox, SIGNAL(accepted()), shxOptDLG, SLOT(accept())); |
| 4164 |
connect(buttonBox, SIGNAL(rejected()), shxOptDLG, SLOT(reject())); |
| 4165 |
lt->addWidget(PathL, 1, 0); |
| 4166 |
lt->addWidget(shxPath, 1, 1); |
| 4167 |
lt->addWidget(argumentsL, 2, 0); |
| 4168 |
lt->addWidget(shxOptions, 2, 1); |
| 4169 |
lt->addWidget(browsePath, 1, 2); |
| 4170 |
lt->addWidget(barray, 3, 1, 1, 2); |
| 4171 |
lt->addWidget(buttonBox, 8, 1, 1, 3); |
| 4172 |
shxOptDLG->setLayout(lt); |
| 4173 |
if (shxOptDLG->exec()==QDialog::Accepted) { |
| 4174 |
shelxlArgs=shxOptions->text(); |
| 4175 |
shelxlPath=shxPath->text(); |
| 4176 |
einstellung->beginGroup("Window"); |
| 4177 |
einstellung->setValue("SHELXL-PATH", shelxlPath); |
| 4178 |
einstellung->setValue("SHELXL-OPTION", shelxlArgs); |
| 4179 |
einstellung->setValue("SHELXL-BARRAY", barray->isChecked()); |
| 4180 |
useMyBArray = barray->isChecked(); |
| 4181 |
einstellung->endGroup(); |
| 4182 |
} |
| 4183 |
shxOptDLG->deleteLater (); |
| 4184 |
delete shxPath; |
| 4185 |
delete shxOptions; |
| 4186 |
shxPath=shxOptions=NULL; |
| 4187 |
} |
| 4188 |
|
| 4189 |
void Window::extraSettings(){ |
| 4190 |
// printf("extraSettings()\n"); |
| 4191 |
QDialog *extDLG = new QDialog(this); |
| 4192 |
extDLG->setWindowTitle("External programs"); |
| 4193 |
QGridLayout *lt = new QGridLayout(extDLG); |
| 4194 |
pgms = new QComboBox(extDLG); |
| 4195 |
pgms->addItems(extraProgramNames); |
| 4196 |
connect(pgms,SIGNAL(currentIndexChanged(int)), this, SLOT(updateExtraSettings(int))); |
| 4197 |
QLabel *extraNameL = new QLabel("Name of external program for menu entry:",extDLG); |
| 4198 |
extraName = new QLineEdit(extDLG); |
| 4199 |
extraName->setMinimumSize(150,15); |
| 4200 |
QLabel *extraPathL = new QLabel("Full path to executable",extDLG); |
| 4201 |
extraPath = new QLineEdit(extDLG); |
| 4202 |
QLabel *argumentsL = new QLabel("Commandline options",extDLG); |
| 4203 |
extraArgumentsEdit = new QLineEdit(extDLG); |
| 4204 |
QLabel *altExtL = new QLabel("Alternative file Extension",extDLG); |
| 4205 |
extraAltExtEdit = new QLineEdit(extDLG); |
| 4206 |
QPushButton *browsePath = new QPushButton("Browse",extDLG); |
| 4207 |
extraFakeButton = new QToolButton(extDLG); |
| 4208 |
extraFakeButton->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 4209 |
connect(browsePath,SIGNAL(pressed ()),this, SLOT(setExtraPath())); |
| 4210 |
connect(extraFakeButton,SIGNAL(pressed()),this,SLOT(brwsIcon())); |
| 4211 |
useArgument = new QCheckBox("Give file name as argument",extDLG); |
| 4212 |
omitExtension = new QCheckBox("Omit '*.res' extension in argument",extDLG); |
| 4213 |
absolutePath = new QCheckBox("Use absolute path in argument",extDLG); |
| 4214 |
copyResIns = new QCheckBox("Copy .res file to ins file before execution",extDLG); |
| 4215 |
openFileDialogBefore = new QCheckBox("Open file dialog before execution",extDLG); |
| 4216 |
iconOverlay = new QCheckBox("Text overlay",extDLG); |
| 4217 |
iovlPointSize = new QSpinBox(extDLG); |
| 4218 |
iovlPointSize->setRange(4,96); |
| 4219 |
iovlPointSize->setValue(36); |
| 4220 |
iovlPointSize->setPrefix("PointSize "); |
| 4221 |
connect(iconOverlay,SIGNAL(stateChanged(int)),this,SLOT(updateExtraIcon())); |
| 4222 |
connect(iovlPointSize,SIGNAL(valueChanged(int)),this,SLOT(updateExtraIcon())); |
| 4223 |
detach = new QCheckBox("start detached",extDLG); |
| 4224 |
detach->setChecked(true); |
| 4225 |
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::No| QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel,Qt::Horizontal,extDLG); |
| 4226 |
QPushButton *ok = buttonBox->button(QDialogButtonBox::Ok); |
| 4227 |
ok->setText("Add program"); |
| 4228 |
QPushButton *no =buttonBox->button(QDialogButtonBox::No); |
| 4229 |
no->setText("Remove program"); |
| 4230 |
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),this,SLOT(removeExtra(QAbstractButton*))); |
| 4231 |
connect(buttonBox, SIGNAL(accepted()), extDLG, SLOT(accept())); |
| 4232 |
connect(buttonBox, SIGNAL(rejected()), extDLG, SLOT(reject())); |
| 4233 |
lt->addWidget(pgms,0,0); |
| 4234 |
lt->addWidget(extraNameL,1,0); |
| 4235 |
lt->addWidget(extraName, 1,1); |
| 4236 |
lt->addWidget(extraPathL,2,0); |
| 4237 |
lt->addWidget(extraPath, 2,1); |
| 4238 |
lt->addWidget(browsePath,2,2); |
| 4239 |
lt->addWidget(extraFakeButton,0,1); |
| 4240 |
lt->addWidget(iconOverlay,0,2); |
| 4241 |
lt->addWidget(iovlPointSize,0,3); |
| 4242 |
lt->addWidget(argumentsL,4,0); |
| 4243 |
lt->addWidget(extraArgumentsEdit,4,1); |
| 4244 |
lt->addWidget(altExtL,5,0); |
| 4245 |
lt->addWidget(extraAltExtEdit,5,1); |
| 4246 |
lt->addWidget(useArgument, 1, 9); |
| 4247 |
lt->addWidget(absolutePath, 2, 9); |
| 4248 |
lt->addWidget(omitExtension, 3, 9); |
| 4249 |
lt->addWidget(detach, 4, 9); |
| 4250 |
lt->addWidget(copyResIns, 5, 9); |
| 4251 |
lt->addWidget(openFileDialogBefore, 6, 9); |
| 4252 |
lt->addWidget(buttonBox,14,0,1,11); |
| 4253 |
extDLG->setLayout(lt); |
| 4254 |
altExtraIconPath=""; |
| 4255 |
//printf("extraSettings()\n"); |
| 4256 |
updateExtraSettings(0); |
| 4257 |
|
| 4258 |
while (extraOptions.size()>extraProgramNames.size()){extraOptions.removeLast();} |
| 4259 |
while (extraAbsolutePath.size()>extraProgramNames.size()){extraAbsolutePath.removeLast();} |
| 4260 |
while (extraExt2.size()>extraProgramNames.size()){extraExt2.removeLast();} |
| 4261 |
|
| 4262 |
if (extDLG->exec()==QDialog::Accepted) { |
| 4263 |
int wegmuss=extraProgramNames.indexOf(extraName->text()); |
| 4264 |
if (wegmuss!=-1) { |
| 4265 |
extraProgramNames.removeAt(wegmuss); |
| 4266 |
extraProgramPaths.removeAt(wegmuss); |
| 4267 |
extraArguments.removeAt(wegmuss); |
| 4268 |
extraExtensions.removeAt(wegmuss); |
| 4269 |
if (wegmuss<extraResIns.size()) extraResIns.removeAt(wegmuss); |
| 4270 |
if (wegmuss<extraOpenFileDialogBefore.size()) extraOpenFileDialogBefore.removeAt(wegmuss); |
| 4271 |
if (wegmuss<extraIconOverlay.size()) extraIconOverlay.removeAt(wegmuss); |
| 4272 |
if (wegmuss<extraOverlayPointSize.size()) extraOverlayPointSize.removeAt(wegmuss); |
| 4273 |
if (wegmuss<altExtraIconPaths.size()) altExtraIconPaths.removeAt(wegmuss); |
| 4274 |
extraDetach.removeAt(wegmuss); |
| 4275 |
extraOptions.removeAt(wegmuss); |
| 4276 |
if (wegmuss<extraAbsolutePath.size())extraAbsolutePath.removeAt(wegmuss); |
| 4277 |
extraExt2.removeAt(wegmuss); |
| 4278 |
} |
| 4279 |
altExtraIconPaths.append(altExtraIconPath); |
| 4280 |
extraProgramNames.append(extraName->text().trimmed()); |
| 4281 |
extraProgramPaths.append(extraPath->text().trimmed()); |
| 4282 |
extraArguments.append(useArgument->checkState()); |
| 4283 |
extraOptions.append(extraArgumentsEdit->text().trimmed()); |
| 4284 |
extraExt2.append(extraAltExtEdit->text().trimmed()); |
| 4285 |
extraExtensions.append(omitExtension->checkState()); |
| 4286 |
extraAbsolutePath.append(absolutePath->checkState()); |
| 4287 |
extraResIns.append(copyResIns->checkState()); |
| 4288 |
extraOpenFileDialogBefore.append(openFileDialogBefore->checkState()); |
| 4289 |
extraIconOverlay.append(iconOverlay->checkState()); |
| 4290 |
extraOverlayPointSize.append(iovlPointSize->value()); |
| 4291 |
extraDetach.append(detach->checkState()); |
| 4292 |
einstellung->beginGroup("Extra"); |
| 4293 |
einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); |
| 4294 |
for (int i = 0; i < extraProgramNames.size(); i++) { |
| 4295 |
einstellung->setArrayIndex(i); |
| 4296 |
einstellung->setValue("Name", extraProgramNames.at(i)); |
| 4297 |
} |
| 4298 |
einstellung->endArray(); |
| 4299 |
einstellung->endGroup(); |
| 4300 |
|
| 4301 |
einstellung->beginGroup("Extra"); |
| 4302 |
einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); |
| 4303 |
for (int i = 0; i < extraProgramPaths.size(); i++) { |
| 4304 |
einstellung->setArrayIndex(i); |
| 4305 |
einstellung->setValue("Path", extraProgramPaths.at(i)); |
| 4306 |
} |
| 4307 |
einstellung->endArray(); |
| 4308 |
einstellung->endGroup(); |
| 4309 |
|
| 4310 |
einstellung->beginGroup("Extra"); |
| 4311 |
einstellung->beginWriteArray("AlternativeExtensions",extraExt2.size()); |
| 4312 |
for (int i = 0; i < extraExt2.size(); i++) { |
| 4313 |
einstellung->setArrayIndex(i); |
| 4314 |
einstellung->setValue("ext", extraExt2.at(i)); |
| 4315 |
} |
| 4316 |
einstellung->endArray(); |
| 4317 |
einstellung->endGroup(); |
| 4318 |
|
| 4319 |
einstellung->beginGroup("Extra"); |
| 4320 |
einstellung->beginWriteArray("CommandLineOptions",extraOptions.size()); |
| 4321 |
for (int i = 0; i < extraOptions.size(); i++) { |
| 4322 |
einstellung->setArrayIndex(i); |
| 4323 |
einstellung->setValue("opt", extraOptions.at(i)); |
| 4324 |
} |
| 4325 |
einstellung->endArray(); |
| 4326 |
einstellung->endGroup(); |
| 4327 |
|
| 4328 |
einstellung->beginGroup("Extra"); |
| 4329 |
einstellung->beginWriteArray("AbsolutePathRequired",extraAbsolutePath.size()); |
| 4330 |
for (int i = 0; i < extraAbsolutePath.size(); i++) { |
| 4331 |
einstellung->setArrayIndex(i); |
| 4332 |
einstellung->setValue("absolute", extraAbsolutePath.at(i)); |
| 4333 |
} |
| 4334 |
einstellung->endArray(); |
| 4335 |
einstellung->endGroup(); |
| 4336 |
|
| 4337 |
einstellung->beginGroup("Extra"); |
| 4338 |
einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); |
| 4339 |
for (int i = 0; i < extraArguments.size(); i++) { |
| 4340 |
einstellung->setArrayIndex(i); |
| 4341 |
einstellung->setValue("Arg", extraArguments.at(i)); |
| 4342 |
} |
| 4343 |
einstellung->endArray(); |
| 4344 |
einstellung->endGroup(); |
| 4345 |
|
| 4346 |
einstellung->beginGroup("Extra"); |
| 4347 |
einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); |
| 4348 |
for (int i = 0; i < extraExtensions.size(); i++) { |
| 4349 |
einstellung->setArrayIndex(i); |
| 4350 |
einstellung->setValue("Ext", extraExtensions.at(i)); |
| 4351 |
} |
| 4352 |
einstellung->endArray(); |
| 4353 |
einstellung->endGroup(); |
| 4354 |
|
| 4355 |
einstellung->beginGroup("Extra"); |
| 4356 |
einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); |
| 4357 |
for (int i = 0; i < extraResIns.size(); i++) { |
| 4358 |
einstellung->setArrayIndex(i); |
| 4359 |
einstellung->setValue("Res2Ins", extraResIns.at(i)); |
| 4360 |
} |
| 4361 |
einstellung->endArray(); |
| 4362 |
einstellung->endGroup(); |
| 4363 |
|
| 4364 |
einstellung->beginGroup("Extra"); |
| 4365 |
einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); |
| 4366 |
for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { |
| 4367 |
einstellung->setArrayIndex(i); |
| 4368 |
einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); |
| 4369 |
} |
| 4370 |
einstellung->endArray(); |
| 4371 |
einstellung->endGroup(); |
| 4372 |
|
| 4373 |
einstellung->beginGroup("Extra"); |
| 4374 |
einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); |
| 4375 |
for (int i = 0; i < extraIconOverlay.size(); i++) { |
| 4376 |
einstellung->setArrayIndex(i); |
| 4377 |
einstellung->setValue("icov", extraIconOverlay.at(i)); |
| 4378 |
} |
| 4379 |
einstellung->endArray(); |
| 4380 |
einstellung->endGroup(); |
| 4381 |
|
| 4382 |
einstellung->beginGroup("Extra"); |
| 4383 |
einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); |
| 4384 |
for (int i = 0; i < extraOverlayPointSize.size(); i++) { |
| 4385 |
einstellung->setArrayIndex(i); |
| 4386 |
einstellung->setValue("icov", extraOverlayPointSize.at(i)); |
| 4387 |
} |
| 4388 |
einstellung->endArray(); |
| 4389 |
einstellung->endGroup(); |
| 4390 |
|
| 4391 |
einstellung->beginGroup("Extra"); |
| 4392 |
einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); |
| 4393 |
for (int i = 0; i < altExtraIconPaths.size(); i++) { |
| 4394 |
einstellung->setArrayIndex(i); |
| 4395 |
einstellung->setValue("altIcon", altExtraIconPaths.at(i)); |
| 4396 |
} |
| 4397 |
einstellung->endArray(); |
| 4398 |
einstellung->endGroup(); |
| 4399 |
|
| 4400 |
einstellung->beginGroup("Extra"); |
| 4401 |
einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); |
| 4402 |
for (int i = 0; i < extraDetach.size(); i++) { |
| 4403 |
einstellung->setArrayIndex(i); |
| 4404 |
einstellung->setValue("Detach", extraDetach.at(i)); |
| 4405 |
} |
| 4406 |
einstellung->endArray(); |
| 4407 |
einstellung->endGroup(); |
| 4408 |
extraMenu->clear(); |
| 4409 |
extraTB->clear(); |
| 4410 |
extraMenu->addAction("add/remove external program",this,SLOT(extraSettings())); |
| 4411 |
QFileIconProvider *p = new QFileIconProvider(); |
| 4412 |
if (extraProgramNames.size()) extraMenu->addSeparator(); |
| 4413 |
for (int i=0; i<extraProgramNames.size(); i++){ |
| 4414 |
QAction *a; |
| 4415 |
QString icopa=extraProgramPaths.at(i); |
| 4416 |
QFileIconProvider *epic = new QFileIconProvider(); |
| 4417 |
QIcon ico = epic->icon(QFileInfo(icopa)); |
| 4418 |
//qDebug()<<ico.availableSizes()<<ico.actualSize(QSize(32,32)); |
| 4419 |
QPixmap fmap = ico.pixmap(32,32); |
| 4420 |
if (QFile::exists(altExtraIconPaths.at(i))) fmap=QIcon(altExtraIconPaths.at(i)).pixmap(64,64); |
| 4421 |
delete epic; |
| 4422 |
|
| 4423 |
if (extraIconOverlay.at(i)==Qt::Checked){ |
| 4424 |
QPainter *paint = new QPainter(&fmap); |
| 4425 |
paint->setPen(QPen(QColor("#FFFFFF"))); |
| 4426 |
QFont ifont=chgl->myFont; |
| 4427 |
ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); |
| 4428 |
paint->setFont(ifont); |
| 4429 |
paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); |
| 4430 |
paint->setPen(QPen(QColor("#000000"))); |
| 4431 |
paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); |
| 4432 |
paint->end(); |
| 4433 |
} |
| 4434 |
extraIcon=QIcon(fmap); |
| 4435 |
a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); |
| 4436 |
a->setData(i); |
| 4437 |
extraTB->addAction(a); |
| 4438 |
} |
| 4439 |
//printf("extraSettings()\n"); |
| 4440 |
delete p; |
| 4441 |
|
| 4442 |
} |
| 4443 |
extDLG->deleteLater (); |
| 4444 |
if (strcmp(PROGRAM_NAME,"shelXle")){ |
| 4445 |
QMessageBox::information(0,"information","Restart of APEX is required to make your changes to external programs active. ",QMessageBox::Ok); |
| 4446 |
|
| 4447 |
} |
| 4448 |
// printf("extraSettings()\n"); |
| 4449 |
} |
| 4450 |
|
| 4451 |
void Window::extraSettingsLast(){ |
| 4452 |
QDialog *extDLG = new QDialog(this); |
| 4453 |
extDLG->setWindowTitle("External programs"); |
| 4454 |
QGridLayout *lt = new QGridLayout(extDLG); |
| 4455 |
pgms = new QComboBox(extDLG); |
| 4456 |
pgms->addItems(extraProgramNames); |
| 4457 |
connect(pgms,SIGNAL(currentIndexChanged(int)), this, SLOT(updateExtraSettings(int))); |
| 4458 |
QLabel *extraNameL = new QLabel("Name of external program for menu entry:",extDLG); |
| 4459 |
extraName = new QLineEdit(extDLG); |
| 4460 |
extraName->setMinimumSize(150,15); |
| 4461 |
QLabel *extraPathL = new QLabel("Full path to executable",extDLG); |
| 4462 |
extraPath = new QLineEdit(extDLG); |
| 4463 |
QLabel *argumentsL = new QLabel("Commandline options",extDLG); |
| 4464 |
extraArgumentsEdit = new QLineEdit(extDLG); |
| 4465 |
QLabel *altExtL = new QLabel("Alternative file Extension",extDLG); |
| 4466 |
extraAltExtEdit = new QLineEdit(extDLG); |
| 4467 |
QPushButton *browsePath = new QPushButton("Browse",extDLG); |
| 4468 |
extraFakeButton = new QToolButton(extDLG); |
| 4469 |
extraFakeButton->setIconSize(QSize(tbiconSize,tbiconSize)); |
| 4470 |
connect(browsePath,SIGNAL(pressed ()),this, SLOT(setExtraPath())); |
| 4471 |
connect(extraFakeButton,SIGNAL(pressed()),this,SLOT(brwsIcon())); |
| 4472 |
useArgument = new QCheckBox("Give file name as argument",extDLG); |
| 4473 |
omitExtension = new QCheckBox("Omit '*.res' extension in argument",extDLG); |
| 4474 |
absolutePath = new QCheckBox("Use absolute path in argument",extDLG); |
| 4475 |
copyResIns = new QCheckBox("Copy .res file to ins file before execution",extDLG); |
| 4476 |
openFileDialogBefore = new QCheckBox("Open file dialog before execution",extDLG); |
| 4477 |
iconOverlay = new QCheckBox("Text overlay",extDLG); |
| 4478 |
iovlPointSize = new QSpinBox(extDLG); |
| 4479 |
iovlPointSize->setRange(4,96); |
| 4480 |
iovlPointSize->setValue(36); |
| 4481 |
iovlPointSize->setPrefix("PointSize "); |
| 4482 |
connect(iconOverlay,SIGNAL(stateChanged(int)),this,SLOT(updateExtraIcon())); |
| 4483 |
connect(iovlPointSize,SIGNAL(valueChanged(int)),this,SLOT(updateExtraIcon())); |
| 4484 |
detach = new QCheckBox("start detached",extDLG); |
| 4485 |
detach->setChecked(true); |
| 4486 |
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::No| QDialogButtonBox::Ok | QDialogButtonBox::Cancel,Qt::Horizontal,extDLG); |
| 4487 |
QPushButton *ok = buttonBox->button(QDialogButtonBox::Ok); |
| 4488 |
ok->setText("Add program"); |
| 4489 |
QPushButton *no =buttonBox->button(QDialogButtonBox::No); |
| 4490 |
no->setText("Remove program"); |
| 4491 |
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),this,SLOT(removeExtra(QAbstractButton*))); |
| 4492 |
connect(buttonBox, SIGNAL(accepted()), extDLG, SLOT(accept())); |
| 4493 |
connect(buttonBox, SIGNAL(rejected()), extDLG, SLOT(reject())); |
| 4494 |
lt->addWidget(pgms,0,0); |
| 4495 |
lt->addWidget(extraNameL,1,0); |
| 4496 |
lt->addWidget(extraName, 1,1); |
| 4497 |
lt->addWidget(extraPathL,2,0); |
| 4498 |
lt->addWidget(extraPath, 2,1); |
| 4499 |
lt->addWidget(browsePath,2,2); |
| 4500 |
lt->addWidget(extraFakeButton,0,1); |
| 4501 |
lt->addWidget(iconOverlay,0,2); |
| 4502 |
lt->addWidget(iovlPointSize,0,3); |
| 4503 |
lt->addWidget(argumentsL,4,0); |
| 4504 |
lt->addWidget(extraArgumentsEdit,4,1); |
| 4505 |
lt->addWidget(altExtL,5,0); |
| 4506 |
lt->addWidget(extraAltExtEdit,5,1); |
| 4507 |
lt->addWidget(useArgument, 1, 9); |
| 4508 |
lt->addWidget(absolutePath, 2, 9); |
| 4509 |
lt->addWidget(omitExtension, 3, 9); |
| 4510 |
lt->addWidget(detach, 4, 9); |
| 4511 |
lt->addWidget(copyResIns, 5, 9); |
| 4512 |
lt->addWidget(openFileDialogBefore, 6, 9); |
| 4513 |
lt->addWidget(buttonBox,14,0,1,11); |
| 4514 |
extDLG->setLayout(lt); |
| 4515 |
altExtraIconPath=""; |
| 4516 |
pgms->setCurrentIndex(extraProgramNames.size()-1); |
| 4517 |
updateExtraSettings(extraProgramNames.size()-1); |
| 4518 |
|
| 4519 |
while (extraOptions.size()>extraProgramNames.size()){extraOptions.removeLast();} |
| 4520 |
while (extraExt2.size()>extraProgramNames.size()){extraExt2.removeLast();} |
| 4521 |
|
| 4522 |
if (extDLG->exec()==QDialog::Accepted) { |
| 4523 |
int wegmuss=extraProgramNames.indexOf(extraName->text()); |
| 4524 |
if (wegmuss!=-1) { |
| 4525 |
extraProgramNames.removeAt(wegmuss); |
| 4526 |
extraProgramPaths.removeAt(wegmuss); |
| 4527 |
extraArguments.removeAt(wegmuss); |
| 4528 |
extraExtensions.removeAt(wegmuss); |
| 4529 |
if (wegmuss<extraAbsolutePath.size())extraAbsolutePath.removeAt(wegmuss); |
| 4530 |
if (wegmuss<extraResIns.size()) extraResIns.removeAt(wegmuss); |
| 4531 |
if (wegmuss<extraOpenFileDialogBefore.size()) extraOpenFileDialogBefore.removeAt(wegmuss); |
| 4532 |
if (wegmuss<extraIconOverlay.size()) extraIconOverlay.removeAt(wegmuss); |
| 4533 |
if (wegmuss<extraOverlayPointSize.size()) extraOverlayPointSize.removeAt(wegmuss); |
| 4534 |
if (wegmuss<altExtraIconPaths.size()) altExtraIconPaths.removeAt(wegmuss); |
| 4535 |
extraDetach.removeAt(wegmuss); |
| 4536 |
extraOptions.removeAt(wegmuss); |
| 4537 |
extraExt2.removeAt(wegmuss); |
| 4538 |
} |
| 4539 |
altExtraIconPaths.append(altExtraIconPath); |
| 4540 |
extraProgramNames.append(extraName->text().trimmed()); |
| 4541 |
extraProgramPaths.append(extraPath->text().trimmed()); |
| 4542 |
extraArguments.append(useArgument->checkState()); |
| 4543 |
extraOptions.append(extraArgumentsEdit->text().trimmed()); |
| 4544 |
extraExt2.append(extraAltExtEdit->text().trimmed()); |
| 4545 |
extraExtensions.append(omitExtension->checkState()); |
| 4546 |
extraAbsolutePath.append(absolutePath->checkState()); |
| 4547 |
extraResIns.append(copyResIns->checkState()); |
| 4548 |
extraOpenFileDialogBefore.append(openFileDialogBefore->checkState()); |
| 4549 |
extraIconOverlay.append(iconOverlay->checkState()); |
| 4550 |
extraOverlayPointSize.append(iovlPointSize->value()); |
| 4551 |
extraDetach.append(detach->checkState()); |
| 4552 |
einstellung->beginGroup("Extra"); |
| 4553 |
einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); |
| 4554 |
for (int i = 0; i < extraProgramNames.size(); i++) { |
| 4555 |
einstellung->setArrayIndex(i); |
| 4556 |
einstellung->setValue("Name", extraProgramNames.at(i)); |
| 4557 |
} |
| 4558 |
einstellung->endArray(); |
| 4559 |
einstellung->endGroup(); |
| 4560 |
|
| 4561 |
einstellung->beginGroup("Extra"); |
| 4562 |
einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); |
| 4563 |
for (int i = 0; i < extraProgramPaths.size(); i++) { |
| 4564 |
einstellung->setArrayIndex(i); |
| 4565 |
einstellung->setValue("Path", extraProgramPaths.at(i)); |
| 4566 |
} |
| 4567 |
einstellung->endArray(); |
| 4568 |
einstellung->endGroup(); |
| 4569 |
|
| 4570 |
einstellung->beginGroup("Extra"); |
| 4571 |
einstellung->beginWriteArray("AlternativeExtensions",extraExt2.size()); |
| 4572 |
for (int i = 0; i < extraExt2.size(); i++) { |
| 4573 |
einstellung->setArrayIndex(i); |
| 4574 |
einstellung->setValue("ext", extraExt2.at(i)); |
| 4575 |
} |
| 4576 |
einstellung->endArray(); |
| 4577 |
einstellung->endGroup(); |
| 4578 |
|
| 4579 |
einstellung->beginGroup("Extra"); |
| 4580 |
einstellung->beginWriteArray("CommandLineOptions",extraOptions.size()); |
| 4581 |
for (int i = 0; i < extraOptions.size(); i++) { |
| 4582 |
einstellung->setArrayIndex(i); |
| 4583 |
einstellung->setValue("opt", extraOptions.at(i)); |
| 4584 |
} |
| 4585 |
einstellung->endArray(); |
| 4586 |
einstellung->endGroup(); |
| 4587 |
|
| 4588 |
einstellung->beginGroup("Extra"); |
| 4589 |
einstellung->beginWriteArray("AbsolutePathRequired",extraAbsolutePath.size()); |
| 4590 |
for (int i = 0; i < extraAbsolutePath.size(); i++) { |
| 4591 |
einstellung->setArrayIndex(i); |
| 4592 |
einstellung->setValue("absolute", extraAbsolutePath.at(i)); |
| 4593 |
} |
| 4594 |
einstellung->endArray(); |
| 4595 |
einstellung->endGroup(); |
| 4596 |
|
| 4597 |
einstellung->beginGroup("Extra"); |
| 4598 |
einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); |
| 4599 |
for (int i = 0; i < extraArguments.size(); i++) { |
| 4600 |
einstellung->setArrayIndex(i); |
| 4601 |
einstellung->setValue("Arg", extraArguments.at(i)); |
| 4602 |
} |
| 4603 |
einstellung->endArray(); |
| 4604 |
einstellung->endGroup(); |
| 4605 |
|
| 4606 |
einstellung->beginGroup("Extra"); |
| 4607 |
einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); |
| 4608 |
for (int i = 0; i < extraExtensions.size(); i++) { |
| 4609 |
einstellung->setArrayIndex(i); |
| 4610 |
einstellung->setValue("Ext", extraExtensions.at(i)); |
| 4611 |
} |
| 4612 |
einstellung->endArray(); |
| 4613 |
einstellung->endGroup(); |
| 4614 |
|
| 4615 |
einstellung->beginGroup("Extra"); |
| 4616 |
einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); |
| 4617 |
for (int i = 0; i < extraResIns.size(); i++) { |
| 4618 |
einstellung->setArrayIndex(i); |
| 4619 |
einstellung->setValue("Res2Ins", extraResIns.at(i)); |
| 4620 |
} |
| 4621 |
einstellung->endArray(); |
| 4622 |
einstellung->endGroup(); |
| 4623 |
|
| 4624 |
einstellung->beginGroup("Extra"); |
| 4625 |
einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); |
| 4626 |
for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { |
| 4627 |
einstellung->setArrayIndex(i); |
| 4628 |
einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); |
| 4629 |
} |
| 4630 |
einstellung->endArray(); |
| 4631 |
einstellung->endGroup(); |
| 4632 |
|
| 4633 |
einstellung->beginGroup("Extra"); |
| 4634 |
einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); |
| 4635 |
for (int i = 0; i < extraIconOverlay.size(); i++) { |
| 4636 |
einstellung->setArrayIndex(i); |
| 4637 |
einstellung->setValue("icov", extraIconOverlay.at(i)); |
| 4638 |
} |
| 4639 |
einstellung->endArray(); |
| 4640 |
einstellung->endGroup(); |
| 4641 |
|
| 4642 |
einstellung->beginGroup("Extra"); |
| 4643 |
einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); |
| 4644 |
for (int i = 0; i < extraOverlayPointSize.size(); i++) { |
| 4645 |
einstellung->setArrayIndex(i); |
| 4646 |
einstellung->setValue("icov", extraOverlayPointSize.at(i)); |
| 4647 |
} |
| 4648 |
einstellung->endArray(); |
| 4649 |
einstellung->endGroup(); |
| 4650 |
|
| 4651 |
einstellung->beginGroup("Extra"); |
| 4652 |
einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); |
| 4653 |
for (int i = 0; i < altExtraIconPaths.size(); i++) { |
| 4654 |
einstellung->setArrayIndex(i); |
| 4655 |
einstellung->setValue("altIcon", altExtraIconPaths.at(i)); |
| 4656 |
} |
| 4657 |
einstellung->endArray(); |
| 4658 |
einstellung->endGroup(); |
| 4659 |
|
| 4660 |
einstellung->beginGroup("Extra"); |
| 4661 |
einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); |
| 4662 |
for (int i = 0; i < extraDetach.size(); i++) { |
| 4663 |
einstellung->setArrayIndex(i); |
| 4664 |
einstellung->setValue("Detach", extraDetach.at(i)); |
| 4665 |
} |
| 4666 |
einstellung->endArray(); |
| 4667 |
einstellung->endGroup(); |
| 4668 |
extraMenu->clear(); |
| 4669 |
extraTB->clear(); |
| 4670 |
extraMenu->addAction("add/remove external program",this,SLOT(extraSettings())); |
| 4671 |
QFileIconProvider *p = new QFileIconProvider(); |
| 4672 |
if (extraProgramNames.size()) extraMenu->addSeparator(); |
| 4673 |
for (int i=0; i<extraProgramNames.size(); i++){ |
| 4674 |
QAction *a; |
| 4675 |
QString icopa=extraProgramPaths.at(i); |
| 4676 |
QFileIconProvider *epic = new QFileIconProvider(); |
| 4677 |
QIcon ico = epic->icon(QFileInfo(icopa)); |
| 4678 |
//qDebug()<<ico.availableSizes()<<ico.actualSize(QSize(32,32)); |
| 4679 |
QPixmap fmap = ico.pixmap(32,32); |
| 4680 |
if (QFile::exists(altExtraIconPaths.at(i))) fmap=QIcon(altExtraIconPaths.at(i)).pixmap(64,64); |
| 4681 |
delete epic; |
| 4682 |
|
| 4683 |
if (extraIconOverlay.at(i)==Qt::Checked){ |
| 4684 |
QPainter *paint = new QPainter(&fmap); |
| 4685 |
paint->setPen(QPen(QColor("#FFFFFF"))); |
| 4686 |
QFont ifont=chgl->myFont; |
| 4687 |
ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); |
| 4688 |
paint->setFont(ifont); |
| 4689 |
paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); |
| 4690 |
paint->setPen(QPen(QColor("#000000"))); |
| 4691 |
paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); |
| 4692 |
paint->end(); |
| 4693 |
} |
| 4694 |
extraIcon=QIcon(fmap); |
| 4695 |
a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); |
| 4696 |
a->setData(i); |
| 4697 |
extraTB->addAction(a); |
| 4698 |
} |
| 4699 |
delete p; |
| 4700 |
|
| 4701 |
} |
| 4702 |
// printf("extraSettingsLast()\n"); |
| 4703 |
extDLG->deleteLater (); |
| 4704 |
if (strcmp(PROGRAM_NAME,"shelXle")){ |
| 4705 |
QMessageBox::information(0,"information","Restart of APEX is required to make your changes to external programs active. ",QMessageBox::Ok); |
| 4706 |
|
| 4707 |
} |
| 4708 |
// printf("extraSettingsLast()\n"); |
| 4709 |
} |
| 4710 |
void Window::removeExtra(QAbstractButton *button){ |
| 4711 |
if (button->text()=="Remove program") { |
| 4712 |
int wegmuss=extraProgramNames.indexOf(extraName->text()); |
| 4713 |
if (wegmuss!=-1) { |
| 4714 |
extraProgramNames.removeAt(wegmuss); |
| 4715 |
extraProgramPaths.removeAt(wegmuss); |
| 4716 |
extraArguments.removeAt(wegmuss); |
| 4717 |
extraExtensions.removeAt(wegmuss); |
| 4718 |
if (wegmuss<extraAbsolutePath.size())extraAbsolutePath.removeAt(wegmuss); |
| 4719 |
if (wegmuss<extraResIns.size()) extraResIns.removeAt(wegmuss); |
| 4720 |
if (wegmuss<extraOpenFileDialogBefore.size()) extraOpenFileDialogBefore.removeAt(wegmuss); |
| 4721 |
if (wegmuss<extraIconOverlay.size()) extraIconOverlay.removeAt(wegmuss); |
| 4722 |
if (wegmuss<extraOverlayPointSize.size()) extraOverlayPointSize.removeAt(wegmuss); |
| 4723 |
if (wegmuss<altExtraIconPaths.size()) altExtraIconPaths.removeAt(wegmuss); |
| 4724 |
extraOptions.removeAt(wegmuss); |
| 4725 |
extraExt2.removeAt(wegmuss); |
| 4726 |
extraDetach.removeAt(wegmuss); |
| 4727 |
} |
| 4728 |
while (extraOptions.size()>extraProgramNames.size()){extraOptions.removeLast();} |
| 4729 |
while (extraExt2.size()>extraProgramNames.size()){extraExt2.removeLast();} |
| 4730 |
einstellung->beginGroup("Extra"); |
| 4731 |
einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); |
| 4732 |
for (int i = 0; i < extraProgramNames.size(); i++) { |
| 4733 |
einstellung->setArrayIndex(i); |
| 4734 |
einstellung->setValue("Name", extraProgramNames.at(i)); |
| 4735 |
} |
| 4736 |
einstellung->endArray(); |
| 4737 |
einstellung->endGroup(); |
| 4738 |
|
| 4739 |
einstellung->beginGroup("Extra"); |
| 4740 |
einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); |
| 4741 |
for (int i = 0; i < extraProgramPaths.size(); i++) { |
| 4742 |
einstellung->setArrayIndex(i); |
| 4743 |
einstellung->setValue("Path", extraProgramPaths.at(i)); |
| 4744 |
} |
| 4745 |
einstellung->endArray(); |
| 4746 |
einstellung->endGroup(); |
| 4747 |
|
| 4748 |
|
| 4749 |
einstellung->beginGroup("Extra"); |
| 4750 |
einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); |
| 4751 |
for (int i = 0; i < extraArguments.size(); i++) { |
| 4752 |
einstellung->setArrayIndex(i); |
| 4753 |
einstellung->setValue("Arg", extraArguments.at(i)); |
| 4754 |
} |
| 4755 |
einstellung->endArray(); |
| 4756 |
einstellung->endGroup(); |
| 4757 |
|
| 4758 |
einstellung->beginGroup("Extra"); |
| 4759 |
einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); |
| 4760 |
for (int i = 0; i < extraExtensions.size(); i++) { |
| 4761 |
einstellung->setArrayIndex(i); |
| 4762 |
einstellung->setValue("Ext", extraExtensions.at(i)); |
| 4763 |
} |
| 4764 |
einstellung->endArray(); |
| 4765 |
einstellung->endGroup(); |
| 4766 |
|
| 4767 |
einstellung->beginGroup("Extra"); |
| 4768 |
einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); |
| 4769 |
for (int i = 0; i < extraResIns.size(); i++) { |
| 4770 |
einstellung->setArrayIndex(i); |
| 4771 |
einstellung->setValue("Res2Ins", extraResIns.at(i)); |
| 4772 |
} |
| 4773 |
einstellung->endArray(); |
| 4774 |
einstellung->endGroup(); |
| 4775 |
|
| 4776 |
einstellung->beginGroup("Extra"); |
| 4777 |
einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); |
| 4778 |
for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { |
| 4779 |
einstellung->setArrayIndex(i); |
| 4780 |
einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); |
| 4781 |
} |
| 4782 |
einstellung->endArray(); |
| 4783 |
einstellung->endGroup(); |
| 4784 |
|
| 4785 |
|
| 4786 |
einstellung->beginGroup("Extra"); |
| 4787 |
einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); |
| 4788 |
for (int i = 0; i < extraIconOverlay.size(); i++) { |
| 4789 |
einstellung->setArrayIndex(i); |
| 4790 |
einstellung->setValue("icov", extraIconOverlay.at(i)); |
| 4791 |
} |
| 4792 |
einstellung->endArray(); |
| 4793 |
einstellung->endGroup(); |
| 4794 |
|
| 4795 |
einstellung->beginGroup("Extra"); |
| 4796 |
einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); |
| 4797 |
for (int i = 0; i < extraOverlayPointSize.size(); i++) { |
| 4798 |
einstellung->setArrayIndex(i); |
| 4799 |
einstellung->setValue("icov", extraOverlayPointSize.at(i)); |
| 4800 |
} |
| 4801 |
einstellung->endArray(); |
| 4802 |
einstellung->endGroup(); |
| 4803 |
|
| 4804 |
einstellung->beginGroup("Extra"); |
| 4805 |
einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); |
| 4806 |
for (int i = 0; i < altExtraIconPaths.size(); i++) { |
| 4807 |
einstellung->setArrayIndex(i); |
| 4808 |
einstellung->setValue("altIcon", altExtraIconPaths.at(i)); |
| 4809 |
} |
| 4810 |
einstellung->endArray(); |
| 4811 |
einstellung->endGroup(); |
| 4812 |
|
| 4813 |
einstellung->beginGroup("Extra"); |
| 4814 |
einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); |
| 4815 |
for (int i = 0; i < extraDetach.size(); i++) { |
| 4816 |
einstellung->setArrayIndex(i); |
| 4817 |
einstellung->setValue("Detach", extraDetach.at(i)); |
| 4818 |
} |
| 4819 |
einstellung->endArray(); |
| 4820 |
einstellung->endGroup(); |
| 4821 |
extraMenu->clear(); |
| 4822 |
|
| 4823 |
extraMenu->addAction("add external program",this,SLOT(extraSettings())); |
| 4824 |
extraTB->clear(); |
| 4825 |
QFileIconProvider *epic = new QFileIconProvider(); |
| 4826 |
if (extraProgramNames.size()) extraMenu->addSeparator(); |
| 4827 |
for (int i=0; i<extraProgramNames.size(); i++){ |
| 4828 |
QAction *a; |
| 4829 |
QString icopa=extraProgramPaths.at(i); |
| 4830 |
QIcon ico = epic->icon(QFileInfo(icopa)); |
| 4831 |
//qDebug()<<ico.availableSizes()<<ico.actualSize(QSize(32,32)); |
| 4832 |
QPixmap fmap = ico.pixmap(32,32); |
| 4833 |
if (QFile::exists(altExtraIconPaths.at(i))) fmap=QIcon(altExtraIconPaths.at(i)).pixmap(64,64); |
| 4834 |
if (extraIconOverlay.at(i)==Qt::Checked){ |
| 4835 |
QPainter *paint = new QPainter(&fmap); |
| 4836 |
paint->setPen(QPen(QColor("#FFFFFF"))); |
| 4837 |
QFont ifont=chgl->myFont; |
| 4838 |
ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); |
| 4839 |
paint->setFont(ifont); |
| 4840 |
paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); |
| 4841 |
paint->setPen(QPen(QColor("#000000"))); |
| 4842 |
paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); |
| 4843 |
paint->end(); |
| 4844 |
} |
| 4845 |
extraIcon=QIcon(fmap); |
| 4846 |
a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); |
| 4847 |
a->setData(i); |
| 4848 |
extraTB->addAction(a); |
| 4849 |
} |
| 4850 |
delete epic; |
| 4851 |
|
| 4852 |
} |
| 4853 |
else if (button->text()=="Apply"){ |
| 4854 |
|
| 4855 |
int wegmuss = pgms->currentIndex(); |
| 4856 |
if ((wegmuss < 0)||(wegmuss >= extraProgramNames.size())) return; |
| 4857 |
printf("changing extra programm %d\n", wegmuss); |
| 4858 |
altExtraIconPaths[wegmuss] = altExtraIconPath; |
| 4859 |
extraProgramNames[wegmuss] = extraName->text().trimmed(); |
| 4860 |
extraProgramPaths[wegmuss] = extraPath->text().trimmed(); |
| 4861 |
extraArguments[wegmuss] = useArgument->checkState(); |
| 4862 |
extraOptions[wegmuss] = extraArgumentsEdit->text().trimmed(); |
| 4863 |
extraExt2[wegmuss] = extraAltExtEdit->text().trimmed(); |
| 4864 |
extraExtensions[wegmuss] = omitExtension->checkState(); |
| 4865 |
extraAbsolutePath[wegmuss] = absolutePath->checkState(); |
| 4866 |
extraResIns[wegmuss] = copyResIns->checkState(); |
| 4867 |
extraOpenFileDialogBefore[wegmuss] = openFileDialogBefore->checkState(); |
| 4868 |
extraIconOverlay[wegmuss] = iconOverlay->checkState(); |
| 4869 |
extraOverlayPointSize[wegmuss] = iovlPointSize->value(); |
| 4870 |
extraDetach[wegmuss] = detach->checkState(); |
| 4871 |
|
| 4872 |
einstellung->beginGroup("Extra"); |
| 4873 |
einstellung->beginWriteArray("ProgramNames",extraProgramNames.size()); |
| 4874 |
for (int i = 0; i < extraProgramNames.size(); i++) { |
| 4875 |
einstellung->setArrayIndex(i); |
| 4876 |
einstellung->setValue("Name", extraProgramNames.at(i)); |
| 4877 |
} |
| 4878 |
einstellung->endArray(); |
| 4879 |
einstellung->endGroup(); |
| 4880 |
|
| 4881 |
einstellung->beginGroup("Extra"); |
| 4882 |
einstellung->beginWriteArray("ProgramPaths",extraProgramPaths.size()); |
| 4883 |
for (int i = 0; i < extraProgramPaths.size(); i++) { |
| 4884 |
einstellung->setArrayIndex(i); |
| 4885 |
einstellung->setValue("Path", extraProgramPaths.at(i)); |
| 4886 |
} |
| 4887 |
einstellung->endArray(); |
| 4888 |
einstellung->endGroup(); |
| 4889 |
|
| 4890 |
einstellung->beginGroup("Extra"); |
| 4891 |
einstellung->beginWriteArray("AlternativeExtensions",extraExt2.size()); |
| 4892 |
for (int i = 0; i < extraExt2.size(); i++) { |
| 4893 |
einstellung->setArrayIndex(i); |
| 4894 |
einstellung->setValue("ext", extraExt2.at(i)); |
| 4895 |
} |
| 4896 |
einstellung->endArray(); |
| 4897 |
einstellung->endGroup(); |
| 4898 |
|
| 4899 |
einstellung->beginGroup("Extra"); |
| 4900 |
einstellung->beginWriteArray("CommandLineOptions",extraOptions.size()); |
| 4901 |
for (int i = 0; i < extraOptions.size(); i++) { |
| 4902 |
einstellung->setArrayIndex(i); |
| 4903 |
einstellung->setValue("opt", extraOptions.at(i)); |
| 4904 |
} |
| 4905 |
einstellung->endArray(); |
| 4906 |
einstellung->endGroup(); |
| 4907 |
|
| 4908 |
einstellung->beginGroup("Extra"); |
| 4909 |
einstellung->beginWriteArray("AbsolutePathRequired",extraAbsolutePath.size()); |
| 4910 |
for (int i = 0; i < extraAbsolutePath.size(); i++) { |
| 4911 |
einstellung->setArrayIndex(i); |
| 4912 |
einstellung->setValue("absolute", extraAbsolutePath.at(i)); |
| 4913 |
} |
| 4914 |
einstellung->endArray(); |
| 4915 |
einstellung->endGroup(); |
| 4916 |
|
| 4917 |
einstellung->beginGroup("Extra"); |
| 4918 |
einstellung->beginWriteArray("ProgramArgs",extraArguments.size()); |
| 4919 |
for (int i = 0; i < extraArguments.size(); i++) { |
| 4920 |
einstellung->setArrayIndex(i); |
| 4921 |
einstellung->setValue("Arg", extraArguments.at(i)); |
| 4922 |
} |
| 4923 |
einstellung->endArray(); |
| 4924 |
einstellung->endGroup(); |
| 4925 |
|
| 4926 |
einstellung->beginGroup("Extra"); |
| 4927 |
einstellung->beginWriteArray("ProgramExtensions",extraExtensions.size()); |
| 4928 |
for (int i = 0; i < extraExtensions.size(); i++) { |
| 4929 |
einstellung->setArrayIndex(i); |
| 4930 |
einstellung->setValue("Ext", extraExtensions.at(i)); |
| 4931 |
} |
| 4932 |
einstellung->endArray(); |
| 4933 |
einstellung->endGroup(); |
| 4934 |
|
| 4935 |
einstellung->beginGroup("Extra"); |
| 4936 |
einstellung->beginWriteArray("ProgramResIns",extraResIns.size()); |
| 4937 |
for (int i = 0; i < extraResIns.size(); i++) { |
| 4938 |
einstellung->setArrayIndex(i); |
| 4939 |
einstellung->setValue("Res2Ins", extraResIns.at(i)); |
| 4940 |
} |
| 4941 |
einstellung->endArray(); |
| 4942 |
einstellung->endGroup(); |
| 4943 |
|
| 4944 |
einstellung->beginGroup("Extra"); |
| 4945 |
einstellung->beginWriteArray("FileDialog",extraOpenFileDialogBefore.size()); |
| 4946 |
for (int i = 0; i < extraOpenFileDialogBefore.size(); i++) { |
| 4947 |
einstellung->setArrayIndex(i); |
| 4948 |
einstellung->setValue("fd", extraOpenFileDialogBefore.at(i)); |
| 4949 |
} |
| 4950 |
einstellung->endArray(); |
| 4951 |
einstellung->endGroup(); |
| 4952 |
|
| 4953 |
einstellung->beginGroup("Extra"); |
| 4954 |
einstellung->beginWriteArray("IconOverlay",extraIconOverlay.size()); |
| 4955 |
for (int i = 0; i < extraIconOverlay.size(); i++) { |
| 4956 |
einstellung->setArrayIndex(i); |
| 4957 |
einstellung->setValue("icov", extraIconOverlay.at(i)); |
| 4958 |
} |
| 4959 |
einstellung->endArray(); |
| 4960 |
einstellung->endGroup(); |
| 4961 |
|
| 4962 |
einstellung->beginGroup("Extra"); |
| 4963 |
einstellung->beginWriteArray("OverlayPointSize",extraOverlayPointSize.size()); |
| 4964 |
for (int i = 0; i < extraOverlayPointSize.size(); i++) { |
| 4965 |
einstellung->setArrayIndex(i); |
| 4966 |
einstellung->setValue("icov", extraOverlayPointSize.at(i)); |
| 4967 |
} |
| 4968 |
einstellung->endArray(); |
| 4969 |
einstellung->endGroup(); |
| 4970 |
|
| 4971 |
einstellung->beginGroup("Extra"); |
| 4972 |
einstellung->beginWriteArray("AltExtraIconPaths",altExtraIconPaths.size()); |
| 4973 |
for (int i = 0; i < altExtraIconPaths.size(); i++) { |
| 4974 |
einstellung->setArrayIndex(i); |
| 4975 |
einstellung->setValue("altIcon", altExtraIconPaths.at(i)); |
| 4976 |
} |
| 4977 |
einstellung->endArray(); |
| 4978 |
einstellung->endGroup(); |
| 4979 |
|
| 4980 |
einstellung->beginGroup("Extra"); |
| 4981 |
einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); |
| 4982 |
for (int i = 0; i < extraDetach.size(); i++) { |
| 4983 |
einstellung->setArrayIndex(i); |
| 4984 |
einstellung->setValue("Detach", extraDetach.at(i)); |
| 4985 |
} |
| 4986 |
einstellung->endArray(); |
| 4987 |
einstellung->endGroup(); |
| 4988 |
extraMenu->clear(); |
| 4989 |
extraTB->clear(); |
| 4990 |
extraMenu->addAction("add/remove external program",this,SLOT(extraSettings())); |
| 4991 |
//QFileIconProvider *p = new QFileIconProvider(); |
| 4992 |
if (extraProgramNames.size()) extraMenu->addSeparator(); |
| 4993 |
for (int i=0; i<extraProgramNames.size(); i++){ |
| 4994 |
QAction *a; |
| 4995 |
QString icopa=extraProgramPaths.at(i); |
| 4996 |
QFileIconProvider *epic = new QFileIconProvider(); |
| 4997 |
QIcon ico = epic->icon(QFileInfo(icopa)); |
| 4998 |
//qDebug()<<ico.availableSizes()<<ico.actualSize(QSize(32,32)); |
| 4999 |
QPixmap fmap = ico.pixmap(32,32); |
| 5000 |
if (QFile::exists(altExtraIconPaths.at(i))) fmap=QIcon(altExtraIconPaths.at(i)).pixmap(64,64); |
| 5001 |
delete epic; |
| 5002 |
|
| 5003 |
if (extraIconOverlay.at(i)==Qt::Checked){ |
| 5004 |
QPainter *paint = new QPainter(&fmap); |
| 5005 |
paint->setPen(QPen(QColor("#FFFFFF"))); |
| 5006 |
QFont ifont=chgl->myFont; |
| 5007 |
ifont.setPixelSize(qMax(extraOverlayPointSize.at(i)*fmap.height()/64,2)); |
| 5008 |
paint->setFont(ifont); |
| 5009 |
paint->drawText(1,fmap.height()-5,extraProgramNames.at(i)); |
| 5010 |
paint->setPen(QPen(QColor("#000000"))); |
| 5011 |
paint->drawText(0,fmap.height()-4,extraProgramNames.at(i)); |
| 5012 |
paint->end(); |
| 5013 |
} |
| 5014 |
extraIcon=QIcon(fmap); |
| 5015 |
a=extraMenu->addAction(extraIcon,QString("run %1 !").arg(extraProgramNames.at(i)),this,SLOT(runExtra())); |
| 5016 |
a->setData(i); |
| 5017 |
extraTB->addAction(a); |
| 5018 |
} |
| 5019 |
pgms->removeItem(wegmuss); |
| 5020 |
pgms->insertItem(wegmuss,extraName->text().trimmed()); |
| 5021 |
pgms->setCurrentIndex(wegmuss); |
| 5022 |
} |
| 5023 |
} |
| 5024 |
|
| 5025 |
void Window::updateExtraSettings(){ |
| 5026 |
updateExtraSettings(0); |
| 5027 |
} |
| 5028 |
|
| 5029 |
void Window::updateExtraSettings(int index){ |
| 5030 |
if ((index<0)||(index>=extraProgramNames.size())) return; |
| 5031 |
extraName->setText(extraProgramNames.at(index)); |
| 5032 |
extraPath->setText(extraProgramPaths.at(index)); |
| 5033 |
altExtraIconPath=(index<altExtraIconPaths.size())?altExtraIconPaths.at(index):""; |
| 5034 |
extraArgumentsEdit->setText(extraOptions.at(index)); |
| 5035 |
extraAltExtEdit->setText(extraExt2.at(index)); |
| 5036 |
QFileIconProvider *epic = new QFileIconProvider(); |
| 5037 |
QString icopa=extraProgramPaths.at(index); |
| 5038 |
QIcon ico = epic->icon(QFileInfo(icopa)); |
| 5039 |
//qDebug()<<index<<ico.availableSizes()<<ico.actualSize(QSize(32,32)); |
| 5040 |
QPixmap fmap = ico.pixmap(32,32); |
| 5041 |
if (QFile::exists(altExtraIconPaths.at(index))) fmap=QIcon(altExtraIconPaths.at(index)).pixmap(64,64); |
| 5042 |
if (extraIconOverlay.at(index)==Qt::Checked){ |
| 5043 |
QPainter *paint = new QPainter(&fmap); |
| 5044 |
paint->setPen(QPen(QColor("#FFFFFF"))); |
| 5045 |
QFont ifont=chgl->myFont; |
| 5046 |
ifont.setPixelSize(qMax(iovlPointSize->value()*fmap.height()/64,2)); |
| 5047 |
paint->setFont(ifont); |
| 5048 |
paint->drawText(1,fmap.height()-5,extraProgramNames.at(index)); |
| 5049 |
paint->setPen(QPen(QColor("#000000"))); |
| 5050 |
paint->drawText(0,fmap.height()-4,extraProgramNames.at(index)); |
| 5051 |
paint->end(); |
| 5052 |
} |
| 5053 |
extraIcon=QIcon(fmap); |
| 5054 |
extraFakeButton->setIcon(extraIcon); |
| 5055 |
delete epic; |
| 5056 |
useArgument->setCheckState(extraArguments.at(index)); |
| 5057 |
absolutePath->setCheckState(extraAbsolutePath.at(index)); |
| 5058 |
omitExtension->setCheckState(extraExtensions.at(index)); |
| 5059 |
if (index<extraResIns.size()) copyResIns->setCheckState(extraResIns.at(index)); |
| 5060 |
if (index<extraOpenFileDialogBefore.size()) openFileDialogBefore->setCheckState(extraOpenFileDialogBefore.at(index)); |
| 5061 |
if (index<extraIconOverlay.size()) iconOverlay->setCheckState(extraIconOverlay.at(index)); |
| 5062 |
if (index<extraOverlayPointSize.size()) iovlPointSize->setValue(extraOverlayPointSize.at(index)); |
| 5063 |
detach->setCheckState(extraDetach.at(index)); |
| 5064 |
update(); |
| 5065 |
} |
| 5066 |
|
| 5067 |
void Window::updateExtraIcon(){ |
| 5068 |
QPixmap fmap; |
| 5069 |
if (altExtraIconPath.isEmpty()){ |
| 5070 |
QFileIconProvider *epic = new QFileIconProvider(); |
| 5071 |
QIcon ico = epic->icon(QFileInfo(extraPath->text())); |
| 5072 |
//qDebug()<<ico.availableSizes()<<ico.actualSize(QSize(32,32)); |
| 5073 |
fmap = ico.pixmap(32,32); |
| 5074 |
delete epic; |
| 5075 |
} |
| 5076 |
else{ |
| 5077 |
fmap = QIcon(altExtraIconPath).pixmap(64,64); |
| 5078 |
|
| 5079 |
} |
| 5080 |
if (iconOverlay->isChecked()){ |
| 5081 |
QPainter *paint = new QPainter(&fmap); |
| 5082 |
paint->setPen(QPen(QColor("#FFFFFF"))); |
| 5083 |
QFont ifont=chgl->myFont; |
| 5084 |
ifont.setPixelSize(qMax(iovlPointSize->value()*fmap.height()/64,2)); |
| 5085 |
paint->setFont(ifont); |
| 5086 |
paint->drawText(1, fmap.height()-5,extraName->text()); |
| 5087 |
paint->setPen(QPen(QColor("#000000"))); |
| 5088 |
paint->drawText(0, fmap.height()-4,extraName->text()); |
| 5089 |
paint->end(); |
| 5090 |
} |
| 5091 |
extraIcon=QIcon(fmap); |
| 5092 |
extraFakeButton->setIcon(extraIcon); |
| 5093 |
|
| 5094 |
} |
| 5095 |
|
| 5096 |
void Window::setExtraPath(){ |
| 5097 |
QString s = |
| 5098 |
QFileDialog::getOpenFileName(this, "Path to external program executable", extraPath->text(), QString(),nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 5099 |
if (!s.isEmpty()){ |
| 5100 |
extraPath->setText(s); |
| 5101 |
updateExtraIcon();; |
| 5102 |
} |
| 5103 |
} |
| 5104 |
|
| 5105 |
void Window::brwsIcon(){ |
| 5106 |
QString path=""; |
| 5107 |
#if defined (Q_WS_X11) |
| 5108 |
path="/usr/share/pixmaps/"; |
| 5109 |
#endif |
| 5110 |
QString *filter=NULL,s= |
| 5111 |
QFileDialog::getOpenFileName(this,QString("Select icon source"),//caption |
| 5112 |
path, "Icon files (*.xpm *.png *.ico *.svg);;",filter, (useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 5113 |
if (QFile::exists(s)) altExtraIconPath=s; |
| 5114 |
updateExtraIcon(); |
| 5115 |
} |
| 5116 |
|
| 5117 |
void Window::runExtra(){ |
| 5118 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 5119 |
int index=0; |
| 5120 |
if (action){ |
| 5121 |
index=action->data().toInt(); |
| 5122 |
} else { |
| 5123 |
return; |
| 5124 |
} |
| 5125 |
if ((index<0)||(index>=extraProgramNames.size())) return; |
| 5126 |
extraOutput->hide(); |
| 5127 |
delete extraOutput; |
| 5128 |
extraIndex = index; |
| 5129 |
extraOutput = new QDialog(this); |
| 5130 |
lt = new QVBoxLayout(); |
| 5131 |
extraOutPut = new QTextEdit(); |
| 5132 |
QFont mospfo(FONTFAM); |
| 5133 |
extraOutPut->setFont(mospfo); |
| 5134 |
#if (QT_VERSION >=0x050000) |
| 5135 |
extraOutput->setMinimumWidth( |
| 5136 |
QFontMetrics(extraOutPut->font()) |
| 5137 |
.horizontalAdvance("#########################################################################################################################################")); |
| 5138 |
#else |
| 5139 |
extraOutput->setMinimumWidth( |
| 5140 |
QFontMetrics(extraOutPut->font()) |
| 5141 |
.width("###########################################################################################")); |
| 5142 |
#endif |
| 5143 |
extraOutPut->setLineWrapMode(QTextEdit::NoWrap); |
| 5144 |
lt->addWidget(extraOutPut); |
| 5145 |
extraOutput->setLayout(lt); |
| 5146 |
extraOutput->setWindowTitle(QString("Running %1 ...").arg(extraProgramNames.at(index))); |
| 5147 |
extraOutPut->clear(); |
| 5148 |
QString path,name; |
| 5149 |
path=extraProgramPaths.at(index); |
| 5150 |
#if defined (Q_WS_MAC) |
| 5151 |
if ((QFileInfo(path).isDir())&&(path.endsWith(".app",Qt::CaseInsensitive))){ |
| 5152 |
path.append("/Contents/MacOS/"); |
| 5153 |
path.append(QDir(path).entryList(QDir::Executable|QDir::Files).first()); |
| 5154 |
} |
| 5155 |
#endif |
| 5156 |
QString dn=dirName.section('/',0,-2), |
| 5157 |
argument=dirName.section('/',-1); |
| 5158 |
if (extraOpenFileDialogBefore.at(index)==Qt::Checked){ |
| 5159 |
QString oMyDir= |
| 5160 |
QFileDialog::getOpenFileName(this,QString("Open a file for %1").arg(extraProgramNames.at(index)),//caption |
| 5161 |
dn,QString(),nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 5162 |
dn=oMyDir.section('/',0,-2); |
| 5163 |
argument=oMyDir.section('/',-1); |
| 5164 |
} |
| 5165 |
if (extraExtensions.at(index)==Qt::Checked) argument.remove(QRegularExpression(".res$|.ins$|.p4p$|.cif$",QRegularExpression::CaseInsensitiveOption)); |
| 5166 |
if (extraResIns.at(index)==Qt::Checked) { |
| 5167 |
//##@##bruce will es |
| 5168 |
// |
| 5169 |
//printf("bruce will es\n"); |
| 5170 |
if (maybeSave2()){ |
| 5171 |
QString dn=dirName.section('/',0,-2), |
| 5172 |
argument=dirName.section('/',-1); |
| 5173 |
argument.remove(resorins); |
| 5174 |
if (dirName.contains(punktres)){ |
| 5175 |
QString insname =dirName; |
| 5176 |
insname.replace(punktres,".ins"); |
| 5177 |
|
| 5178 |
QString fcfname = dirName; |
| 5179 |
fcfname.replace(punktres,".fcf"); |
| 5180 |
QString fcfname2 = dirName; |
| 5181 |
fcfname2.replace(punktres,".2fcf"); |
| 5182 |
if ((QFileInfo(dirName).lastModified()>=QFileInfo(insname).lastModified())){ |
| 5183 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5184 |
QStringList filter; |
| 5185 |
filter << QString("%1_*_.ins").arg(argument); |
| 5186 |
QStringList resfs; |
| 5187 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 5188 |
int vers=0; |
| 5189 |
if (resfs.isEmpty()) vers=1; |
| 5190 |
else { |
| 5191 |
bool ok=true; |
| 5192 |
for (int i = 0; i < resfs.size(); i++) |
| 5193 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 5194 |
vers++; |
| 5195 |
} |
| 5196 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5197 |
QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5198 |
QFile::remove(insname); |
| 5199 |
QFile::copy(dirName,insname); |
| 5200 |
|
| 5201 |
QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5202 |
QFile::remove(fcfname2); |
| 5203 |
QFile::copy(fcfname,fcfname2); |
| 5204 |
} |
| 5205 |
else { |
| 5206 |
int but=QMessageBox::information(0,"information", |
| 5207 |
QString("<h3>The <b>ins</b>truction file is newer than the <b>res</b>ult file you are working on!</h3> %1 %2 <br> %3 <br> %4<br>Maybe you edited it outside of this program.\ |
| 5208 |
<br> Now the your computer clock says: %5<br>%6 %7 (negative numbers here probably indicate asynchronous clocks on network file systems.)<br><hr><b> Click on 'Ignore' to copy your current .res to .ins file and refine.</b>") |
| 5209 |
.arg(insname) |
| 5210 |
.arg(dirName) |
| 5211 |
.arg(QFileInfo(insname).lastModified().toString(Qt::TextDate)) |
| 5212 |
.arg(QFileInfo(dirName).lastModified().toString(Qt::TextDate)) |
| 5213 |
.arg(QDateTime::currentDateTime().toString(Qt::TextDate)) |
| 5214 |
#if (QT_VERSION >= 0x040700) |
| 5215 |
.arg(QFileInfo(insname).lastModified().msecsTo(QDateTime::currentDateTime())) |
| 5216 |
.arg(QFileInfo(dirName).lastModified().msecsTo(QDateTime::currentDateTime())) |
| 5217 |
#else |
| 5218 |
.arg(QFileInfo(insname).lastModified().secsTo(QDateTime::currentDateTime())) |
| 5219 |
.arg(QFileInfo(dirName).lastModified().secsTo(QDateTime::currentDateTime())) |
| 5220 |
|
| 5221 |
#endif |
| 5222 |
,QMessageBox::Ignore|QMessageBox::Ok); |
| 5223 |
if (but==QMessageBox::Ignore){ |
| 5224 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5225 |
QStringList filter; |
| 5226 |
filter << QString("%1_*_.ins").arg(argument); |
| 5227 |
QStringList resfs; |
| 5228 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 5229 |
int vers=0; |
| 5230 |
if (resfs.isEmpty()) vers=1; |
| 5231 |
else { |
| 5232 |
bool ok=true; |
| 5233 |
for (int i = 0; i < resfs.size(); i++) |
| 5234 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 5235 |
vers++; |
| 5236 |
} |
| 5237 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5238 |
QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5239 |
QFile::remove(insname); |
| 5240 |
QFile::copy(dirName,insname); |
| 5241 |
|
| 5242 |
QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5243 |
QFile::remove(fcfname2); |
| 5244 |
QFile::copy(fcfname,fcfname2); |
| 5245 |
}else{ |
| 5246 |
shxOutputDock->hide(); |
| 5247 |
infotainmentDock->hide(); |
| 5248 |
refineButtonBox->hide(); |
| 5249 |
pro7->hide(); |
| 5250 |
refineButtonBox2->hide(); |
| 5251 |
stoppRefinement->hide(); |
| 5252 |
stoppRefinement2->hide(); |
| 5253 |
finishRefinement->hide(); |
| 5254 |
finishRefinement2->hide(); |
| 5255 |
shxEditorDock->show(); |
| 5256 |
dock->show(); |
| 5257 |
histDock->show(); |
| 5258 |
return; |
| 5259 |
} |
| 5260 |
} |
| 5261 |
}else{ |
| 5262 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5263 |
QStringList filter; |
| 5264 |
filter << QString("%1_*_.ins").arg(argument); |
| 5265 |
QStringList resfs; |
| 5266 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 5267 |
int vers=0; |
| 5268 |
if (resfs.isEmpty()) vers=1; |
| 5269 |
else { |
| 5270 |
bool ok=true; |
| 5271 |
for (int i = 0; i < resfs.size(); i++) |
| 5272 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 5273 |
vers++; |
| 5274 |
} |
| 5275 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5276 |
QFile::copy(dirName,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5277 |
|
| 5278 |
} |
| 5279 |
} |
| 5280 |
/// bruce will es |
| 5281 |
} |
| 5282 |
if ((extraExt2.size()>index)&&(!extraExt2.at(index).isEmpty())){ |
| 5283 |
argument.remove(resorins); |
| 5284 |
argument.append(extraExt2.at(index)); |
| 5285 |
} |
| 5286 |
extraProc = new QProcess(this); |
| 5287 |
QStringList al; |
| 5288 |
if ((extraOptions.size()>index)&&(!extraOptions.at(index).isEmpty())) al.append(extraOptions.at(index)); |
| 5289 |
if (extraArguments.at(index)==Qt::Checked){ |
| 5290 |
if (extraAbsolutePath.at(index)==Qt::Checked) al.append(dirName); else al.append(argument); |
| 5291 |
} |
| 5292 |
extraProc->setWorkingDirectory(dn); // updateXLput() |
| 5293 |
connect(extraProc,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateExtraOutput())); |
| 5294 |
connect(extraProc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateExtraOutput())); |
| 5295 |
connect(extraProc,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateExtraOutput())); |
| 5296 |
#if (QT_VERSION >= 0x040600) |
| 5297 |
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); |
| 5298 |
extraProc->setProcessEnvironment(env);//Thanks to Dr. Pavlo Solntsev!! |
| 5299 |
#else |
| 5300 |
QStringList env = QProcess::systemEnvironment(); |
| 5301 |
extraProc->setEnvironment(env); |
| 5302 |
#endif |
| 5303 |
QString dummyargument=al.join(" "); |
| 5304 |
al=dummyargument.split(" "); |
| 5305 |
if (extraDetach.at(index)) { |
| 5306 |
|
| 5307 |
#if (QT_VERSION >= 0x050700) |
| 5308 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 5309 |
extraProc->setProgram(path); |
| 5310 |
extraProc->setArguments(al); |
| 5311 |
extraProc->setWorkingDirectory(dn); |
| 5312 |
extraProc->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) {args->flags &= ~CREATE_NO_WINDOW;}); |
| 5313 |
extraProc->startDetached(); |
| 5314 |
/* |
| 5315 |
//https://bugreports.qt.io/browse/QTBUG-57687?focusedCommentId=354550&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-354550 |
| 5316 |
QProcess p; |
| 5317 |
p.setProgram("cmd.exe"); |
| 5318 |
p.setArguments({"/k", "echo", "Hello from Qt!"}); |
| 5319 |
p.setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) { |
| 5320 |
args->flags &= ~CREATE_NO_WINDOW; |
| 5321 |
}); |
| 5322 |
p.startDetached(); |
| 5323 |
*/ |
| 5324 |
#else |
| 5325 |
extraProc->startDetached(path,al,dn); |
| 5326 |
#endif |
| 5327 |
#else |
| 5328 |
extraProc->startDetached(path,al,dn); |
| 5329 |
#endif |
| 5330 |
|
| 5331 |
} |
| 5332 |
else { |
| 5333 |
extraProc->start(path,al); |
| 5334 |
extraOutPut->setText(QString("|--- Running %1 %2 in %3 ---|\n").arg(path).arg(al.join(" ")).arg(dn)); |
| 5335 |
extraOutput->show(); |
| 5336 |
} |
| 5337 |
} |
| 5338 |
|
| 5339 |
void Window::updateExtraOutput(){ |
| 5340 |
#if (QT_VERSION >= 0x050300) |
| 5341 |
if (extraProc->processId()) { |
| 5342 |
#else |
| 5343 |
if (extraProc->pid()) { |
| 5344 |
#endif |
| 5345 |
extraOutPut->setReadOnly(false); |
| 5346 |
QString s=extraOutPut->toPlainText(); |
| 5347 |
s.append(extraProc->readAllStandardOutput()); |
| 5348 |
s.append(extraProc->readAllStandardError()); |
| 5349 |
extraOutPut->setPlainText(s); |
| 5350 |
extraOutPut->moveCursor(QTextCursor::End); |
| 5351 |
extraOutPut->ensureCursorVisible (); |
| 5352 |
extraOutPut->setReadOnly(true); |
| 5353 |
extraProc->write("\n"); // this is sent to fake a 'pause' waiting for any key so that the script continues |
| 5354 |
}else{ |
| 5355 |
extraOutPut->setReadOnly(false); |
| 5356 |
QString s=extraOutPut->toPlainText(); |
| 5357 |
s.append(extraProc->readAllStandardOutput()); |
| 5358 |
s.append(extraProc->readAllStandardError()); |
| 5359 |
if (s.isEmpty()) { |
| 5360 |
s.append("|---Program is not running!---|\n"); |
| 5361 |
extraIndex = -1; |
| 5362 |
} |
| 5363 |
else{ |
| 5364 |
if ((s.endsWith(" ---|\n"))&&(extraIndex>-1)){ |
| 5365 |
einstellung->beginGroup("Extra"); |
| 5366 |
einstellung->beginWriteArray("ProgramDetached",extraDetach.size()); |
| 5367 |
einstellung->setArrayIndex(extraIndex); |
| 5368 |
einstellung->setValue("Detach", Qt::Checked); |
| 5369 |
extraDetach[extraIndex] = Qt::Checked; |
| 5370 |
einstellung->endArray(); |
| 5371 |
einstellung->endGroup(); |
| 5372 |
printf("There was no output. I will start this program detached in future. I hope that is Ok.\n"); |
| 5373 |
|
| 5374 |
} |
| 5375 |
if ((extraIndex == -21)&&(QFile::exists(pngName))){ |
| 5376 |
//here should be a png output file of povray be loaded |
| 5377 |
QLabel *preview = new QLabel(""); |
| 5378 |
int eh = extraOutput->height(), ew = extraOutput->width(); |
| 5379 |
preview->setPixmap(QPixmap(pngName)); |
| 5380 |
if (qsaPNG==nullptr) qsaPNG = new QScrollArea(extraOutput); |
| 5381 |
qsaPNG->setWidget(preview); |
| 5382 |
lt->addWidget(qsaPNG); |
| 5383 |
QString s=extraOutPut->toPlainText(); |
| 5384 |
s.append("\n|---Program is finished.---|\n"); |
| 5385 |
extraOutput->resize(ew,2*eh); |
| 5386 |
}else{ |
| 5387 |
s.append("\n|---Program is finished.---|\n"); |
| 5388 |
QString dn=dirName.section('/',0,-2), argument=dirName.section('/',-1); |
| 5389 |
argument.remove(QRegularExpression(".res$|.ins$|.cif$",QRegularExpression::CaseInsensitiveOption)); |
| 5390 |
QDir work=QDir(QString("%1/").arg(dn)); |
| 5391 |
QStringList filter; |
| 5392 |
filter << QString("%1*.res").arg(argument)<< QString("%1*.ins").arg(argument);; |
| 5393 |
QStringList resfs; |
| 5394 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 5395 |
|
| 5396 |
QList<QToolButton *> oldbuts = extraOutput->findChildren<QToolButton *>("resloadbutton"); |
| 5397 |
//printf("old buttons %d\n",oldbuts.size()); |
| 5398 |
for (int i=oldbuts.size()-1; i>=0; i--) { |
| 5399 |
oldbuts[i]->setVisible(false); |
| 5400 |
oldbuts[i]->deleteLater(); |
| 5401 |
} |
| 5402 |
QHBoxLayout *hbl=new QHBoxLayout(); |
| 5403 |
QToolButton *tbb0=new QToolButton(); |
| 5404 |
QAction *ac0=new QAction(QString("cancel"),this); |
| 5405 |
connect(ac0,SIGNAL(triggered()),extraOutput,SLOT(reject())); |
| 5406 |
tbb0->setDefaultAction(ac0); |
| 5407 |
tbb0->setObjectName("resloadbutton"); |
| 5408 |
for (int i=0; i<resfs.size(); i++){ |
| 5409 |
QAction *ac=new QAction(QString("load %1").arg(resfs.at(i)),this); |
| 5410 |
ac->setData(QString("%1/%2").arg(dn).arg(resfs.at(i))); |
| 5411 |
|
| 5412 |
connect(ac,SIGNAL(triggered()),this,SLOT(loadThisFile())); |
| 5413 |
QToolButton *tbb=new QToolButton(); |
| 5414 |
tbb->setDefaultAction(ac); |
| 5415 |
tbb->setObjectName("resloadbutton"); |
| 5416 |
hbl->addWidget(tbb); |
| 5417 |
} |
| 5418 |
hbl->addWidget(tbb0); |
| 5419 |
lt->addLayout(hbl); |
| 5420 |
}//-21 |
| 5421 |
extraIndex = -1; |
| 5422 |
} |
| 5423 |
extraOutPut->setPlainText(s); |
| 5424 |
extraOutPut->moveCursor(QTextCursor::End); |
| 5425 |
extraOutPut->ensureCursorVisible (); |
| 5426 |
extraOutPut->setReadOnly(true); |
| 5427 |
} |
| 5428 |
} |
| 5429 |
|
| 5430 |
void Window::loadThisFile(){ |
| 5431 |
extraOutput->hide(); |
| 5432 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 5433 |
QString name=""; |
| 5434 |
if (action) |
| 5435 |
name=action->data().toString(); |
| 5436 |
else return; |
| 5437 |
if (name.isEmpty()) return; |
| 5438 |
|
| 5439 |
|
| 5440 |
loadFile(name); |
| 5441 |
} |
| 5442 |
|
| 5443 |
void Window::configureBottomToolbar(){ |
| 5444 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 5445 |
int index=0; |
| 5446 |
if (action) |
| 5447 |
index=action->data().toInt(); |
| 5448 |
else return; |
| 5449 |
if ((index>=0)&&(index<5)) bottomToolBar->setToolButtonStyle((Qt::ToolButtonStyle) index); |
| 5450 |
if (index>32) { |
| 5451 |
index-=32; |
| 5452 |
addToolBarBreak(); |
| 5453 |
addToolBar((Qt::ToolBarArea) index,bottomToolBar); |
| 5454 |
} |
| 5455 |
einstellung->beginGroup("ToolBar"); |
| 5456 |
einstellung->setValue("SelectionToolBarStyle",bottomToolBar->toolButtonStyle()); |
| 5457 |
einstellung->endGroup(); |
| 5458 |
|
| 5459 |
} |
| 5460 |
|
| 5461 |
void Window::grossRC(const QString &text){ |
| 5462 |
QString s=text.toUpper (); |
| 5463 |
resiResiClass->setText(s); |
| 5464 |
update(); |
| 5465 |
} |
| 5466 |
|
| 5467 |
void Window::defineBarray() { |
| 5468 |
//! This method adjusts the value for the B array in SHELXL according to the number of atoms. |
| 5469 |
//! The calculation is not rocket science, but should work in every case. |
| 5470 |
int barray; |
| 5471 |
if (useMyBArray) { |
| 5472 |
return; // the user wants to have his own value; |
| 5473 |
} |
| 5474 |
barray = mole.asymm.size() * 9; // Can fail with very large molecules. |
| 5475 |
if (barray > 3000) { // B array == 3000 is defult |
| 5476 |
shelxlArgs = shelxlArgs.simplified(); |
| 5477 |
if (!shelxlArgs.contains("-b")) { |
| 5478 |
shelxlArgs += QString(" -b%1").arg(barray); |
| 5479 |
} else { |
| 5480 |
shelxlArgs.replace(QRegularExpression("\\s{0,2}\\-b\\s{0,1}\\d{0,8}"), QString(" -b%1").arg(barray)); |
| 5481 |
} |
| 5482 |
} |
| 5483 |
} |
| 5484 |
|
| 5485 |
void Window::runShelXL(){ |
| 5486 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 5487 |
if (action){ |
| 5488 |
if (action->data().toInt()==1) {editor->insertAnis(); if (!fileSave(true,false)) return;} |
| 5489 |
if (action->data().toInt()==2) {editor->insertActa(); if (!fileSave(true,false)) return;} |
| 5490 |
if (action->data().toInt()==3) {editor->insertEXTI(); if (!fileSave(true,false)) return;} |
| 5491 |
if (action->data().toInt()==4) {editor->insertCONF(); if (!fileSave(true,false)) return;} |
| 5492 |
} |
| 5493 |
if (maybeSave2()){ |
| 5494 |
if (mole.qbeforehkl) deleteAllQ(); |
| 5495 |
// printf("runXL line %d",__LINE__); |
| 5496 |
editor->insertList6(); |
| 5497 |
xlPutor->clear(); |
| 5498 |
|
| 5499 |
xlPutor->ListFile=false; |
| 5500 |
//xlPutor->highlighter->loadHighlightPatterns(lstpatternfile); |
| 5501 |
shxOutputDock->show(); |
| 5502 |
stoppRefinement->show(); |
| 5503 |
finishRefinement->show(); |
| 5504 |
finishRefinement->setFocus(); |
| 5505 |
QObject::disconnect(stoppRefinement, 0, this, 0); |
| 5506 |
if (infotainmentDock->isVisible())finishRefinement2->setFocus(); |
| 5507 |
stoppRefinement2->show(); |
| 5508 |
finishRefinement2->show(); |
| 5509 |
QObject::disconnect(stoppRefinement2, 0, this, 0); |
| 5510 |
refineButtonBox->hide(); |
| 5511 |
pro7->hide(); |
| 5512 |
loadRes->show(); |
| 5513 |
refineButtonBox2->hide(); |
| 5514 |
loadRes2->show(); |
| 5515 |
shxEditorDock->hide(); |
| 5516 |
dock->hide(); |
| 5517 |
histDock->hide(); |
| 5518 |
renamDock->hide(); |
| 5519 |
QString dn=dirName.section('/',0,-2), |
| 5520 |
argument=dirName.section('/',-1); |
| 5521 |
argument.remove(resorins); |
| 5522 |
if (dirName.contains(punktres)){ |
| 5523 |
QString insname =dirName; |
| 5524 |
insname.replace(punktres,".ins"); |
| 5525 |
|
| 5526 |
QString fcfname = dirName; |
| 5527 |
fcfname.replace(punktres,".fcf"); |
| 5528 |
QString fcfname2 = dirName; |
| 5529 |
fcfname2.replace(punktres,".2fcf"); |
| 5530 |
// qDebug()<<QFileInfo(insname).lastModified().toString(Qt::TextDate)<<QFileInfo(dirName).lastModified().toString(Qt::TextDate)<<(QFileInfo(dirName).lastModified()>=QFileInfo(insname).lastModified()); |
| 5531 |
if (//(0)&& |
| 5532 |
(QFileInfo(dirName).lastModified()>=QFileInfo(insname).lastModified())){ |
| 5533 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5534 |
QStringList filter; |
| 5535 |
filter << QString("%1_*_.ins").arg(argument); |
| 5536 |
QStringList resfs; |
| 5537 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 5538 |
int vers=0; |
| 5539 |
if (resfs.isEmpty()) vers=1; |
| 5540 |
else { |
| 5541 |
bool ok=true; |
| 5542 |
for (int i = 0; i < resfs.size(); i++) |
| 5543 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 5544 |
vers++; |
| 5545 |
} |
| 5546 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5547 |
QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5548 |
QFile::remove(insname); |
| 5549 |
QFile::copy(dirName,insname); |
| 5550 |
|
| 5551 |
QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5552 |
QFile::remove(fcfname2); |
| 5553 |
QFile::copy(fcfname,fcfname2); |
| 5554 |
} |
| 5555 |
else { |
| 5556 |
int but=QMessageBox::information(0,"information", |
| 5557 |
QString("<h3>The <b>ins</b>truction file is newer than the <b>res</b>ult file you are working on!</h3> %1 %2 <br> %3 <br> %4<br>Maybe you edited it outside of this program.\ |
| 5558 |
<br> Now the your computer clock says: %5<br>%6 %7 (negative numbers here probably indicate asynchronous clocks on network file systems.)<br><hr><b> Click on 'Ignore' to copy your current .res to .ins file and refine.</b>") |
| 5559 |
.arg(insname) |
| 5560 |
.arg(dirName) |
| 5561 |
.arg(QFileInfo(insname).lastModified().toString(Qt::TextDate)) |
| 5562 |
.arg(QFileInfo(dirName).lastModified().toString(Qt::TextDate)) |
| 5563 |
.arg(QDateTime::currentDateTime().toString(Qt::TextDate)) |
| 5564 |
#if (QT_VERSION >= 0x040700) |
| 5565 |
.arg(QFileInfo(insname).lastModified().msecsTo(QDateTime::currentDateTime())) |
| 5566 |
.arg(QFileInfo(dirName).lastModified().msecsTo(QDateTime::currentDateTime())) |
| 5567 |
#else |
| 5568 |
.arg(QFileInfo(insname).lastModified().secsTo(QDateTime::currentDateTime())) |
| 5569 |
.arg(QFileInfo(dirName).lastModified().secsTo(QDateTime::currentDateTime())) |
| 5570 |
|
| 5571 |
#endif |
| 5572 |
,QMessageBox::Ignore|QMessageBox::Ok); |
| 5573 |
if (but==QMessageBox::Ignore){ |
| 5574 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5575 |
QStringList filter; |
| 5576 |
filter << QString("%1_*_.ins").arg(argument); |
| 5577 |
QStringList resfs; |
| 5578 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 5579 |
int vers=0; |
| 5580 |
if (resfs.isEmpty()) vers=1; |
| 5581 |
else { |
| 5582 |
bool ok=true; |
| 5583 |
for (int i = 0; i < resfs.size(); i++) |
| 5584 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 5585 |
vers++; |
| 5586 |
} |
| 5587 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5588 |
QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5589 |
QFile::remove(insname); |
| 5590 |
QFile::copy(dirName,insname); |
| 5591 |
|
| 5592 |
QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5593 |
QFile::remove(fcfname2); |
| 5594 |
QFile::copy(fcfname,fcfname2); |
| 5595 |
}else{ |
| 5596 |
shxOutputDock->hide(); |
| 5597 |
infotainmentDock->hide(); |
| 5598 |
refineButtonBox->hide(); |
| 5599 |
pro7->hide(); |
| 5600 |
refineButtonBox2->hide(); |
| 5601 |
finishRefinement->hide(); |
| 5602 |
finishRefinement2->hide(); |
| 5603 |
stoppRefinement->hide(); |
| 5604 |
stoppRefinement2->hide(); |
| 5605 |
shxEditorDock->show(); |
| 5606 |
dock->show(); |
| 5607 |
histDock->show(); |
| 5608 |
return; |
| 5609 |
} |
| 5610 |
} |
| 5611 |
}else{ |
| 5612 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5613 |
QStringList filter; |
| 5614 |
filter << QString("%1_*_.ins").arg(argument); |
| 5615 |
QStringList resfs; |
| 5616 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 5617 |
int vers=0; |
| 5618 |
if (resfs.isEmpty()) vers=1; |
| 5619 |
else { |
| 5620 |
bool ok=true; |
| 5621 |
for (int i = 0; i < resfs.size(); i++) |
| 5622 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 5623 |
vers++; |
| 5624 |
} |
| 5625 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 5626 |
QFile::copy(dirName,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 5627 |
|
| 5628 |
} |
| 5629 |
//printf("runXL!123\n"); |
| 5630 |
|
| 5631 |
shxOutputDock->setWindowTitle(QString("SHELXL OUTPUT: %1").arg(argument)); |
| 5632 |
shxOutputDock->show(); |
| 5633 |
shxOutputDock->raise(); |
| 5634 |
shelxl = new QProcess(this); |
| 5635 |
|
| 5636 |
QStringList al; |
| 5637 |
al.append(argument); |
| 5638 |
|
| 5639 |
defineBarray(); |
| 5640 |
finishRefinement->setFocus(); |
| 5641 |
vis_settings->beginGroup("infotaiment"); |
| 5642 |
bool lastvis = vis_settings->value("info_as_default").toBool(); |
| 5643 |
vis_settings->endGroup(); |
| 5644 |
if (lastvis) { |
| 5645 |
raiseTaff(); |
| 5646 |
finishRefinement2->setFocus(); |
| 5647 |
} |
| 5648 |
al+=shelxlArgs.split(' ',skipEmptyParts); |
| 5649 |
shelxl->setWorkingDirectory(dn); // updateXLput() |
| 5650 |
if (focusSet) connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),loadRes ,SLOT(setFocus())); |
| 5651 |
if ((lastvis)&&(focusSet)) connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),loadRes2 ,SLOT(setFocus())); |
| 5652 |
|
| 5653 |
#if (QT_VERSION >= 0x060400) |
| 5654 |
connect(shelxl,&QProcess::readyReadStandardOutput,this,&Window::updateXLput); |
| 5655 |
connect(shelxl,&QProcess::finished, refineButtonBox, &QGroupBox::show); |
| 5656 |
connect(shelxl,&QProcess::finished, refineButtonBox2, &QGroupBox::show); |
| 5657 |
connect(shelxl,&QProcess::finished, stoppRefinement, &QPushButton::hide); |
| 5658 |
connect(shelxl,&QProcess::finished, finishRefinement, &QPushButton::hide); |
| 5659 |
connect(shelxl,&QProcess::finished, finishRefinement2, &QPushButton::hide); |
| 5660 |
connect(shelxl,&QProcess::finished, stoppRefinement2, &QPushButton::hide); |
| 5661 |
connect(shelxl,&QProcess::finished, this, &Window::updateXLput); |
| 5662 |
connect(shelxl,&QProcess::finished, this, &Window::displayDisagreeableRestraints); |
| 5663 |
connect(shelxl,&QProcess::errorOccurred,this,&Window::updateXLput); |
| 5664 |
#else |
| 5665 |
connect(shelxl,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateXLput())); |
| 5666 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),refineButtonBox ,SLOT(show())); |
| 5667 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),refineButtonBox2 ,SLOT(show())); |
| 5668 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),stoppRefinement ,SLOT(hide())); |
| 5669 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),finishRefinement ,SLOT(hide())); |
| 5670 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),finishRefinement2 ,SLOT(hide())); |
| 5671 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),stoppRefinement2 ,SLOT(hide())); |
| 5672 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateXLput())); |
| 5673 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(displayDisagreeableRestraints())); |
| 5674 |
connect(shelxl,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateXLput())); |
| 5675 |
//printf("QT??? %X\n",QT_VERSION); |
| 5676 |
#endif |
| 5677 |
|
| 5678 |
connect(finishRefinement,SIGNAL(clicked()),this,SLOT(finXL())); |
| 5679 |
connect(finishRefinement2,SIGNAL(clicked()),this,SLOT(finXL())); |
| 5680 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 5681 |
connect(stoppRefinement,SIGNAL(clicked()),shelxl,SLOT(kill())); |
| 5682 |
connect(stoppRefinement2,SIGNAL(clicked()),shelxl,SLOT(kill())); |
| 5683 |
#else |
| 5684 |
connect(stoppRefinement,SIGNAL(clicked()),shelxl,SLOT(terminate())); |
| 5685 |
connect(stoppRefinement2,SIGNAL(clicked()),shelxl,SLOT(terminate())); |
| 5686 |
#endif |
| 5687 |
connect(stoppRefinement,SIGNAL(clicked()),loadRes,SLOT(hide())); |
| 5688 |
connect(stoppRefinement2,SIGNAL(clicked()),loadRes2,SLOT(hide())); |
| 5689 |
shelxl->start(shelxlPath,al); |
| 5690 |
//printf("runXL!123 123\n"); |
| 5691 |
pro7->show(); |
| 5692 |
} |
| 5693 |
} |
| 5694 |
|
| 5695 |
void Window::displayResiduals(XLOutputParser &lfo, QString s) { |
| 5696 |
//! Draws the residuals of the refinement as a table |
| 5697 |
//qDebug()<<s; |
| 5698 |
RGraph lsdata; |
| 5699 |
lsdata.cycle = 0; |
| 5700 |
restr_table->clear(); |
| 5701 |
foreach (QString line, s.split(QRegularExpression("\n|\r\n|\r"))) { |
| 5702 |
resid_label->setText(lfo.residualsTextDisplay(line, ls_cycls)); |
| 5703 |
} |
| 5704 |
} |
| 5705 |
|
| 5706 |
void Window::displayDisagreeableRestraints() { |
| 5707 |
//! Displays the list of disagreeable restraints in the restr_table widget |
| 5708 |
//! This has to be started ofter SHELXL is finished! (via signal) |
| 5709 |
QFileInfo lfi(dirName); |
| 5710 |
QString restrtext = "There is no SHELXL list file available for this structure. Please refine to get output here."; |
| 5711 |
QString lfpath; |
| 5712 |
lfpath = lfi.absoluteFilePath().replace(".res", ".lst"); |
| 5713 |
if (QFile(lfpath).exists()) { |
| 5714 |
ListFileHandler lf(lfpath); |
| 5715 |
restrtext = lf.restraintsTable(); |
| 5716 |
} |
| 5717 |
restr_table->setText(restrtext); |
| 5718 |
} |
| 5719 |
|
| 5720 |
void Window::updateXLput(){ |
| 5721 |
XLOutputParser xlo; |
| 5722 |
QString warn = "** NO running Process maybe the 'shelxl' is not in PATH or is spelled differently **\n\n" |
| 5723 |
"** Please give a correct path to an existing executable of shelxl. **\n\n" |
| 5724 |
"** Check SHELXL -> 'Specify SHELXL runtime options' **"; |
| 5725 |
if (infotainmentDock->isVisible())finishRefinement2->setFocus(); else finishRefinement->setFocus(); |
| 5726 |
#if (QT_VERSION >= 0x050300) |
| 5727 |
if (shelxl->processId()&&shelxl->isOpen()) { |
| 5728 |
#else |
| 5729 |
if (shelxl->pid()&&shelxl->isOpen()) { |
| 5730 |
#endif |
| 5731 |
// printf("updateXLput()\n"); |
| 5732 |
xlPutor->setReadOnly(false); |
| 5733 |
QString s=xlPutor->toPlainText(); |
| 5734 |
s.append(shelxl->readAllStandardOutput()); |
| 5735 |
s.append(shelxl->readAllStandardError()); |
| 5736 |
//qDebug()<<__LINE__<<s; |
| 5737 |
displayResiduals(xlo, s); |
| 5738 |
if (shelxl->state()==QProcess::NotRunning) { |
| 5739 |
s.append(warn); |
| 5740 |
resid_label->append("<b>" + warn.replace("\n", "<br>") + "</b>"); |
| 5741 |
refineButtonBox->show(); |
| 5742 |
stoppRefinement->hide(); |
| 5743 |
finishRefinement->hide(); |
| 5744 |
finishRefinement2->hide(); |
| 5745 |
refineButtonBox2->show(); |
| 5746 |
stoppRefinement2->hide(); |
| 5747 |
} |
| 5748 |
xlPutor->setPlainText(s); |
| 5749 |
falschAtom=-1; |
| 5750 |
xlPutor->setReadOnly(true); |
| 5751 |
loadRes->setEnabled((s.contains("for all data"))); |
| 5752 |
loadRes2->setEnabled((s.contains("for all data"))); |
| 5753 |
if ((focusSet)&&(!s.contains("for all data"))) withdraw->setFocus(); |
| 5754 |
if (s.contains(" ** ")) { |
| 5755 |
QString Fehl=s.section("**",1,1).simplified(); |
| 5756 |
Fehl=Fehl.remove("UNSUITABLE AFIX HYDROGENS FOLLOW "); |
| 5757 |
Fehl=Fehl.remove("BAD Ueq DEPENDENCE FOR "); |
| 5758 |
Fehl=Fehl.remove("BAD AFIX FOR "); |
| 5759 |
Fehl=Fehl.remove("BAD AFIX CONNECTIVITY: "); |
| 5760 |
Fehl=Fehl.remove("NO PIVOT ATOM FOR RIGID GROUP CONTAINING "); |
| 5761 |
Fehl=Fehl.simplified(); |
| 5762 |
Fehl=Fehl.section(' ',0,0); |
| 5763 |
if ((Fehl.size()<5)||Fehl.contains('_')){ |
| 5764 |
chgl->mol->selectedatoms.clear(); |
| 5765 |
for (int i=0; i<chgl->mol->showatoms.size(); i++){ |
| 5766 |
if (!Fehl.compare(chgl->mol->showatoms.at(i).Label,Qt::CaseInsensitive)){ |
| 5767 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[i]); |
| 5768 |
chgl->mol->selectedatoms.last().style=i; |
| 5769 |
} |
| 5770 |
} |
| 5771 |
if (!chgl->mol->selectedatoms.isEmpty()) { |
| 5772 |
chgl->centerSelection->setChecked(true); |
| 5773 |
chgl->updateBondActions(); |
| 5774 |
chgl->update(); |
| 5775 |
update(); |
| 5776 |
chgl->update(); |
| 5777 |
falschAtom=chgl->mol->selectedatoms.last().style; |
| 5778 |
jumpToAtom(chgl->mol->selectedatoms.last().style); |
| 5779 |
|
| 5780 |
} |
| 5781 |
} |
| 5782 |
} |
| 5783 |
}else{ |
| 5784 |
xlPutor->setReadOnly(false); |
| 5785 |
QString s=xlPutor->toPlainText(); |
| 5786 |
if (shelxl->isOpen()) { |
| 5787 |
s.append(shelxl->readAllStandardOutput()); |
| 5788 |
s.append(shelxl->readAllStandardError()); |
| 5789 |
} |
| 5790 |
//qDebug()<<__LINE__<<s; |
| 5791 |
if (s.isEmpty()){ |
| 5792 |
s.append(warn); |
| 5793 |
resid_label->append("<b>" + warn.replace("\n", "<br>") + "</b>"); |
| 5794 |
} |
| 5795 |
xlPutor->setPlainText(s); |
| 5796 |
xlPutor->setReadOnly(true); |
| 5797 |
if (!s.contains("WGHT")){ |
| 5798 |
loadRes->setEnabled((s.contains("for all data"))); |
| 5799 |
loadRes2->setEnabled((s.contains("for all data"))); |
| 5800 |
refineButtonBox->show(); |
| 5801 |
stoppRefinement->hide(); |
| 5802 |
finishRefinement->hide(); |
| 5803 |
finishRefinement2->hide(); |
| 5804 |
refineButtonBox2->show(); |
| 5805 |
stoppRefinement2->hide(); |
| 5806 |
} |
| 5807 |
if (!s.contains("Total elapsed")) { |
| 5808 |
// SHELXL executed but didn't finish: |
| 5809 |
resid_label->append("<b>SHELXL was terminated!</b>"); |
| 5810 |
} |
| 5811 |
} |
| 5812 |
|
| 5813 |
QTextCursor tc = xlPutor->textCursor(); |
| 5814 |
tc.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); |
| 5815 |
xlPutor->setTextCursor(tc); |
| 5816 |
xlPutor->ensureCursorVisible(); |
| 5817 |
update(); |
| 5818 |
if (infotainmentDock->isVisible())finishRefinement2->setFocus(); else finishRefinement->setFocus(); |
| 5819 |
} |
| 5820 |
|
| 5821 |
void Window::loadrefres(){ |
| 5822 |
dirName.replace(punktins,".res"); |
| 5823 |
shxOutputDock->hide(); |
| 5824 |
infotainmentDock->hide(); |
| 5825 |
|
| 5826 |
refineButtonBox->hide(); |
| 5827 |
refineButtonBox2->hide(); |
| 5828 |
shxEditorDock->show(); |
| 5829 |
shxEditorDock->raise(); |
| 5830 |
|
| 5831 |
loadFile(dirName); |
| 5832 |
} |
| 5833 |
|
| 5834 |
void Window::replyFinished(QNetworkReply* antwort){ |
| 5835 |
QSettings *einstellung =new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME,mole.mynewnameis ); |
| 5836 |
int ignore=0; |
| 5837 |
einstellung->beginGroup("Updates"); |
| 5838 |
if (einstellung->contains("IgnoreUpdates")) |
| 5839 |
ignore=einstellung->value("IgnoreUpdates").toInt(); |
| 5840 |
einstellung->endGroup(); |
| 5841 |
QString a=antwort->readAll(); |
| 5842 |
latestRev=a; |
| 5843 |
bool ok; |
| 5844 |
int lat=a.toInt(&ok,10); |
| 5845 |
if (ok&&lat&&(0==(ignore&QMessageBox::No))){ |
| 5846 |
if ((lat-7)>Revision) { |
| 5847 |
int later= |
| 5848 |
QMessageBox::information( |
| 5849 |
0,"information",QString( |
| 5850 |
"<h3>This is revision: <font color=#aa66cc>%1" |
| 5851 |
"</font><br> The latest available version is revision: <font color=#aa66cc> %2</font> " |
| 5852 |
"New versions can be downloaded here: " |
| 5853 |
"<a href=\"http://shelxle.org/shelx/index.php\">" |
| 5854 |
"http://shelxle.org/shelx/index.php</a></h3>" |
| 5855 |
"<h4>Please contact the author" |
| 5856 |
" <a href=\"mailto:[email protected]\">[email protected]</a> if you find any bugs.<br> Thank you!</h4>" |
| 5857 |
"<h3>Do you want to be reminded later?</h3>").arg(Revision).arg(lat) |
| 5858 |
,QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); |
| 5859 |
|
| 5860 |
einstellung->beginGroup("Updates"); |
| 5861 |
einstellung->setValue("IgnoreUpdates",later); |
| 5862 |
einstellung->endGroup(); |
| 5863 |
} |
| 5864 |
}else{ |
| 5865 |
latestRev="<font color=red> network unavailable, check failed.</font>"; |
| 5866 |
} |
| 5867 |
antwort->close(); |
| 5868 |
antwort->deleteLater(); |
| 5869 |
disconnect(net,SIGNAL(finished(QNetworkReply*)),0,0); |
| 5870 |
delete einstellung; |
| 5871 |
} |
| 5872 |
|
| 5873 |
void Window::checkForUpdates(){ |
| 5874 |
//disconnect(net,SIGNAL(finished(QNetworkReply*)),0,0); |
| 5875 |
connect(net, SIGNAL(finished(QNetworkReply*)), this, SLOT(isUpToDate(QNetworkReply*))); |
| 5876 |
reply = net->get(QNetworkRequest(QUrl("http://shelxle.org/shelx/revision.php"))); |
| 5877 |
} |
| 5878 |
|
| 5879 |
void Window::isUpToDate(QNetworkReply* antwort){ |
| 5880 |
QSettings *einstellung =new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME,mole.mynewnameis); |
| 5881 |
//int ignore=0; |
| 5882 |
einstellung->beginGroup("Updates"); |
| 5883 |
if (einstellung->contains("IgnoreUpdates")) |
| 5884 |
// ignore= |
| 5885 |
einstellung->value("IgnoreUpdates").toInt(); |
| 5886 |
einstellung->endGroup(); |
| 5887 |
QString a=antwort->readAll(); |
| 5888 |
latestRev=a; |
| 5889 |
bool ok; |
| 5890 |
int lat=a.toInt(&ok,10); |
| 5891 |
if (ok&&lat){ |
| 5892 |
int later= |
| 5893 |
QMessageBox::information( |
| 5894 |
0,"information",QString( |
| 5895 |
"<h3>This is revision: <font color=#aa66cc>%1" |
| 5896 |
"</font><br> The latest available version is revision: <font color=#aa66cc> %2</font> " |
| 5897 |
"<h3>%3</h3>" |
| 5898 |
"New versions can be downloaded here: " |
| 5899 |
"<a href=\"http://shelxle.org/shelx/index.php\">" |
| 5900 |
"http://shelxle.org/shelx/index.php</a></h3>" |
| 5901 |
"<h4>Please contact the author" |
| 5902 |
" <a href=\"mailto:[email protected]\">[email protected]</a> if you find any bugs.<br> Thank you!</h4>" |
| 5903 |
"<h3>Do you want to be reminded for new versions at startup?</h3>").arg(Revision).arg(lat).arg(((lat-3)>Revision)?"You should probably update ShelXle.":"Your ShelXle is rather up to date.") |
| 5904 |
,QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes); |
| 5905 |
|
| 5906 |
einstellung->beginGroup("Updates"); |
| 5907 |
einstellung->setValue("IgnoreUpdates",later); |
| 5908 |
einstellung->endGroup(); |
| 5909 |
}else{ |
| 5910 |
latestRev="<font color=red> network unavailable, check failed.</font>"; |
| 5911 |
QMessageBox::information( 0,"information",latestRev); |
| 5912 |
} |
| 5913 |
antwort->close(); |
| 5914 |
antwort->deleteLater(); |
| 5915 |
|
| 5916 |
disconnect(net,SIGNAL(finished(QNetworkReply*)),0,0); |
| 5917 |
|
| 5918 |
} |
| 5919 |
|
| 5920 |
void Window::changeLabelFont(){ |
| 5921 |
bool ok; |
| 5922 |
QFont font = QFontDialog::getFont(&ok, chgl->myFont, this,"Change Label Font"); |
| 5923 |
if (ok) { |
| 5924 |
//font.setStyleStrategy(QFont::OpenGLCompatible); |
| 5925 |
chgl->myFont=font; |
| 5926 |
einstellung->beginGroup("Fonts"); |
| 5927 |
einstellung->setValue("LabelFont",chgl->myFont); |
| 5928 |
einstellung->setValue("LabelFontSize", chgl->myFont.pointSize()); |
| 5929 |
einstellung->endGroup(); |
| 5930 |
//chgl->updateLabelTextures(); |
| 5931 |
chgl->update(); |
| 5932 |
} |
| 5933 |
} |
| 5934 |
|
| 5935 |
void Window::changeEditorFont(){ |
| 5936 |
bool ok; |
| 5937 |
QFont font = QFontDialog::getFont(&ok, editor->font(), this,"Change Editor Font"); |
| 5938 |
if (ok) { |
| 5939 |
font.setFixedPitch(true); |
| 5940 |
einstellung->beginGroup("Fonts"); |
| 5941 |
einstellung->setValue("EditorFont",font); |
| 5942 |
einstellung->setValue("EditorFontSize",font.pointSize()); |
| 5943 |
einstellung->endGroup(); |
| 5944 |
editor->setFont(font); |
| 5945 |
xlPutor->setFont(font); |
| 5946 |
} |
| 5947 |
} |
| 5948 |
|
| 5949 |
void Window::withdrawres(){ |
| 5950 |
if (dirName.contains(punktres)){ |
| 5951 |
QString insname =dirName; |
| 5952 |
insname.replace(punktres,".ins"); |
| 5953 |
QString fcfname = dirName; |
| 5954 |
fcfname.replace(punktres,".fcf"); |
| 5955 |
QString fcfname2 = dirName; |
| 5956 |
fcfname2.replace(punktres,".2fcf"); |
| 5957 |
QFile::remove(dirName); |
| 5958 |
QFile::copy(insname,dirName); |
| 5959 |
QFile::remove(fcfname); |
| 5960 |
QFile::copy(fcfname2,fcfname); |
| 5961 |
editor->document()->setModified(false); |
| 5962 |
loadFile(dirName); |
| 5963 |
} |
| 5964 |
shxOutputDock->hide(); |
| 5965 |
infotainmentDock->hide(); |
| 5966 |
refineButtonBox->hide(); |
| 5967 |
shxEditorDock->show(); |
| 5968 |
if (falschAtom!=-1){ |
| 5969 |
// qDebug()<<"tata"<<falschAtom; |
| 5970 |
chgl->mol->selectedatoms.clear(); |
| 5971 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[falschAtom]); |
| 5972 |
chgl->mol->selectedatoms.last().style=falschAtom; |
| 5973 |
chgl->centerSelection->setChecked(true); |
| 5974 |
chgl->updateBondActions(); |
| 5975 |
chgl->update(); |
| 5976 |
update(); |
| 5977 |
chgl->update(); |
| 5978 |
jumpToAtom(falschAtom); |
| 5979 |
|
| 5980 |
} |
| 5981 |
} |
| 5982 |
|
| 5983 |
void Window::loadLst(){ |
| 5984 |
xlPutor->clear(); |
| 5985 |
pro7->hide(); |
| 5986 |
QString listName=dirName; |
| 5987 |
listName.replace(punktins,".lst"); |
| 5988 |
listName.replace(punktres,".lst"); |
| 5989 |
QFile lstf(listName); |
| 5990 |
int wl=0; |
| 5991 |
//xlPutor->highlighter->setDocument(0); |
| 5992 |
if (lstf.open(QIODevice::ReadOnly|QIODevice::Text)){ |
| 5993 |
QElapsedTimer stech; |
| 5994 |
stech.start(); |
| 5995 |
xlPutor->setReadOnly(false); |
| 5996 |
xlPutor->ListFile=true; |
| 5997 |
//xlPutor->highlighter->setDocument(0); |
| 5998 |
// xlPutor->highlighter->setOutputStyle(); |
| 5999 |
shxOutputDock->setWindowTitle(QString("LIST FILE: %1").arg(listName.section('/', -1))); |
| 6000 |
// shxOutputDock->setWhatsThis("<h1>.lst file viewer</h1> The .lst file contains useful information about the refinement of your structure."); |
| 6001 |
printf("1 %d ms\n", stech.elapsed()); |
| 6002 |
QString testS=QString(lstf.readAll().replace('\0','~')); |
| 6003 |
printf("2 %d ms\n", stech.elapsed()); |
| 6004 |
xlPutor->setPlainText(testS); |
| 6005 |
printf("3 %d ms\n", stech.elapsed()); |
| 6006 |
wl=testS.count("\n"); |
| 6007 |
lstf.close(); |
| 6008 |
shxOutputDock->show(); |
| 6009 |
shxOutputDock->lower(); |
| 6010 |
einstellung->beginGroup("Cursor"); |
| 6011 |
if (einstellung->contains("ListFilePos")){ |
| 6012 |
xlPutor->setReadOnly(false); |
| 6013 |
int mipo= qMin(wl,einstellung->value("ListFilePos",0).toInt()); |
| 6014 |
// printf("mipo %d\n",mipo); |
| 6015 |
QTextCursor c=xlPutor->textCursor(); |
| 6016 |
// qDebug()<<c.isNull(); |
| 6017 |
c.movePosition(QTextCursor::Start); |
| 6018 |
c.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor,mipo); |
| 6019 |
if (!c.isNull()) xlPutor->setTextCursor(c); |
| 6020 |
xlPutor->centerCursor(); |
| 6021 |
xlPutor->setReadOnly(true); |
| 6022 |
printf("%s read and ready after %d ms\n",listName.toStdString().c_str(),stech.elapsed()); |
| 6023 |
} |
| 6024 |
einstellung->endGroup(); |
| 6025 |
xlPutor->setReadOnly(true); |
| 6026 |
// shxOutputDock->raise(); |
| 6027 |
}else { |
| 6028 |
shxOutputDock->lower(); |
| 6029 |
shxOutputDock->hide(); |
| 6030 |
} |
| 6031 |
|
| 6032 |
update(); |
| 6033 |
} |
| 6034 |
|
| 6035 |
void Window::loadFile(QString fileName, bool fromloadref){ |
| 6036 |
//! Loads the shelxfile, sets the last cursor position in editor, saves "last file" entry in config, |
| 6037 |
//! checks if file is valid in terms of UNIT, HKLF and END instructions, loads list file, runs the editor. |
| 6038 |
mole.vtriangles.clear(); |
| 6039 |
mole.vorobas=0; |
| 6040 |
//chgl->setLabelSize(24); |
| 6041 |
QDir directory(fileName); |
| 6042 |
QString dn=directory.canonicalPath(); |
| 6043 |
if ((editor->toPlainText().length()>79)){//(dn!=dirName)&& |
| 6044 |
QTextCursor c=editor->textCursor(); |
| 6045 |
if (!c.isNull()){ |
| 6046 |
myHash[dirName]=c.position(); |
| 6047 |
einstellung->beginGroup("Cursor"); |
| 6048 |
einstellung->setValue("lastCursorHash", myHash ); |
| 6049 |
einstellung->setValue("ListFilePos",xlPutor->midCursorpos); |
| 6050 |
einstellung->endGroup(); |
| 6051 |
} |
| 6052 |
} |
| 6053 |
dirName=dn; |
| 6054 |
if (dn!=lastDirName){// do this only is we have a different file name |
| 6055 |
hklf5files.clear(); |
| 6056 |
//QTime rzeit; |
| 6057 |
//rzeit.start(); |
| 6058 |
switch2HKLF5->setVisible(doWeHaveHKLF5here(hklf5files)); |
| 6059 |
//printf("doWeHaveHKLF5here() took %d ms.\n", rzeit.elapsed()); // rzeit.restart(); |
| 6060 |
} |
| 6061 |
switch2HKLF4->setVisible(false); |
| 6062 |
einstellung->beginGroup("Files"); |
| 6063 |
einstellung->setValue("lastFile", dirName ); |
| 6064 |
einstellung->endGroup(); |
| 6065 |
fileName = dirName; |
| 6066 |
lastDirName = dirName; |
| 6067 |
if (fileName.isEmpty()) return; |
| 6068 |
bool gut=false; |
| 6069 |
QFile test; |
| 6070 |
// alltest will contain the shelxfile that is displayed: |
| 6071 |
QString alltest; |
| 6072 |
test.setFileName(fileName); |
| 6073 |
if (test.exists()&&test.size()){ |
| 6074 |
test.open(QIODevice::ReadOnly|QIODevice::Text); |
| 6075 |
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 |
| 6076 |
|
| 6077 |
gut = ((alltest.contains("UNIT",Qt::CaseInsensitive))&&(alltest.contains("HKLF",Qt::CaseInsensitive)||alltest.contains("END",Qt::CaseInsensitive))); |
| 6078 |
test.close(); |
| 6079 |
} |
| 6080 |
if (!gut){ |
| 6081 |
fileName.replace(QRegularExpression("res$",QRegularExpression::CaseInsensitiveOption),"ins"); |
| 6082 |
test.setFileName(fileName); |
| 6083 |
if (test.exists()&&test.size()){ |
| 6084 |
test.open(QIODevice::ReadOnly|QIODevice::Text); |
| 6085 |
alltest=test.readAll(); |
| 6086 |
gut = ((alltest.contains("UNIT",Qt::CaseInsensitive))&&(alltest.contains("HKLF",Qt::CaseInsensitive)||alltest.contains("END",Qt::CaseInsensitive))); |
| 6087 |
test.close(); |
| 6088 |
if (gut ) dirName=fileName; |
| 6089 |
} |
| 6090 |
} |
| 6091 |
if (!gut) { |
| 6092 |
QMessageBox::information(this, "information", QString("Can't open %1").arg(fileName)); |
| 6093 |
test.open(QIODevice::ReadOnly|QIODevice::Text); |
| 6094 |
alltest=test.readAll(); |
| 6095 |
test.close(); |
| 6096 |
return; |
| 6097 |
} |
| 6098 |
|
| 6099 |
packMenu->setEnabled(true); |
| 6100 |
|
| 6101 |
int qtmajor=(QT_VERSION&0xff0000)>>16; |
| 6102 |
if ((Revision%666)==0) { |
| 6103 |
setWindowTitle(QString("%1 - A Qt GUI for sHELLxl (Rev: %2): %3[*] ") |
| 6104 |
.arg(PROGRAM_NAME) |
| 6105 |
.arg(Revision) |
| 6106 |
.arg(fileName.section("/",-1))); |
| 6107 |
} else { |
| 6108 |
setWindowTitle(QString("%1 - A Qt GUI for SHELXL (Rev: %2)(%4bit)(Qt%5): %3[*] ") |
| 6109 |
.arg(PROGRAM_NAME) |
| 6110 |
.arg(Revision) |
| 6111 |
.arg(fileName.section("/",-1)) |
| 6112 |
.arg(BitWidth) |
| 6113 |
.arg(qtmajor) |
| 6114 |
); |
| 6115 |
} |
| 6116 |
notRefine = alltest.contains("DISABLE_REFINE");// this has to be here to work correctly |
| 6117 |
if (alltest.contains("OVERRIDEF000")) { |
| 6118 |
double str = alltest.section("OVERRIDEF000",1,-1).section('\n',0,0).simplified().toDouble(); |
| 6119 |
fxle->overridef000=(float)str; |
| 6120 |
//qDebug()<<str<<"hier"<<alltest.section("OVERRIDEF000",1,-1).section('\n',0,0).simplified(); |
| 6121 |
} |
| 6122 |
runMenu->setDisabled(notRefine); |
| 6123 |
packMenu->setDisabled(notRefine); |
| 6124 |
refineToolBar->setDisabled(notRefine); |
| 6125 |
refineToolBar->setVisible(!notRefine); |
| 6126 |
alltest.replace(QRegularExpression("=\\s*[\\r\\n]+\\s{1,}"),"="); |
| 6127 |
alltest.replace(QRegularExpression("REM[^\\n]*\n"),"\n"); |
| 6128 |
alltest.replace(QRegularExpression("![^\\n]*\n"),"\n"); |
| 6129 |
while (alltest.contains(QRegularExpression("[\\n^]\\++[^\\n]*\n"))) { |
| 6130 |
QString incl=alltest.section(QRegularExpression("[\\n^]\\++"),1,1,QString::SectionSkipEmpty); |
| 6131 |
incl=incl.section('\n',0,0); |
| 6132 |
QString pre=dirName.section('/',0,-2); |
| 6133 |
// qDebug()<<pre+"/"+incl<<QFileInfo(pre+"/"+incl).exists()<<dirName; |
| 6134 |
if (QFileInfo(pre+"/"+incl).exists()) { |
| 6135 |
QFile include(pre+"/"+incl); |
| 6136 |
QString inst; |
| 6137 |
if (include.open(QIODevice::ReadOnly|QIODevice::Text)) inst=include.readAll(); |
| 6138 |
alltest.replace("++" + incl, inst); |
| 6139 |
alltest.replace("+" + incl, inst); |
| 6140 |
} else { |
| 6141 |
alltest.remove("++" + incl); |
| 6142 |
alltest.remove("+" + incl); |
| 6143 |
} |
| 6144 |
} |
| 6145 |
loadLst(); |
| 6146 |
//printf("after loadLst()\n"); |
| 6147 |
load_sheldrick(fileName, alltest); |
| 6148 |
//printf("after load_sheldrick()\n"); |
| 6149 |
shx_editor(fileName); |
| 6150 |
//printf("after shx_editor()\n"); |
| 6151 |
if (!fileName.contains("helXlesaves")){//do not remember files loaded from a saves folder ... lets see if this is a good idea :-P |
| 6152 |
einstellung->beginGroup("Files"); |
| 6153 |
einstellung->setValue("lastFile", fileName ); |
| 6154 |
QStringList files = einstellung->value("recentFileList").toStringList(); |
| 6155 |
files.removeAll(fileName); //alle identischen "fileName" aus der Liste entfernen |
| 6156 |
files.prepend(fileName); // und dann vorne anfuegen... |
| 6157 |
while (files.size() > MaxRecentFiles) { |
| 6158 |
files.removeLast() ;//hinten abschneiden was laenger als MaxRecentFiles ist |
| 6159 |
} |
| 6160 |
einstellung->setValue("recentFileList", files); |
| 6161 |
foreach (QWidget *widget, QApplication::topLevelWidgets()) { |
| 6162 |
Window *mainWin = qobject_cast<Window *>(widget); |
| 6163 |
if (mainWin) |
| 6164 |
mainWin->updateRecentFileActions(); |
| 6165 |
} |
| 6166 |
einstellung->endGroup(); |
| 6167 |
} |
| 6168 |
hw->setPath(fileName, dock->width()); |
| 6169 |
if (hw->gooddata.size()) histDock->show(); |
| 6170 |
//chgl->updateLabelTextures(); |
| 6171 |
emit fileLoaded(); |
| 6172 |
if ((chgl->toggleOrthoView->isChecked())&&(chgl->viewAngle>3.0)) { |
| 6173 |
toggleOrtho(true); |
| 6174 |
chgl->update(); |
| 6175 |
// qDebug()<<chgl->viewAngle; |
| 6176 |
} |
| 6177 |
chgl->update(); |
| 6178 |
|
| 6179 |
loadMolInTest(fromloadref); |
| 6180 |
printf("loadFile\n"); |
| 6181 |
} |
| 6182 |
|
| 6183 |
void Window::openRecentFile() { |
| 6184 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 6185 |
if (action) |
| 6186 |
loadFile(action->data().toString()); |
| 6187 |
} |
| 6188 |
|
| 6189 |
void Window::setMaxWGHTCycls(){ |
| 6190 |
bool ok; |
| 6191 |
int i = QInputDialog::getInt(this, |
| 6192 |
"limit", |
| 6193 |
"number of maximum cycles in WGHT refinement" , |
| 6194 |
wght_max_cycls, -1, 100000, 1, &ok); |
| 6195 |
if (ok){ |
| 6196 |
wght_max_cycls = i; |
| 6197 |
wghtRefineAct->setText(QString("Try to refine until WGHT converges (max %1 runs)").arg(wght_max_cycls)); |
| 6198 |
} |
| 6199 |
|
| 6200 |
} |
| 6201 |
|
| 6202 |
void Window::setSDMLimit(){ |
| 6203 |
bool ok; |
| 6204 |
int i = QInputDialog::getInt(this,"limit", |
| 6205 |
"number of atoms in asymmetric unit to skip automatic distance calculation on loading" , chgl->SDM_Limit, 100, 10000, 1, &ok); |
| 6206 |
if (ok) |
| 6207 |
chgl->SDM_Limit=i; |
| 6208 |
|
| 6209 |
} |
| 6210 |
|
| 6211 |
void Window::closeEvent(QCloseEvent *event) { |
| 6212 |
//printf("Close Event\n"); |
| 6213 |
chgl->clearEnvi(); |
| 6214 |
//printf("Close Event survived clearEnvi\n"); |
| 6215 |
if (isFullScreen ())showNormal(); |
| 6216 |
if (maybeSave()){ |
| 6217 |
einstellung->beginGroup("Window"); |
| 6218 |
einstellung->setValue("geometry", saveGeometry()); |
| 6219 |
einstellung->setValue("state", saveState()); |
| 6220 |
/* |
| 6221 |
int kinder=0; |
| 6222 |
const QObjectList smwk = shxMW->children(); |
| 6223 |
for (int chi=0; chi<smwk.size(); chi++){ |
| 6224 |
kinder+=smwk.at(chi)->children().size(); |
| 6225 |
} |
| 6226 |
printf("editor dock has %d children\n",kinder); |
| 6227 |
*/ |
| 6228 |
einstellung->setValue("EditorState",shxMW->saveState()); |
| 6229 |
einstellung->setValue("InvertMouseZoom",(chgl->invertMouseZoom->isChecked())); |
| 6230 |
einstellung->setValue("SDM-LIMIT", chgl->SDM_Limit); |
| 6231 |
einstellung->setValue("Calculate-Maps",fxle->doMaps->isChecked()); |
| 6232 |
einstellung->setValue("KeepMapIsoValues",fxle->keepIso->isChecked()); |
| 6233 |
einstellung->setValue("Fo-Map",chgl->foact->isChecked()); |
| 6234 |
einstellung->setValue("Fc-Fo-Map",chgl->fofcact->isChecked()); |
| 6235 |
einstellung->setValue("Map-truncation-type",fxle->mapSchnitt->currentIndex()); |
| 6236 |
einstellung->setValue("Map-Line-Transparency",chgl->lintrans); |
| 6237 |
einstellung->setValue("Map-Line-Width", chgl->linwidth); |
| 6238 |
einstellung->setValue("Map-Resolution",fxle->rr); |
| 6239 |
einstellung->setValue("Map-Weight",fxle->rw); |
| 6240 |
einstellung->setValue("Map-Lighting",chgl->lighting->isChecked()); |
| 6241 |
einstellung->setValue("Nice-Transparency",chgl->niceTrans->isChecked()); |
| 6242 |
einstellung->setValue("Solid-Map",chgl->fillMap->isChecked()); |
| 6243 |
einstellung->setValue("HighlightEquivalents",mole.highlightEquivalents); |
| 6244 |
einstellung->setValue("ADPs",chgl->adp->isChecked()); |
| 6245 |
einstellung->setValue("Tubes",chgl->tubes->isChecked()); |
| 6246 |
einstellung->setValue("Legend",chgl->atomLegend->isChecked()); |
| 6247 |
einstellung->setValue("ShowLabels",togLabel->isChecked()); |
| 6248 |
einstellung->setValue("ShortLabels",chgl->shortLabels->isChecked()); |
| 6249 |
einstellung->setValue("BackGroundGradient",togBackGr->isChecked()); |
| 6250 |
einstellung->setValue("SHELXL-PATH",shelxlPath); |
| 6251 |
einstellung->setValue("LevelOfDetail",mole.LOD); |
| 6252 |
//einstellung->setValue("Use_GLSL_Shaders",mole.useShaders); |
| 6253 |
//einstellung->setValue("WireModelOnRotate",chgl->wireButt->isChecked()); |
| 6254 |
einstellung->endGroup(); |
| 6255 |
einstellung->beginGroup("Colors"); |
| 6256 |
einstellung->setValue("LabelColor",chgl->labelColor); |
| 6257 |
einstellung->setValue("BackGroundColor",chgl->backGroundColor); |
| 6258 |
einstellung->endGroup(); |
| 6259 |
einstellung->beginGroup("Files"); |
| 6260 |
einstellung->setValue("lastFile", dirName ); |
| 6261 |
einstellung->endGroup(); |
| 6262 |
einstellung->beginGroup("Fonts"); |
| 6263 |
printf("Storing Font to Settings %s %d\n", editor->font().family().toStdString().c_str(), editor->font().pointSize()); |
| 6264 |
einstellung->setValue("EditorFont", editor->font()); |
| 6265 |
einstellung->setValue("EditorFontSize", editor->font().pointSize()); |
| 6266 |
einstellung->setValue("LabelFont",chgl->myFont); |
| 6267 |
einstellung->setValue("LabelFontSize", chgl->myFont.pointSize()); |
| 6268 |
einstellung->endGroup(); |
| 6269 |
einstellung->beginGroup("ToolBarIcons"); |
| 6270 |
einstellung->setValue("ToolBarIconSize",tbiconSize); |
| 6271 |
einstellung->endGroup(); |
| 6272 |
QTextCursor c=editor->textCursor(); |
| 6273 |
if (!c.isNull()){ |
| 6274 |
myHash[dirName]=c.position(); |
| 6275 |
einstellung->beginGroup("Cursor"); |
| 6276 |
einstellung->setValue("lastCursorHash", myHash ); |
| 6277 |
einstellung->endGroup(); |
| 6278 |
} |
| 6279 |
//printf("Close Event survived Einstellungen.\n"); |
| 6280 |
delete einstellung; |
| 6281 |
//printf("deleting\n"); |
| 6282 |
// printf("%d\n",__LINE__); |
| 6283 |
editor->clear(); |
| 6284 |
mole.asymm.clear(); |
| 6285 |
// printf("%d\n",__LINE__); |
| 6286 |
mole.sdm.clear(); |
| 6287 |
// printf("%d\n",__LINE__); |
| 6288 |
mole.showatoms.clear(); |
| 6289 |
// printf("%d\n",__LINE__); |
| 6290 |
mole.showbonds.clear(); |
| 6291 |
// printf("%d\n",__LINE__); |
| 6292 |
mole.cell.symmops.clear(); |
| 6293 |
// printf("%d\n",__LINE__); |
| 6294 |
mole.cell.trans.clear(); |
| 6295 |
// printf("%d\n",__LINE__); |
| 6296 |
mole.selectedatoms.clear(); |
| 6297 |
// printf("%d\n",__LINE__); |
| 6298 |
editor->sfac.clear(); |
| 6299 |
editor->sfacsmbl.clear(); |
| 6300 |
// printf("%d\n",__LINE__); |
| 6301 |
fvar.clear(); |
| 6302 |
// printf("%d\n",__LINE__); |
| 6303 |
fvarCntr.clear(); |
| 6304 |
// printf("%d\n",__LINE__); |
| 6305 |
mole.transEQIV.clear(); |
| 6306 |
// printf("%d\n",__LINE__); |
| 6307 |
mole.symmopsEQIV.clear(); |
| 6308 |
// printf("%d\n",__LINE__); |
| 6309 |
mole.labelEQIV.clear(); |
| 6310 |
// printf("%d\n",__LINE__); |
| 6311 |
mole.freeatoms.clear(); |
| 6312 |
// printf("%d\n",__LINE__); |
| 6313 |
mole.bindatoms.clear(); |
| 6314 |
// printf("%d\n",__LINE__); |
| 6315 |
// disconnect(this); |
| 6316 |
// printf("%d\n",__LINE__); |
| 6317 |
// disconnect(editor); |
| 6318 |
// printf("%d %p\n", __LINE__, chgl); |
| 6319 |
// disconnect(chgl); |
| 6320 |
|
| 6321 |
// printf("%d\n",__LINE__); |
| 6322 |
mole.asymm.clear(); |
| 6323 |
// printf("%d\n",__LINE__); |
| 6324 |
mole.sdm.clear(); |
| 6325 |
// printf("%d\n",__LINE__); |
| 6326 |
mole.showbonds.clear(); |
| 6327 |
// printf("%d\n",__LINE__); |
| 6328 |
mole.showatoms.clear(); |
| 6329 |
// printf("%d\n",__LINE__); |
| 6330 |
mole.selectedatoms.clear(); |
| 6331 |
// printf("%d\n",__LINE__); |
| 6332 |
|
| 6333 |
mole.envi_sdm.clear(); |
| 6334 |
// printf("%d\n",__LINE__); |
| 6335 |
mole.contact.clear(); |
| 6336 |
// printf("%d\n",__LINE__); |
| 6337 |
mole.symmopsEQIV.clear(); |
| 6338 |
// printf("%d\n",__LINE__); |
| 6339 |
mole.labelEQIV.clear(); |
| 6340 |
// printf("%d\n",__LINE__); |
| 6341 |
mole.transEQIV.clear(); |
| 6342 |
// printf("%d\n",__LINE__); |
| 6343 |
mole.freeatoms.clear(); |
| 6344 |
// printf("%d\n",__LINE__); |
| 6345 |
mole.bindatoms.clear(); |
| 6346 |
// printf("%d\n",__LINE__); |
| 6347 |
for (int i=0; i<mole.knoepfe.size();i++) mole.knoepfe[i].neighbors.clear(); |
| 6348 |
mole.knoepfe.clear(); |
| 6349 |
// printf("%d\n",__LINE__); |
| 6350 |
mole.cell.symmops.clear(); |
| 6351 |
// printf("%d\n",__LINE__); |
| 6352 |
mole.cell.trans.clear(); |
| 6353 |
// printf("%d\n",__LINE__); |
| 6354 |
// printf("Close Event survived!! Good bye! Ade! Ciao!\n"); |
| 6355 |
event->accept(); |
| 6356 |
} |
| 6357 |
else{ |
| 6358 |
event->ignore(); |
| 6359 |
// printf("Close Event survived and Ignored\n"); |
| 6360 |
} |
| 6361 |
} |
| 6362 |
|
| 6363 |
void Window::changeScalefactor(){ |
| 6364 |
widthBox->disconnect(); |
| 6365 |
heightBox->disconnect(); |
| 6366 |
scalefBox->disconnect(); |
| 6367 |
widthBox->setValue(int(chgl->width()*scalePic+0.5)); |
| 6368 |
heightBox->setValue(int(chgl->height()*scalePic+0.5)); |
| 6369 |
scalefBox->setValue(scalePic*100.0); |
| 6370 |
connect(widthBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); |
| 6371 |
connect(heightBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); |
| 6372 |
connect(scalefBox,SIGNAL(valueChanged(double)),this,SLOT(updateScaleDlg())); |
| 6373 |
scalDlg->exec(); |
| 6374 |
} |
| 6375 |
|
| 6376 |
void Window::updateScaleDlg(){ |
| 6377 |
QObject *o = qobject_cast<QObject *>(sender()); |
| 6378 |
if (o) { |
| 6379 |
QString name = o->objectName(); |
| 6380 |
widthBox->disconnect(); |
| 6381 |
heightBox->disconnect(); |
| 6382 |
scalefBox->disconnect(); |
| 6383 |
if (name=="scalefBox"){ |
| 6384 |
scalePic=scalefBox->value()*0.01; |
| 6385 |
widthBox->setValue(int(chgl->width()*scalePic+0.5)); |
| 6386 |
heightBox->setValue(int(chgl->height()*scalePic+0.5)); |
| 6387 |
} else if (name=="widthBox"){ |
| 6388 |
scalePic= (double (widthBox->value() -0.5) / chgl->width()) ; |
| 6389 |
heightBox->setValue(int(chgl->height()*scalePic+0.5)); |
| 6390 |
scalefBox->setValue(scalePic*100.0); |
| 6391 |
} else if (name=="heightBox"){ |
| 6392 |
scalePic= (double (heightBox->value() -0.5) / chgl->height()) ; |
| 6393 |
widthBox->setValue(int(chgl->width()*scalePic+0.5)); |
| 6394 |
scalefBox->setValue(scalePic*100.0); |
| 6395 |
} |
| 6396 |
scalDlg->update(); |
| 6397 |
|
| 6398 |
connect(widthBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); |
| 6399 |
connect(heightBox,SIGNAL(valueChanged(int)),this,SLOT(updateScaleDlg())); |
| 6400 |
connect(scalefBox,SIGNAL(valueChanged(double)),this,SLOT(updateScaleDlg())); |
| 6401 |
} |
| 6402 |
} |
| 6403 |
|
| 6404 |
void Window::updateSelectResi(){ |
| 6405 |
QStringList l = editor->document()->toPlainText().split('\n'); |
| 6406 |
if (editor->resiFinder == NULL) return; |
| 6407 |
editor->resiFinder->clear(); |
| 6408 |
editor->resiFinder->addItem("<Select residues>",-1); |
| 6409 |
for (int i=0; i<l.size();i++){ |
| 6410 |
if ((l.at(i).startsWith("RESI",Qt::CaseInsensitive))&&(!l.at(i).contains(QRegularExpression(" 0\\b")))) |
| 6411 |
editor->resiFinder->addItem(l.at(i).trimmed(),i); |
| 6412 |
// if (l.at(i).startsWith("MOLE",Qt::CaseInsensitive)) |
| 6413 |
// resiFinder->addItem(l.at(i).trimmed(),i); |
| 6414 |
} |
| 6415 |
int mi=1,ma=-1; |
| 6416 |
for (int i=0;i<editor->parenthesis2.size();i++){ |
| 6417 |
mi=qMin(editor->parenthesis2.at(i),mi); |
| 6418 |
ma=qMax(editor->parenthesis2.at(i),ma); |
| 6419 |
} |
| 6420 |
spinSelectPart->setMinimum(mi); |
| 6421 |
spinSelectPart->setMaximum(ma); |
| 6422 |
} |
| 6423 |
|
| 6424 |
void Window::selectParts(){ |
| 6425 |
int pt=spinSelectPart->value(); |
| 6426 |
bool b=inculdePartNull->isChecked(); |
| 6427 |
chgl->mol->selectedatoms.clear(); |
| 6428 |
int hidden=0; |
| 6429 |
if (selectPart->isChecked()){ |
| 6430 |
for (int i=0; i<chgl->mol->showatoms.size();i++){ |
| 6431 |
hidden+=chgl->mol->showatoms.at(i).hidden; |
| 6432 |
if (chgl->mol->showatoms.at(i).part==pt){ |
| 6433 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[i]); |
| 6434 |
chgl->mol->selectedatoms.last().style=i; |
| 6435 |
} |
| 6436 |
if ((pt!=0)&&(chgl->mol->showatoms.at(i).part==0)&&b){ |
| 6437 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[i]); |
| 6438 |
chgl->mol->selectedatoms.last().style=i; |
| 6439 |
} |
| 6440 |
} |
| 6441 |
} |
| 6442 |
if (hidden) chgl->hideNonSelected(); |
| 6443 |
chgl->updateBondActions(); |
| 6444 |
chgl->update(); |
| 6445 |
update(); |
| 6446 |
chgl->update(); |
| 6447 |
} |
| 6448 |
|
| 6449 |
void Window::resiSelectorCheck(){ |
| 6450 |
QTextCursor tc = editor->textCursor(); |
| 6451 |
int l,c=0,rnr=-1; |
| 6452 |
l=tc.blockNumber(); |
| 6453 |
while ((c<editor->resiFinder->count())&&(l>=(rnr=editor->resiFinder->itemData(c).toInt()))) {c++;} |
| 6454 |
if (c) editor->resiFinder->setCurrentIndex(c-1); |
| 6455 |
update(); |
| 6456 |
} |
| 6457 |
|
| 6458 |
void Window::fuse(){ |
| 6459 |
printf("f\n"); |
| 6460 |
chgl->disSelection(); |
| 6461 |
chgl->mol->fuse(); |
| 6462 |
infoKanalNews(chgl->mol->HumanSymmetry); |
| 6463 |
|
| 6464 |
chgl->setMolecule(&mole); |
| 6465 |
chgl->fuse->setVisible(false); |
| 6466 |
chgl->grow->setVisible(true); |
| 6467 |
loadMolInTest(); |
| 6468 |
|
| 6469 |
chgl->update(); |
| 6470 |
update(); |
| 6471 |
chgl->update(); |
| 6472 |
} |
| 6473 |
|
| 6474 |
void Window::uniq(){ |
| 6475 |
if (mole.asymm.isEmpty()) return; |
| 6476 |
|
| 6477 |
chgl->disSelection(); |
| 6478 |
if ((mole.maxmols()==0)||(quickReLoadButton->isChecked())) sdm(); |
| 6479 |
chgl->mol->uniqueInCell(); |
| 6480 |
infoKanalNews(chgl->mol->HumanSymmetry); |
| 6481 |
QTextDocument *document = editor->document(); |
| 6482 |
QTextCursor cursor = editor->textCursor(); |
| 6483 |
cursor.beginEditBlock (); |
| 6484 |
|
| 6485 |
for (int i=0; i<mole.asymm.size();i++){ |
| 6486 |
cursor.movePosition(QTextCursor::Start); |
| 6487 |
QString label=mole.asymm.at(i).orginalLine.left(80).trimmed(); |
| 6488 |
cursor = document->find(label ,cursor); |
| 6489 |
|
| 6490 |
if (cursor.isNull()){ |
| 6491 |
cursor = editor->textCursor(); |
| 6492 |
cursor.movePosition(QTextCursor::Start); |
| 6493 |
label.chop(10); |
| 6494 |
cursor = document->find(label,cursor); |
| 6495 |
if (cursor.isNull()) { |
| 6496 |
cursor = editor->textCursor(); |
| 6497 |
} |
| 6498 |
} |
| 6499 |
QString vorherig,neues; |
| 6500 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 6501 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 6502 |
while (cursor.selectedText().endsWith("=")) { |
| 6503 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 6504 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 6505 |
} |
| 6506 |
neues = vorherig= cursor.selectedText(); |
| 6507 |
QStringList sl = vorherig.split(leer); |
| 6508 |
sl.removeOne("="); |
| 6509 |
if (sl.size()>=7) |
| 6510 |
neues=QString("%1 %2 %3 %4 %5 %6 %7 ") |
| 6511 |
.arg(mole.asymm.at(i).Label.section('_',0,0),-4) |
| 6512 |
.arg(qMax(1,editor->sfac.indexOf(mole.asymm.at(i).an)+1)) |
| 6513 |
.arg(mole.asymm.at(i).frac.x,10,'f',6) |
| 6514 |
.arg(mole.asymm.at(i).frac.y,10,'f',6) |
| 6515 |
.arg(mole.asymm.at(i).frac.z,10,'f',6) |
| 6516 |
.arg(mole.asymm.at(i).sof_org,9,'f',5) |
| 6517 |
.arg((mole.asymm.at(i).isIso)?mole.asymm.at(i).ufiso_org:QString("%1").arg(mole.asymm.at(i).uf.m11,9,'f',5)); |
| 6518 |
if (mole.asymm.at(i).an<0) { |
| 6519 |
neues.append(QString("%1 ") |
| 6520 |
.arg(mole.asymm.at(i).peakHeight,9,'f',2)); |
| 6521 |
} else |
| 6522 |
if (!mole.asymm.at(i).isIso){ |
| 6523 |
neues.append(QString("%1 =\n %2 %3 %4 %5") |
| 6524 |
.arg(mole.asymm.at(i).uf.m22,9,'f',5) |
| 6525 |
.arg(mole.asymm.at(i).uf.m33,9,'f',5) |
| 6526 |
.arg(mole.asymm.at(i).uf.m23,9,'f',5) |
| 6527 |
.arg(mole.asymm.at(i).uf.m13,9,'f',5) |
| 6528 |
.arg(mole.asymm.at(i).uf.m12,9,'f',5)); |
| 6529 |
} |
| 6530 |
cursor.deleteChar(); |
| 6531 |
cursor.insertText(neues); |
| 6532 |
mole.asymm[i].orginalLine=neues.section("=",0,0); |
| 6533 |
|
| 6534 |
}//i |
| 6535 |
cursor.endEditBlock (); |
| 6536 |
|
| 6537 |
grow(); |
| 6538 |
|
| 6539 |
// printf("%d\n",__LINE__); |
| 6540 |
} |
| 6541 |
|
| 6542 |
void Window::grow(){ |
| 6543 |
printf("g\n"); |
| 6544 |
chgl->disSelection(); |
| 6545 |
chgl->mol->grow(); |
| 6546 |
infoKanalNews(chgl->mol->HumanSymmetry); |
| 6547 |
|
| 6548 |
chgl->setMolecule(&mole); |
| 6549 |
chgl->fuse->setVisible(true); |
| 6550 |
chgl->grow->setVisible(false); |
| 6551 |
loadMolInTest(); |
| 6552 |
|
| 6553 |
chgl->update(); |
| 6554 |
update(); |
| 6555 |
chgl->update(); |
| 6556 |
} |
| 6557 |
|
| 6558 |
void Window::expandAll(){ |
| 6559 |
chgl->disSelection(); |
| 6560 |
chgl->mol->expandAll(); |
| 6561 |
infoKanalNews(chgl->mol->HumanSymmetry); |
| 6562 |
|
| 6563 |
chgl->setMolecule(&mole); |
| 6564 |
chgl->fuse->setVisible(true); |
| 6565 |
chgl->grow->setVisible(false); |
| 6566 |
loadMolInTest(); |
| 6567 |
|
| 6568 |
chgl->update(); |
| 6569 |
} |
| 6570 |
|
| 6571 |
void Window::fillCell(){ |
| 6572 |
chgl->disSelection(); |
| 6573 |
chgl->mol->fillCell(); |
| 6574 |
infoKanalNews(chgl->mol->HumanSymmetry); |
| 6575 |
|
| 6576 |
chgl->setMolecule(&mole); |
| 6577 |
chgl->fuse->setVisible(true); |
| 6578 |
chgl->grow->setVisible(false); |
| 6579 |
loadMolInTest(); |
| 6580 |
|
| 6581 |
chgl->update(); |
| 6582 |
} |
| 6583 |
|
| 6584 |
void Window::packInLimits(){ |
| 6585 |
QDialog *boxpack= new QDialog(this); |
| 6586 |
QDoubleSpinBox |
| 6587 |
*aminlim,*amaxlim, |
| 6588 |
*bminlim,*bmaxlim, |
| 6589 |
*cminlim,*cmaxlim; |
| 6590 |
aminlim = new QDoubleSpinBox(boxpack); |
| 6591 |
amaxlim = new QDoubleSpinBox(boxpack); |
| 6592 |
bminlim = new QDoubleSpinBox(boxpack); |
| 6593 |
bmaxlim = new QDoubleSpinBox(boxpack); |
| 6594 |
cminlim = new QDoubleSpinBox(boxpack); |
| 6595 |
cmaxlim = new QDoubleSpinBox(boxpack); |
| 6596 |
aminlim->setMinimum(-10.0); |
| 6597 |
amaxlim->setMinimum(0.0); |
| 6598 |
bminlim->setMinimum(-10.0); |
| 6599 |
bmaxlim->setMinimum(0.0); |
| 6600 |
cminlim->setMinimum(-10.0); |
| 6601 |
cmaxlim->setMinimum(0.0); |
| 6602 |
aminlim->setMaximum(1.0); |
| 6603 |
amaxlim->setMaximum(10.0); |
| 6604 |
bminlim->setMaximum(1.0); |
| 6605 |
bmaxlim->setMaximum(10.0); |
| 6606 |
cminlim->setMaximum(1.0); |
| 6607 |
cmaxlim->setMaximum(10.0); |
| 6608 |
aminlim->setValue(0.0); |
| 6609 |
amaxlim->setValue(1.0); |
| 6610 |
bminlim->setValue(0.0); |
| 6611 |
bmaxlim->setValue(1.0); |
| 6612 |
cminlim->setValue(0.0); |
| 6613 |
cmaxlim->setValue(1.0); |
| 6614 |
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 6615 |
connect(buttonBox, SIGNAL(rejected()), boxpack, SLOT(reject())); |
| 6616 |
connect(buttonBox, SIGNAL(accepted()), boxpack, SLOT(accept())); |
| 6617 |
QGridLayout *g = new QGridLayout(boxpack); |
| 6618 |
g->addWidget(new QLabel("pack range along a "),0,0); |
| 6619 |
g->addWidget(aminlim,1,0); |
| 6620 |
g->addWidget(amaxlim,2,0); |
| 6621 |
g->addWidget(new QLabel("pack range along b "),0,1); |
| 6622 |
g->addWidget(bminlim,1,1); |
| 6623 |
g->addWidget(bmaxlim,2,1); |
| 6624 |
g->addWidget(new QLabel("pack range along c "),0,2); |
| 6625 |
g->addWidget(cminlim,1,2); |
| 6626 |
g->addWidget(cmaxlim,2,2); |
| 6627 |
g->addWidget(buttonBox,10,0,1,3); |
| 6628 |
if (QDialog::Accepted==boxpack->exec()){ |
| 6629 |
chgl->disSelection(); |
| 6630 |
chgl->mol->showatoms.clear(); |
| 6631 |
chgl->mol->packInLimits(aminlim->value(),amaxlim->value(),bminlim->value(),bmaxlim->value(),cminlim->value(),cmaxlim->value()); |
| 6632 |
chgl->setMolecule(&mole); |
| 6633 |
chgl->fuse->setVisible(true); |
| 6634 |
chgl->grow->setVisible(false); |
| 6635 |
loadMolInTest(); |
| 6636 |
|
| 6637 |
chgl->update(); |
| 6638 |
} |
| 6639 |
|
| 6640 |
} |
| 6641 |
|
| 6642 |
void Window::grow_plus(){ |
| 6643 |
printf("grow_plus?\n"); |
| 6644 |
chgl->disSelection(); |
| 6645 |
chgl->mol->grow_plus(); |
| 6646 |
infoKanalNews(chgl->mol->HumanSymmetry); |
| 6647 |
loadMolInTest(); |
| 6648 |
chgl->setMolecule(&mole); |
| 6649 |
chgl->fuse->setVisible(true); |
| 6650 |
chgl->grow->setVisible(false); |
| 6651 |
|
| 6652 |
chgl->update(); |
| 6653 |
} |
| 6654 |
|
| 6655 |
void Window::complete(){ |
| 6656 |
printf("Complete?\n"); |
| 6657 |
chgl->disSelection(); |
| 6658 |
chgl->mol->complete(); |
| 6659 |
infoKanalNews(chgl->mol->HumanSymmetry); |
| 6660 |
loadMolInTest(); |
| 6661 |
chgl->setMolecule(&mole); |
| 6662 |
chgl->fuse->setVisible(true); |
| 6663 |
chgl->grow->setVisible(false); |
| 6664 |
|
| 6665 |
chgl->update(); |
| 6666 |
} |
| 6667 |
struct Dtocom{//distance to center of mass |
| 6668 |
int idx; |
| 6669 |
double d; |
| 6670 |
}; |
| 6671 |
|
| 6672 |
inline bool operator < (const Dtocom &d1, const Dtocom &d2) {return (d1.d<d2.d);}; |
| 6673 |
|
| 6674 |
void Window::inheritLabels(){ |
| 6675 |
return; |
| 6676 |
/* |
| 6677 |
QList <int> imapperA,imapperB, istfalsch,istsuper; |
| 6678 |
|
| 6679 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 6680 |
QList<int> index; |
| 6681 |
if (action){ |
| 6682 |
//printf("inher it\n"); |
| 6683 |
index = chgl->lastClicked(); |
| 6684 |
} |
| 6685 |
else return; |
| 6686 |
if (index.size()<2) return; |
| 6687 |
// * |
| 6688 |
CEnvironment molecule[2]; |
| 6689 |
QList<Dtocom> dc[2]; |
| 6690 |
int nn=0, ne=0; |
| 6691 |
//printf("asymmetric unit size: %d\n",mole.asymm.size()); |
| 6692 |
//printf("%d(%d) %d(%d)\n",mole.asymm.at(index.at(0)).molindex,index.at(0),mole.asymm.at(index.at(1)).molindex,index.at(1)); |
| 6693 |
//qDebug()<<index; |
| 6694 |
V3 middle[2]; |
| 6695 |
middle[0]=V3(0.,0.,0.); |
| 6696 |
middle[1]=V3(0.,0.,0.); |
| 6697 |
// QList<SdmItem> sdms[2]; |
| 6698 |
Matrix amat[2]; |
| 6699 |
amat[0]=Matrix(1.,0.,0., 0.,1.,0., 0.,0.,1.); |
| 6700 |
amat[1]=Matrix(1.,0.,0., 0.,1.,0., 0.,0.,1.); |
| 6701 |
for (int j =0; j < mole.showatoms.size(); j++){ |
| 6702 |
mole.showatoms[j].hidden=1; |
| 6703 |
if ((mole.asymm.at(index.at(0)).molindex == mole.showatoms.at(j).molindex)|| |
| 6704 |
(mole.asymm.at(index.at(1)).molindex == mole.showatoms.at(j).molindex)){ |
| 6705 |
mole.showatoms[j].hidden=0; |
| 6706 |
} |
| 6707 |
} |
| 6708 |
for (int i =0; i < 2; i++){ |
| 6709 |
for (int j =0; j < mole.asymm.size(); j++){ |
| 6710 |
if (mole.asymm.at(index.at(i)).molindex == mole.asymm.at(j).molindex) { |
| 6711 |
molecule[i].append(mole.asymm[j]); |
| 6712 |
molecule[i].last().scod = j; |
| 6713 |
molecule[i].last().sg = i; |
| 6714 |
middle[i]+=mole.asymm.at(j).pos; |
| 6715 |
} |
| 6716 |
} |
| 6717 |
middle[i]*=1.0/molecule[i].size(); |
| 6718 |
//sdms[i] = mole.computeSDM(molecule[i]); |
| 6719 |
for (int j = 0; j < molecule[i].size(); j++){ |
| 6720 |
Dtocom cc; |
| 6721 |
cc.idx=j; |
| 6722 |
cc.d=Distance(molecule[i].at(j).pos, middle[i]); |
| 6723 |
dc[i].append(cc); |
| 6724 |
} |
| 6725 |
#if (QT_VERSION >= 0x050000) |
| 6726 |
std::sort(dc[i].begin(),dc[i].end()); |
| 6727 |
#else |
| 6728 |
qSort(dc[i].begin(),dc[i].end()); |
| 6729 |
#endif |
| 6730 |
|
| 6731 |
for (int n0=0; n0<dc[i].size(); n0++){ |
| 6732 |
printf("distance to center of mass %s %f\n",molecule[i][dc[i].at(n0).idx].Label.toStdString().c_str(),sqrt(dc[i].at(n0).d)); |
| 6733 |
} |
| 6734 |
|
| 6735 |
nn=0; |
| 6736 |
ne=dc[i].size(); |
| 6737 |
V3 a1,a2,a3; |
| 6738 |
do{ |
| 6739 |
a1=Normalize(middle[i]-molecule[i].at(dc[i].at((nn+1)%ne).idx).pos);//a1=(A-B)/|A-B| |
| 6740 |
a2=Normalize(middle[i]-molecule[i].at(dc[i].at((nn)%ne).idx).pos);//a2=(A-C)/|A-B| |
| 6741 |
a3=Normalize(a1%a2);//a3=(a1 x a2)/(a1 x a2) |
| 6742 |
a2=a3%a1;//a2 = a3 x a1 |
| 6743 |
printf("Determinant of fit matrix%d %g %f %f %d %d %d\n",i, a1*(a2%a3), sqrt(dc[i].at(nn%ne).d), sqrt(dc[i].at((nn+1)%ne).d) ,nn%ne,(nn+1)%ne,ne); |
| 6744 |
nn++; |
| 6745 |
} while((a1*(a2%a3))<0.9); |
| 6746 |
amat[i]=(i==0)?transponse(Matrix(a1,a2,a3)):Matrix(a1,a2,a3); |
| 6747 |
|
| 6748 |
|
| 6749 |
} |
| 6750 |
|
| 6751 |
if (molecule[0].size()!=molecule[1].size()) { |
| 6752 |
QMessageBox::information(0,"information",QString("The Number of atoms in the two molecules is not the same. This program can not help here, sorry! %1 %2") |
| 6753 |
.arg(molecule[0].size()).arg(molecule[1].size())); |
| 6754 |
return; |
| 6755 |
} |
| 6756 |
|
| 6757 |
for (int j = 0; j < molecule[0].size(); j++){ |
| 6758 |
//molecule[0][j].pos+=-1.0*middle[0]; |
| 6759 |
molecule[0][j].style=0; |
| 6760 |
molecule[0][j].frac=(((molecule[0][j].pos-(1.0*middle[0]))*amat[1])*amat[0])+middle[1]; |
| 6761 |
printf("#%-5d %f %f %f %s\n %f %f %f %s\n",j |
| 6762 |
,molecule[0][j].frac.x, molecule[0][j].frac.y, molecule[0][j].frac.z, molecule[0][j].Label.toStdString().c_str() |
| 6763 |
,molecule[1][j].pos.x, molecule[1][j].pos.y, molecule[1][j].pos.z, molecule[1][j].Label.toStdString().c_str() |
| 6764 |
);// * / |
| 6765 |
} |
| 6766 |
double dmd=0.0,dmdmin=1e37; |
| 6767 |
int ia1min=0,ia2min=0; |
| 6768 |
|
| 6769 |
//middle[0]=middle[1]; |
| 6770 |
for (int n0=0; n0<dc[0].size(); n0++){ |
| 6771 |
printf("I. distance to center of mass %s %f\n",molecule[0][dc[0].at(n0).idx].Label.toStdString().c_str() |
| 6772 |
,sqrt(Distance(molecule[0][dc[0].at(n0).idx].frac,middle[0]))); |
| 6773 |
printf("II. distance to center of mass %s %f\n",molecule[1][dc[1].at(n0).idx].Label.toStdString().c_str() |
| 6774 |
,sqrt(Distance(molecule[1][dc[1].at(n0).idx].pos,middle[1]))); |
| 6775 |
} |
| 6776 |
for (int ia1=0; ia1<ne; ia1++){ |
| 6777 |
for (int ia2=0; ia2<ne; ia2++){ |
| 6778 |
if (ia1==ia2) continue; |
| 6779 |
V3 a1,a2,a3; |
| 6780 |
a1=Normalize(middle[0]-molecule[0].at(dc[0].at(ia1).idx).pos);//a1=(A-B)/|A-B| |
| 6781 |
a2=Normalize(middle[0]-molecule[0].at(dc[0].at(ia2).idx).pos);//a2=(A-C)/|A-B| |
| 6782 |
a3=Normalize(a1%a2);//a3=(a1 x a2)/(a1 x a2) |
| 6783 |
a2=a3%a1;//a2 = a3 x a1 |
| 6784 |
printf("_Determinant of fit matrix0 %g %f %f %d %d %d\n", a1*(a2%a3), sqrt(dc[0].at(ia1).d), sqrt(dc[0].at(ia2).d), ia1, ia2,ne); |
| 6785 |
|
| 6786 |
amat[0]=transponse(Matrix(a1,a2,a3)); |
| 6787 |
for (int j = 0; j < molecule[0].size(); j++){ |
| 6788 |
//molecule[0][j].pos+=-1.0*middle[0]; |
| 6789 |
molecule[0][j].style=0; |
| 6790 |
molecule[0][j].frac=(((molecule[0][j].pos-(1.0*middle[0]))*amat[1])*amat[0])+middle[1]; |
| 6791 |
//printf("#%-5d %f %f %f %s\n %f %f %f %s\n",j |
| 6792 |
// ,molecule[0][j].pos.x,molecule[0][j].pos.y,molecule[0][j].pos.z,molecule[0][j].Label.toStdString().c_str() |
| 6793 |
// ,molecule[1][j].pos.x,molecule[1][j].pos.y,molecule[1][j].pos.z,molecule[1][j].Label.toStdString().c_str() |
| 6794 |
// ); |
| 6795 |
} |
| 6796 |
//mole.selectedatoms.append(xd); |
| 6797 |
dmd=0.0; |
| 6798 |
for (int i = 0; i < molecule[1].size(); i++){ |
| 6799 |
double dm = 1.0e35; |
| 6800 |
int k=0; |
| 6801 |
for (int j = 0; j < molecule[0].size(); j++){ |
| 6802 |
if (molecule[0][j].style!=0) continue; |
| 6803 |
double d = Distance(molecule[0].at(i).frac, molecule[1].at(j).pos); |
| 6804 |
if (d<dm){ |
| 6805 |
k=j; |
| 6806 |
dm=d; |
| 6807 |
} |
| 6808 |
} |
| 6809 |
molecule[0][k].style=1; |
| 6810 |
dmd+=dm; |
| 6811 |
} |
| 6812 |
dmd/=molecule[0].size(); |
| 6813 |
if (dmd<dmdmin){ |
| 6814 |
dmdmin=dmd; |
| 6815 |
ia1min=ia1; |
| 6816 |
ia2min=ia2; |
| 6817 |
} |
| 6818 |
//printf("##### %f #### %f\n",dmd,dmdmin); |
| 6819 |
|
| 6820 |
} |
| 6821 |
} |
| 6822 |
{ |
| 6823 |
V3 a1,a2,a3; |
| 6824 |
a1=Normalize(middle[0]-molecule[0].at(dc[0].at(ia1min).idx).pos);//a1=(A-B)/|A-B| |
| 6825 |
a2=Normalize(middle[0]-molecule[0].at(dc[0].at(ia2min).idx).pos);//a2=(A-C)/|A-B| |
| 6826 |
a3=Normalize(a1%a2);//a3=(a1 x a2)/(a1 x a2) |
| 6827 |
a2=a3%a1;//a2 = a3 x a1 |
| 6828 |
printf("_Determinant of fit final matrix0 %g %f %f %d %d %d\n", a1*(a2%a3), sqrt(dc[0].at(ia1min).d), sqrt(dc[0].at(ia2min).d), ia1min, ia2min,ne); |
| 6829 |
|
| 6830 |
amat[0]=transponse(Matrix(a1,a2,a3)); |
| 6831 |
|
| 6832 |
for (int j = 0; j < molecule[0].size(); j++){ |
| 6833 |
//molecule[0][j].pos+=-1.0*middle[0]; |
| 6834 |
molecule[0][j].style=0; |
| 6835 |
molecule[0][j].pos=(((molecule[0][j].pos-(1.0*middle[0]))*amat[1])*amat[0])+middle[1]; |
| 6836 |
printf("#%-5d %f %f %f %s\n %f %f %f %s\n",j |
| 6837 |
,molecule[0][j].pos.x,molecule[0][j].pos.y,molecule[0][j].pos.z,molecule[0][j].Label.toStdString().c_str() |
| 6838 |
,molecule[1][j].pos.x,molecule[1][j].pos.y,molecule[1][j].pos.z,molecule[1][j].Label.toStdString().c_str() |
| 6839 |
);// * / |
| 6840 |
} |
| 6841 |
dmd=0.0; |
| 6842 |
for (int i = 0; i < molecule[1].size(); i++){ |
| 6843 |
double dm = 100.0; |
| 6844 |
int k=0; |
| 6845 |
for (int j = 0; j < molecule[0].size(); j++){ |
| 6846 |
if (molecule[0][j].style!=0) continue; |
| 6847 |
double d = Distance(molecule[0].at(i).pos, molecule[1].at(j).pos); |
| 6848 |
if (d<dm){ |
| 6849 |
k=j; |
| 6850 |
dm=d; |
| 6851 |
} |
| 6852 |
} |
| 6853 |
molecule[0][k].style=1; |
| 6854 |
printf("%s -> %s %f %f %f\n" |
| 6855 |
,molecule[0][i].Label.toStdString().c_str() |
| 6856 |
,molecule[1][k].Label.toStdString().c_str() |
| 6857 |
,sqrt(dm) |
| 6858 |
,sqrt(Distance(molecule[0].at(i).pos, middle[0])) |
| 6859 |
,sqrt(Distance(molecule[1].at(k).pos, middle[1])) |
| 6860 |
); |
| 6861 |
dmd+=dm; |
| 6862 |
imapperA.append(molecule[1][k].scod); |
| 6863 |
imapperB.append(molecule[0][i].scod); |
| 6864 |
} |
| 6865 |
dmd/=molecule[0].size(); |
| 6866 |
//printf("##### %f ####\n",dmd); |
| 6867 |
} |
| 6868 |
|
| 6869 |
chgl->setRotationCenter(middle[1]); |
| 6870 |
mole.fitatoms.clear(); |
| 6871 |
MyAtom m; |
| 6872 |
m.an=-42; |
| 6873 |
m.pos=middle[1]; |
| 6874 |
m.Label="com"; |
| 6875 |
|
| 6876 |
m.part=0; |
| 6877 |
m.resiNr=0; |
| 6878 |
m.hidden=0; |
| 6879 |
m.symmGroup=0; |
| 6880 |
m.sg=0; |
| 6881 |
m.scod=555;//the identity |
| 6882 |
m.sof=0; |
| 6883 |
m.sof_org=0; |
| 6884 |
m.screenX=0; |
| 6885 |
m.screenY=0; |
| 6886 |
m.afix=0; |
| 6887 |
mole.fitatoms.append(molecule[1]); |
| 6888 |
mole.fitatoms.append(molecule[0]); |
| 6889 |
mole.fitatoms.append(m); |
| 6890 |
|
| 6891 |
// printf("%d\n",mole.fitatoms.size()); |
| 6892 |
Connection abond,bbond; |
| 6893 |
abond = mole.connecting(molecule[1],true); |
| 6894 |
mole.fitbonds = mole.connecting(molecule[0],true); |
| 6895 |
mole.fitbonds.append(abond); |
| 6896 |
|
| 6897 |
// chgl->pairing(imapperA,imapperB); |
| 6898 |
|
| 6899 |
chgl->update(); |
| 6900 |
|
| 6901 |
|
| 6902 |
|
| 6903 |
DragDropAtomsDialog *ddad = new DragDropAtomsDialog(chgl, mole, imapperA, &imapperB,this); |
| 6904 |
connect(ddad,SIGNAL(pairs(const QString&)),chgl,SLOT(selectPair(const QString&))); |
| 6905 |
ddad->resiFinder=editor->resiFinder; |
| 6906 |
//ddad->show(); |
| 6907 |
|
| 6908 |
molecule[0].clear(); |
| 6909 |
molecule[1].clear(); |
| 6910 |
imapperA.clear(); |
| 6911 |
imapperB.clear(); |
| 6912 |
mole.fitatoms.clear(); |
| 6913 |
mole.fitbonds.clear(); |
| 6914 |
mole.showbonds.clear(); |
| 6915 |
mole.showbonds=mole.connecting(mole.showatoms); |
| 6916 |
chgl->rotCenter(); |
| 6917 |
chgl->rCenter->hide(); |
| 6918 |
chgl->showHidden(); |
| 6919 |
//sdms[0].clear(); |
| 6920 |
//sdms[1].clear(); |
| 6921 |
delete ddad; |
| 6922 |
// */ |
| 6923 |
} |
| 6924 |
|
| 6925 |
void Window::obj(){ |
| 6926 |
mole.exportOBJ(dirName,mole.showatoms,mole.showbonds); |
| 6927 |
} |
| 6928 |
|
| 6929 |
void Window::sina(){//anis rueckrwaerts |
| 6930 |
if (mole.asymm.isEmpty()) return; |
| 6931 |
if (chgl->mol->selectedatoms.isEmpty()) { |
| 6932 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 6933 |
int index=-1; |
| 6934 |
if (action) |
| 6935 |
index=action->data().toInt(); |
| 6936 |
else index=-1; |
| 6937 |
if (index>mole.asymm.size()) index=-1; |
| 6938 |
if (index!=-1) { |
| 6939 |
chgl->mol->selectedatoms.clear(); |
| 6940 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[index]); |
| 6941 |
chgl->mol->selectedatoms.last().style=index; |
| 6942 |
} |
| 6943 |
} |
| 6944 |
QTextDocument *document = editor->document(); |
| 6945 |
QTextCursor cursor = editor->textCursor(); |
| 6946 |
if (chgl->mol->selectedatoms.isEmpty()){ |
| 6947 |
double uEQ; |
| 6948 |
cursor.beginEditBlock(); |
| 6949 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 6950 |
if (!mole.asymm.at(i).isIso){ |
| 6951 |
uEQ=0.05;//mole.ueq(mole.asymm.at(i).uf); |
| 6952 |
mole.asymm[i].uf.m11= |
| 6953 |
mole.asymm[i].uf.m22= |
| 6954 |
mole.asymm[i].uf.m33= |
| 6955 |
mole.asymm[i].uc.m11= |
| 6956 |
mole.asymm[i].uc.m22= |
| 6957 |
mole.asymm[i].uc.m33=uEQ; |
| 6958 |
mole.asymm[i].isIso=true; |
| 6959 |
mole.asymm[i].uf.m12 = mole.asymm[i].uf.m21 = uEQ * mole.cell.cosrg; |
| 6960 |
mole.asymm[i].uf.m13 = mole.asymm[i].uf.m31 = uEQ * mole.cell.cosrb; |
| 6961 |
mole.asymm[i].uf.m23 = mole.asymm[i].uf.m32 = uEQ * mole.cell.cosra; |
| 6962 |
mole.asymm[i].uc.m21= |
| 6963 |
mole.asymm[i].uc.m12= |
| 6964 |
mole.asymm[i].uc.m13= |
| 6965 |
mole.asymm[i].uc.m31= |
| 6966 |
mole.asymm[i].uc.m32= |
| 6967 |
mole.asymm[i].uc.m23=0.0; |
| 6968 |
QString label = mole.asymm.at(i).orginalLine.left(80).trimmed(); |
| 6969 |
cursor.movePosition(QTextCursor::Start); |
| 6970 |
cursor = document->find(label,cursor); |
| 6971 |
if (cursor.isNull()){ |
| 6972 |
cursor = editor->textCursor(); |
| 6973 |
cursor.movePosition(QTextCursor::Start); |
| 6974 |
label.chop(10); |
| 6975 |
cursor = document->find(label,cursor); |
| 6976 |
if (cursor.isNull()) { |
| 6977 |
cursor = editor->textCursor(); |
| 6978 |
printf("hab was nicht %d %s\n",i,label.toStdString().c_str()); |
| 6979 |
continue; |
| 6980 |
} |
| 6981 |
} |
| 6982 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 6983 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 6984 |
while (cursor.selectedText().endsWith("=")) { |
| 6985 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 6986 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 6987 |
} |
| 6988 |
cursor.deleteChar(); |
| 6989 |
mole.asymm[i].orginalLine= |
| 6990 |
QString("%1 %2 %3 %4 %5 %6 %7") |
| 6991 |
.arg(mole.asymm.at(i).Label.section('_',0,0),-4) |
| 6992 |
.arg(qMax(1,editor->sfac.indexOf(mole.asymm.at(i).an)+1)) |
| 6993 |
.arg(mole.asymm.at(i).frac.x,9,'f',5) |
| 6994 |
.arg(mole.asymm.at(i).frac.y,9,'f',5) |
| 6995 |
.arg(mole.asymm.at(i).frac.z,9,'f',5) |
| 6996 |
.arg(mole.asymm.at(i).sof_org,9,'f',5) |
| 6997 |
.arg(mole.asymm.at(i).uf.m11,9,'f',5); |
| 6998 |
cursor.insertText(mole.asymm[i].orginalLine); |
| 6999 |
QString s = |
| 7000 |
QString("<font color=blue>Isotropyfied atom: %1 part:%2 residue:%3 %4 </font> Please save to update structure view.") |
| 7001 |
.arg(mole.asymm.at(i).Label) |
| 7002 |
.arg(mole.asymm.at(i).part) |
| 7003 |
.arg(mole.asymm.at(i).resiNr) |
| 7004 |
.arg(mole.asymm.at(i).ResiClass); |
| 7005 |
infoKanalNews(s); |
| 7006 |
} |
| 7007 |
} |
| 7008 |
cursor.endEditBlock(); |
| 7009 |
mole.showatoms.clear(); |
| 7010 |
mole.showbonds.clear(); |
| 7011 |
chgl->mol->showatoms.clear(); |
| 7012 |
chgl->mol->showbonds.clear(); |
| 7013 |
chgl->mol->selectedatoms.clear(); |
| 7014 |
for (int o=0; o<mole.asymm.size();o++) |
| 7015 |
mole.showatoms.append(mole.asymm[o]); |
| 7016 |
mole.showbonds = |
| 7017 |
mole.connecting(mole.showatoms); |
| 7018 |
chgl->mol->selectedatoms.clear(); |
| 7019 |
|
| 7020 |
bool growYes=chgl->fuse->isVisible (); |
| 7021 |
chgl->mol->fuse(); |
| 7022 |
if (growYes) chgl->mol->grow(); |
| 7023 |
|
| 7024 |
|
| 7025 |
// printf("%d\n",__LINE__); |
| 7026 |
|
| 7027 |
loadMolInTest(); |
| 7028 |
chgl->updateBondActions(); |
| 7029 |
chgl->update(); |
| 7030 |
update(); |
| 7031 |
chgl->update(); |
| 7032 |
} |
| 7033 |
else |
| 7034 |
{ |
| 7035 |
double uEQ; |
| 7036 |
cursor.beginEditBlock(); |
| 7037 |
for (int j=0; j<mole.selectedatoms.size(); j++){ |
| 7038 |
int i=mole.selectedatoms.at(j).style; |
| 7039 |
if ((i>=mole.asymm.size())||(i<0)) continue; |
| 7040 |
if (!mole.asymm.at(i).isIso){ |
| 7041 |
uEQ=0.05;//mole.ueq(mole.asymm.at(i).uf); |
| 7042 |
mole.asymm[i].uf.m11= |
| 7043 |
mole.asymm[i].uf.m22= |
| 7044 |
mole.asymm[i].uf.m33= |
| 7045 |
mole.asymm[i].uc.m11= |
| 7046 |
mole.asymm[i].uc.m22= |
| 7047 |
mole.asymm[i].uc.m33=uEQ; |
| 7048 |
mole.asymm[i].isIso=true; |
| 7049 |
mole.asymm[i].uf.m12 = mole.asymm[i].uf.m21 = uEQ * mole.cell.cosrg; |
| 7050 |
mole.asymm[i].uf.m13 = mole.asymm[i].uf.m31 = uEQ * mole.cell.cosrb; |
| 7051 |
mole.asymm[i].uf.m23 = mole.asymm[i].uf.m32 = uEQ * mole.cell.cosra; |
| 7052 |
mole.asymm[i].uc.m21= |
| 7053 |
mole.asymm[i].uc.m12= |
| 7054 |
mole.asymm[i].uc.m13= |
| 7055 |
mole.asymm[i].uc.m31= |
| 7056 |
mole.asymm[i].uc.m32= |
| 7057 |
mole.asymm[i].uc.m23=0.0; |
| 7058 |
QString label = mole.asymm.at(i).orginalLine.left(80).trimmed(); |
| 7059 |
cursor.movePosition(QTextCursor::Start); |
| 7060 |
cursor = document->find(label,cursor); |
| 7061 |
if (cursor.isNull()){ |
| 7062 |
cursor = editor->textCursor(); |
| 7063 |
cursor.movePosition(QTextCursor::Start); |
| 7064 |
label.chop(10); |
| 7065 |
cursor = document->find(label,cursor); |
| 7066 |
if (cursor.isNull()) { |
| 7067 |
cursor = editor->textCursor(); |
| 7068 |
printf("hab was nicht %d %s\n",i,label.toStdString().c_str()); |
| 7069 |
continue; |
| 7070 |
} |
| 7071 |
} |
| 7072 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 7073 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7074 |
while (cursor.selectedText().endsWith("=")) { |
| 7075 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 7076 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7077 |
} |
| 7078 |
cursor.deleteChar(); |
| 7079 |
mole.asymm[i].orginalLine= |
| 7080 |
QString("%1 %2 %3 %4 %5 %6 %7") |
| 7081 |
.arg(mole.asymm.at(i).Label.section('_',0,0),-4) |
| 7082 |
.arg(qMax(1,editor->sfac.indexOf(mole.asymm.at(i).an)+1)) |
| 7083 |
.arg(mole.asymm.at(i).frac.x,9,'f',5) |
| 7084 |
.arg(mole.asymm.at(i).frac.y,9,'f',5) |
| 7085 |
.arg(mole.asymm.at(i).frac.z,9,'f',5) |
| 7086 |
.arg(mole.asymm.at(i).sof_org,9,'f',5) |
| 7087 |
.arg(mole.asymm.at(i).uf.m11,9,'f',5); |
| 7088 |
cursor.insertText(mole.asymm[i].orginalLine); |
| 7089 |
QString s = |
| 7090 |
QString("<font color=blue>Isotropyfied atom: %1 part:%2 residue:%3 %4 </font> Please save to update structure view.") |
| 7091 |
.arg(mole.asymm.at(i).Label) |
| 7092 |
.arg(mole.asymm.at(i).part) |
| 7093 |
.arg(mole.asymm.at(i).resiNr) |
| 7094 |
.arg(mole.asymm.at(i).ResiClass); |
| 7095 |
infoKanalNews(s); |
| 7096 |
} |
| 7097 |
} |
| 7098 |
cursor.endEditBlock(); |
| 7099 |
mole.showatoms.clear(); |
| 7100 |
mole.showbonds.clear(); |
| 7101 |
chgl->mol->showatoms.clear(); |
| 7102 |
chgl->mol->showbonds.clear(); |
| 7103 |
chgl->mol->selectedatoms.clear(); |
| 7104 |
for (int o=0; o<mole.asymm.size();o++) |
| 7105 |
mole.showatoms.append(mole.asymm[o]); |
| 7106 |
mole.sdmcompleter(); |
| 7107 |
mole.showbonds = |
| 7108 |
mole.connecting(mole.showatoms); |
| 7109 |
chgl->mol->selectedatoms.clear(); |
| 7110 |
|
| 7111 |
bool growYes=chgl->fuse->isVisible (); |
| 7112 |
chgl->mol->fuse(); |
| 7113 |
if (growYes) chgl->mol->grow(); |
| 7114 |
|
| 7115 |
|
| 7116 |
// printf("%d\n",__LINE__); |
| 7117 |
|
| 7118 |
loadMolInTest(); |
| 7119 |
chgl->updateBondActions(); |
| 7120 |
chgl->update(); |
| 7121 |
update(); |
| 7122 |
chgl->update(); |
| 7123 |
|
| 7124 |
} |
| 7125 |
} |
| 7126 |
|
| 7127 |
void Window::autoHFix(){ |
| 7128 |
if (mole.asymm.isEmpty()) return; |
| 7129 |
int warmal=mole.asymm.size(); |
| 7130 |
int warmalAtome=0; |
| 7131 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)warmalAtome++; |
| 7132 |
QStringList alab; |
| 7133 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 7134 |
alab.append(mole.asymm.at(i).Label); |
| 7135 |
} |
| 7136 |
QString nn; |
| 7137 |
chgl->disSelection(); |
| 7138 |
chgl->mol->grow(); |
| 7139 |
|
| 7140 |
MyAtom htest,qtest; |
| 7141 |
|
| 7142 |
double xh[8]={ |
| 7143 |
0.98,//1 |
| 7144 |
0.97,//2 |
| 7145 |
0.96,//3 |
| 7146 |
0.93,//4 |
| 7147 |
1.10,//15 B |
| 7148 |
0.82,//8 O |
| 7149 |
0.93,//9 |
| 7150 |
0.93// 16 |
| 7151 |
}; |
| 7152 |
|
| 7153 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 7154 |
htest.an=0; |
| 7155 |
htest.part=0; |
| 7156 |
htest.resiNr=0; |
| 7157 |
htest.hidden=0; |
| 7158 |
htest.symmGroup=0; |
| 7159 |
htest.sg=0; |
| 7160 |
htest.scod=555;//the identity |
| 7161 |
htest.auidx=-1; |
| 7162 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 7163 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 7164 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 7165 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 7166 |
qtest=htest; |
| 7167 |
qtest.an=-1; |
| 7168 |
QTextDocument *document = editor->document(); |
| 7169 |
QTextCursor cursor = editor->textCursor(); |
| 7170 |
cursor.beginEditBlock (); |
| 7171 |
QMap<int,int> keinDonor; |
| 7172 |
QMap<int,int> istDonor; |
| 7173 |
for (int j=0;j<mole.contact.size();j++){ |
| 7174 |
double ch1,ch2; |
| 7175 |
if (mole.knoepfe.at(mole.contact.at(j).a1).neighbors.size()==0) keinDonor[mole.contact.at(j).a1]++; |
| 7176 |
if (mole.knoepfe.at(mole.contact.at(j).a2).neighbors.size()==0) keinDonor[mole.contact.at(j).a2]++; |
| 7177 |
if ((mole.asymm.at(mole.contact.at(j).a1).an==7)&&(mole.knoepfe.at(mole.contact.at(j).a1).neighbors.size()>1)) keinDonor[mole.contact.at(j).a1]++; |
| 7178 |
if ((mole.asymm.at(mole.contact.at(j).a2).an==7)&&(mole.knoepfe.at(mole.contact.at(j).a2).neighbors.size()>1)) keinDonor[mole.contact.at(j).a2]++; |
| 7179 |
if ((mole.contact.at(j).covalent)){// |
| 7180 |
ch1=ch2=0; |
| 7181 |
|
| 7182 |
for (int k=0; k<mole.knoepfe.at(mole.contact.at(j).a1).neighbors.size(); k++){ |
| 7183 |
ch1 += sqrt(Distance(mole.asymm.at(mole.contact.at(j).a1).pos, |
| 7184 |
mole.showatoms.at(mole.knoepfe.at(mole.contact.at(j).a1).neighbors.at(k)).pos))- |
| 7185 |
((mole.Kovalenz_Radien[mole.asymm.at(mole.contact.at(j).a1).an]+ |
| 7186 |
mole.Kovalenz_Radien[mole.showatoms.at(mole.knoepfe.at(mole.contact.at(j).a1).neighbors.at(k)).an])*0.0095); |
| 7187 |
|
| 7188 |
} |
| 7189 |
if (mole.knoepfe.at(mole.contact.at(j).a1).neighbors.size()) |
| 7190 |
ch1*=1.0/mole.knoepfe.at(mole.contact.at(j).a1).neighbors.size(); |
| 7191 |
|
| 7192 |
for (int k=0; k<mole.knoepfe.at(mole.contact.at(j).a2).neighbors.size(); k++){ |
| 7193 |
ch2 += sqrt(Distance(mole.asymm.at(mole.contact.at(j).a2).pos, |
| 7194 |
mole.showatoms.at(mole.knoepfe.at(mole.contact.at(j).a2).neighbors.at(k)).pos))- |
| 7195 |
((mole.Kovalenz_Radien[mole.asymm.at(mole.contact.at(j).a2).an]+ |
| 7196 |
mole.Kovalenz_Radien[mole.showatoms.at(mole.knoepfe.at(mole.contact.at(j).a2).neighbors.at(k)).an])*0.0095); |
| 7197 |
} |
| 7198 |
if (mole.knoepfe.at(mole.contact.at(j).a2).neighbors.size()) |
| 7199 |
ch2*=1.0/mole.knoepfe.at(mole.contact.at(j).a2).neighbors.size(); |
| 7200 |
/*printf("%s %s %d %d %g %g\n" |
| 7201 |
,mole.asymm.at(mole.contact.at(j).a1).Label.toStdString().c_str() |
| 7202 |
,mole.asymm.at(mole.contact.at(j).a2).Label.toStdString().c_str(), |
| 7203 |
((ch1-0.01)>ch2),((ch2-0.01)>ch1),ch1,ch2 |
| 7204 |
);*/ |
| 7205 |
if (ch1<-0.2 ) keinDonor[mole.contact.at(j).a1]++; |
| 7206 |
if (ch2<-0.2 ) keinDonor[mole.contact.at(j).a2]++; |
| 7207 |
if ((ch1-0.01)>ch2) istDonor[mole.contact.at(j).a1]++; |
| 7208 |
if ((ch2-0.01)>ch1) istDonor[mole.contact.at(j).a2]++; |
| 7209 |
} |
| 7210 |
} |
| 7211 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 7212 |
if ((mole.asymm.at(i).an==5)||(mole.asymm.at(i).an==6)){ |
| 7213 |
double nh= (mole.asymm.at(i).an==6) ? 0.07 : 0; |
| 7214 |
if (mole.is2Dissordered4H(mole.asymm.at(i))) continue; |
| 7215 |
double plan=1.0; |
| 7216 |
if (mole.knoepfe.at(i).neighbors.size()==1) { |
| 7217 |
if ((mole.asymm.at(i).an==6)&&(!istDonor.contains(i))) { |
| 7218 |
printf("%s is probably no donor \n",mole.asymm.at(i).Label.toStdString().c_str()); |
| 7219 |
continue; |
| 7220 |
} |
| 7221 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0);//,b=V3(0,0,0),c=V3(0,0,0); |
| 7222 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos - mole.asymm.at(i).pos; |
| 7223 |
//printf("A = %s-%s %g %g %g\n",mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).Label.toStdString().c_str(),mole.asymm.at(i).Label.toStdString().c_str(),a.x,a.y,a.z); |
| 7224 |
double chi = sqrt(Norm(a))-((mole.Kovalenz_Radien[mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).an]+mole.Kovalenz_Radien[mole.asymm.at(i).an])/100.0); |
| 7225 |
if (chi>-0.09) {//afix 137 127 |
| 7226 |
int j,k,l; |
| 7227 |
a=Normalize(a); |
| 7228 |
double jx,kx,lx,mx,my,mz; |
| 7229 |
double val[24],merg[8],wink=0,t=0,mt=0; |
| 7230 |
for (int z=0; z<8;z++) merg[z]=0; |
| 7231 |
if (fxle->n5){ |
| 7232 |
for (int z=0; z<24; z++){ |
| 7233 |
if ((a==V3(0,0,-1))||(a==V3(0,0,1))) { |
| 7234 |
w=Normalize(V3(1,1,1)%a); |
| 7235 |
} else { |
| 7236 |
w=Normalize(V3(0,0,1)%a); |
| 7237 |
} |
| 7238 |
//printf("w= %g %g %g\n",w.x,w.y,w.z); |
| 7239 |
u=Normalize(w%a); |
| 7240 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 7241 |
qtest.pos=v; |
| 7242 |
mole.kart2frac(v,v); |
| 7243 |
int zplu=0; |
| 7244 |
do { |
| 7245 |
jx=((zplu+v.x)*fxle->n1+0.5); |
| 7246 |
zplu++; |
| 7247 |
}while (jx<0); |
| 7248 |
zplu=0; |
| 7249 |
do { |
| 7250 |
kx=((zplu+v.y)*fxle->n2+0.5); |
| 7251 |
zplu++; |
| 7252 |
}while (kx<0); |
| 7253 |
zplu=0; |
| 7254 |
do { |
| 7255 |
lx=((zplu+v.z)*fxle->n3+0.5); |
| 7256 |
zplu++; |
| 7257 |
}while (lx<0); |
| 7258 |
mx=jx-floor(jx); |
| 7259 |
my=kx-floor(kx); |
| 7260 |
mz=lx-floor(lx); |
| 7261 |
j=((int)jx)%fxle->n1;// |
| 7262 |
k=((int)kx)%fxle->n2;// |
| 7263 |
l=((int)lx)%fxle->n3;// |
| 7264 |
merg[z%8]+=val[z]=( |
| 7265 |
(1-mx)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7266 |
mx*fxle->datfo_fc[((j+1)+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7267 |
(1-my)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7268 |
my*fxle->datfo_fc[(j+fxle->n1*((k+1)+l*fxle->n2))%fxle->n5]+ |
| 7269 |
(1-mz)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7270 |
mz*fxle->datfo_fc[(j+fxle->n1*(k+(l+1)*fxle->n2))%fxle->n5])/3.0; |
| 7271 |
qtest.peakHeight=val[z]; |
| 7272 |
qtest.frac=v; |
| 7273 |
qtest.Label=QString("Q%1#").arg(z,-2); |
| 7274 |
mole.pmin=qMin(mole.pmin, qtest.peakHeight); |
| 7275 |
mole.pmax=qMax(mole.pmax, qtest.peakHeight); |
| 7276 |
qpv->cutoff=0;//mole.pmin; |
| 7277 |
qpv->setMin(mole.pmin); |
| 7278 |
qpv->setMax(mole.pmax); |
| 7279 |
mole.asymm.append(qtest); |
| 7280 |
wink+=0.261799387799; |
| 7281 |
} |
| 7282 |
for (int z=0; z<8;z++) { |
| 7283 |
t =merg[(z+8)%8] ; |
| 7284 |
double x = t - merg[(z+9)%8]; |
| 7285 |
double u = t - merg[(z+7)%8]; |
| 7286 |
if (fmin(x,u)<0) continue; |
| 7287 |
double p=0.5*(u-x)/(u+x); |
| 7288 |
t=t+0.25*(p*(u-x)); |
| 7289 |
mt=(mt>t)?mt:t; |
| 7290 |
if (t<mt)continue; |
| 7291 |
wink=((double) z + p )*0.261799387799; |
| 7292 |
} |
| 7293 |
} else { |
| 7294 |
int zzz=0; |
| 7295 |
int z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 7296 |
while ((z==i)&&(zzz<mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.size())) { |
| 7297 |
z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 7298 |
} |
| 7299 |
if ((a==V3(0,0,-1))||(a==V3(0,0,1))) { |
| 7300 |
w=Normalize(V3(1,1,1)%a); |
| 7301 |
} else { |
| 7302 |
w=Normalize(V3(0,0,1)%a); |
| 7303 |
} |
| 7304 |
u=Normalize(w%a); |
| 7305 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 7306 |
// if z == i then dieder() returns nan, because A in dieder gets (0,0,0) |
| 7307 |
V3 increm = V3(0.0, 0.0, 0.0); |
| 7308 |
if ( z == i ) { |
| 7309 |
increm = V3(0.00001, 0.00001, 0.00001); |
| 7310 |
} |
| 7311 |
wink=mole.dieder(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos+increm-mole.asymm.at(z).pos, |
| 7312 |
mole.asymm.at(i).pos-mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos, |
| 7313 |
v-mole.asymm.at(i).pos)/180.0*M_PI; |
| 7314 |
} |
| 7315 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 7316 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 7317 |
htest.part=mole.asymm.at(i).part; |
| 7318 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 7319 |
htest.Label.replace(0,1,'H'); |
| 7320 |
QString baslab=htest.Label; |
| 7321 |
int hindex=1; |
| 7322 |
QString nnn=htest.Label; |
| 7323 |
do { |
| 7324 |
htest.Label=baslab; |
| 7325 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7326 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7327 |
if (htest.resiNr) |
| 7328 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7329 |
.arg(nnn) |
| 7330 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7331 |
else nn=nnn; |
| 7332 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7333 |
hindex++; |
| 7334 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7335 |
htest.Label=nnn; |
| 7336 |
alab.append(nn); |
| 7337 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.5; |
| 7338 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 7339 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 7340 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 7341 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 7342 |
htest.isIso=true; |
| 7343 |
htest.ufiso_org=QString("-1.5"); |
| 7344 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 7345 |
htest.pos=v; |
| 7346 |
mole.kart2frac(htest.pos,htest.frac); |
| 7347 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7348 |
.arg(htest.Label) |
| 7349 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7350 |
.arg(htest.frac.x,9,'f',5) |
| 7351 |
.arg(htest.frac.y,9,'f',5) |
| 7352 |
.arg(htest.frac.z,9,'f',5) |
| 7353 |
.arg(mole.asymm.at(i).sof_org) |
| 7354 |
.arg("-1.5"); |
| 7355 |
mole.asymm.append(htest); |
| 7356 |
wink+=2.09439510239; |
| 7357 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 7358 |
do { |
| 7359 |
htest.Label=baslab; |
| 7360 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7361 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7362 |
if (htest.resiNr) |
| 7363 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7364 |
.arg(nnn) |
| 7365 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7366 |
else nn=nnn; |
| 7367 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7368 |
hindex++; |
| 7369 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7370 |
htest.Label=nnn; |
| 7371 |
alab.append(nn); |
| 7372 |
htest.pos=v; |
| 7373 |
mole.kart2frac(htest.pos,htest.frac); |
| 7374 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7375 |
.arg(htest.Label) |
| 7376 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7377 |
.arg(htest.frac.x,9,'f',5) |
| 7378 |
.arg(htest.frac.y,9,'f',5) |
| 7379 |
.arg(htest.frac.z,9,'f',5) |
| 7380 |
.arg(mole.asymm.at(i).sof_org) |
| 7381 |
.arg("-1.5"); |
| 7382 |
mole.asymm.append(htest); |
| 7383 |
wink+=2.09439510239; |
| 7384 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 7385 |
do { |
| 7386 |
htest.Label=baslab; |
| 7387 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7388 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7389 |
if (htest.resiNr) |
| 7390 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7391 |
.arg(nnn) |
| 7392 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7393 |
else nn=nnn; |
| 7394 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7395 |
hindex++; |
| 7396 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7397 |
htest.Label=nnn; |
| 7398 |
alab.append(nn); |
| 7399 |
htest.pos=v; |
| 7400 |
mole.kart2frac(htest.pos,htest.frac); |
| 7401 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7402 |
.arg(htest.Label) |
| 7403 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7404 |
.arg(htest.frac.x,9,'f',5) |
| 7405 |
.arg(htest.frac.y,9,'f',5) |
| 7406 |
.arg(htest.frac.z,9,'f',5) |
| 7407 |
.arg(mole.asymm.at(i).sof_org) |
| 7408 |
.arg("-1.5"); |
| 7409 |
mole.asymm.append(htest); |
| 7410 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 7411 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 7412 |
cursor.movePosition(QTextCursor::Start); |
| 7413 |
cursor = document->find(label,cursor); |
| 7414 |
if (cursor.isNull()){ |
| 7415 |
cursor = editor->textCursor(); |
| 7416 |
cursor.movePosition(QTextCursor::Start); |
| 7417 |
label.chop(10); |
| 7418 |
cursor = document->find(label,cursor); |
| 7419 |
if (cursor.isNull()) { |
| 7420 |
cursor = editor->textCursor(); |
| 7421 |
} |
| 7422 |
} |
| 7423 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 7424 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7425 |
while (cursor.selectedText().endsWith("=")) { |
| 7426 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 7427 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7428 |
} |
| 7429 |
cursor.clearSelection(); |
| 7430 |
cursor.movePosition(QTextCursor::Down); |
| 7431 |
cursor.insertText(QString("AFIX 137\n%1\n%2\n%3\nAFIX %4\n") |
| 7432 |
.arg(mole.asymm.at(mole.asymm.size()-3).orginalLine) |
| 7433 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 7434 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 7435 |
.arg(mole.afix5(i)) |
| 7436 |
); |
| 7437 |
}else if (chi> -0.27){//afix 93 |
| 7438 |
int j,k,l; |
| 7439 |
a=Normalize(a); |
| 7440 |
double jx,kx,lx,mx,my,mz; |
| 7441 |
double val[24],merg[12],wink=0,t=0,mt=0; |
| 7442 |
if (fxle->n5){ |
| 7443 |
for (int z=0; z<12;z++) merg[z]=0; |
| 7444 |
for (int z=0; z<24; z++){ |
| 7445 |
wink=z*0.261799387799; |
| 7446 |
w=Normalize(V3(0,0,1)%a); |
| 7447 |
u=Normalize(w%a); |
| 7448 |
v=(-(xh[6]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[6]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 7449 |
qtest.pos=v; |
| 7450 |
mole.kart2frac(v,v); |
| 7451 |
jx=(v.x>0)?(v.x*fxle->n1+0.5):((1.0+v.x)*fxle->n1+0.5); |
| 7452 |
kx=(v.y>0)?(v.y*fxle->n2+0.5):((1.0+v.y)*fxle->n2+0.5); |
| 7453 |
lx=(v.z>0)?(v.z*fxle->n3+0.5):((1.0+v.z)*fxle->n3+0.5); |
| 7454 |
mx=jx-floor(jx); |
| 7455 |
my=kx-floor(kx); |
| 7456 |
mz=lx-floor(lx); |
| 7457 |
j=((int)jx)%fxle->n1;// |
| 7458 |
k=((int)kx)%fxle->n2;// |
| 7459 |
l=((int)lx)%fxle->n3;// |
| 7460 |
merg[z%12]+=val[z]=( |
| 7461 |
(1-mx)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7462 |
mx*fxle->datfo_fc[((j+1)+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7463 |
(1-my)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7464 |
my*fxle->datfo_fc[(j+fxle->n1*((k+1)+l*fxle->n2))%fxle->n5]+ |
| 7465 |
(1-mz)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 7466 |
mz*fxle->datfo_fc[(j+fxle->n1*(k+(l+1)*fxle->n2))%fxle->n5])/3.0; |
| 7467 |
qtest.peakHeight=val[z]; |
| 7468 |
qtest.frac=v; |
| 7469 |
qtest.Label=QString("Q%1").arg(z+100); |
| 7470 |
mole.pmin=qMin(mole.pmin, qtest.peakHeight); |
| 7471 |
mole.pmax=qMax(mole.pmax, qtest.peakHeight); |
| 7472 |
qpv->cutoff=0;//mole.pmin; |
| 7473 |
qpv->setMin(mole.pmin); |
| 7474 |
qpv->setMax(mole.pmax); |
| 7475 |
mole.asymm.append(qtest); |
| 7476 |
} |
| 7477 |
for (int z=0; z<12;z++) { |
| 7478 |
t =merg[(z+12)%12] ; |
| 7479 |
double x = t - merg[(z+13)%12]; |
| 7480 |
double u = t - merg[(z+11)%12]; |
| 7481 |
if (fmin(x,u)<0) continue; |
| 7482 |
double p=0.5*(u-x)/(u+x); |
| 7483 |
t=t+0.25*(p*(u-x)); |
| 7484 |
mt=(mt>t)?mt:t; |
| 7485 |
if (t<mt)continue; |
| 7486 |
wink=((double) z + p )*0.261799387799; |
| 7487 |
|
| 7488 |
///////////////// |
| 7489 |
} |
| 7490 |
}else{ |
| 7491 |
int zzz=0; |
| 7492 |
int z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 7493 |
while ((z==i)&&(zzz<mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.size())) |
| 7494 |
z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 7495 |
w=Normalize(V3(0,0,1)%a); |
| 7496 |
u=Normalize(w%a); |
| 7497 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 7498 |
// if z == i then dieder() returns nan, because A in dieder gets (0,0,0) |
| 7499 |
V3 increm = V3(0.0, 0.0, 0.0); |
| 7500 |
if ( z == i ) { |
| 7501 |
increm = V3(0.00001, 0.00001, 0.00001); |
| 7502 |
} |
| 7503 |
wink=mole.dieder(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos+increm-mole.asymm.at(z).pos, |
| 7504 |
mole.asymm.at(i).pos-mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos, |
| 7505 |
v-mole.asymm.at(i).pos)/180.0*M_PI; |
| 7506 |
|
| 7507 |
} |
| 7508 |
|
| 7509 |
v=(-(xh[6]-nh)*0.5*a)+ mole.asymm.at(i).pos+(xh[6]-nh)*0.866025403784*(sin(wink)*u+cos(wink)*w); |
| 7510 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 7511 |
htest.part=mole.asymm.at(i).part; |
| 7512 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 7513 |
htest.Label.replace(0,1,'H'); |
| 7514 |
int hindex=1; |
| 7515 |
QString nnn=htest.Label; |
| 7516 |
QString baslab=htest.Label; |
| 7517 |
do { |
| 7518 |
htest.Label=baslab; |
| 7519 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7520 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7521 |
if (htest.resiNr) |
| 7522 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7523 |
.arg(nnn) |
| 7524 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7525 |
else nn=nnn; |
| 7526 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7527 |
hindex++; |
| 7528 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7529 |
htest.Label=nnn; |
| 7530 |
alab.append(nn); |
| 7531 |
htest.isIso=true; |
| 7532 |
htest.ufiso_org=QString("-1.2"); |
| 7533 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 7534 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 7535 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 7536 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 7537 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 7538 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 7539 |
htest.pos=v; |
| 7540 |
mole.kart2frac(htest.pos,htest.frac); |
| 7541 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7542 |
.arg(htest.Label) |
| 7543 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7544 |
.arg(htest.frac.x,9,'f',5) |
| 7545 |
.arg(htest.frac.y,9,'f',5) |
| 7546 |
.arg(htest.frac.z,9,'f',5) |
| 7547 |
.arg(mole.asymm.at(i).sof_org) |
| 7548 |
.arg("-1.2"); |
| 7549 |
mole.asymm.append(htest); |
| 7550 |
wink+=3.14159265359; |
| 7551 |
v=(-(xh[6]-nh)*0.5*a)+ mole.asymm.at(i).pos+(xh[6]-nh)*0.866025403784*(sin(wink)*u+cos(wink)*w); |
| 7552 |
do { |
| 7553 |
htest.Label=baslab; |
| 7554 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7555 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7556 |
if (htest.resiNr) |
| 7557 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7558 |
.arg(nnn) |
| 7559 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7560 |
else nn=nnn; |
| 7561 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7562 |
hindex++; |
| 7563 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7564 |
htest.Label=nnn; |
| 7565 |
alab.append(nn); |
| 7566 |
htest.pos=v; |
| 7567 |
mole.kart2frac(htest.pos,htest.frac); |
| 7568 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7569 |
.arg(htest.Label) |
| 7570 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7571 |
.arg(htest.frac.x,9,'f',5) |
| 7572 |
.arg(htest.frac.y,9,'f',5) |
| 7573 |
.arg(htest.frac.z,9,'f',5) |
| 7574 |
.arg(mole.asymm.at(i).sof_org) |
| 7575 |
.arg("-1.2"); |
| 7576 |
mole.asymm.append(htest); |
| 7577 |
|
| 7578 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 7579 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 7580 |
cursor.movePosition(QTextCursor::Start); |
| 7581 |
cursor = document->find(label,cursor); |
| 7582 |
if (cursor.isNull()){ |
| 7583 |
cursor = editor->textCursor(); |
| 7584 |
cursor.movePosition(QTextCursor::Start); |
| 7585 |
label.chop(10); |
| 7586 |
cursor = document->find(label,cursor); |
| 7587 |
if (cursor.isNull()) { |
| 7588 |
cursor = editor->textCursor(); |
| 7589 |
} |
| 7590 |
} |
| 7591 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 7592 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7593 |
while (cursor.selectedText().endsWith("=")) { |
| 7594 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 7595 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7596 |
} |
| 7597 |
cursor.clearSelection(); |
| 7598 |
cursor.movePosition(QTextCursor::Down); |
| 7599 |
cursor.insertText(QString("AFIX 93\n%1\n%2\nAFIX %3\n") |
| 7600 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 7601 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 7602 |
.arg(mole.afix5(i)) |
| 7603 |
); |
| 7604 |
}else{//afix 163 |
| 7605 |
if (mole.asymm.at(i).an==5){ |
| 7606 |
a = Normalize(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos - mole.asymm.at(i).pos); |
| 7607 |
v=(-(xh[7]-nh)*a)+ mole.asymm.at(i).pos; |
| 7608 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 7609 |
htest.part=mole.asymm.at(i).part; |
| 7610 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 7611 |
htest.Label.replace(0,1,'H'); |
| 7612 |
int hindex=0; |
| 7613 |
QString nnn=htest.Label; |
| 7614 |
do { |
| 7615 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7616 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7617 |
if (htest.resiNr) |
| 7618 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7619 |
.arg(nnn) |
| 7620 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7621 |
else nn=nnn; |
| 7622 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7623 |
hindex++; |
| 7624 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7625 |
htest.Label=nnn; |
| 7626 |
alab.append(nn); |
| 7627 |
htest.isIso=true; |
| 7628 |
htest.ufiso_org=QString("-1.2"); |
| 7629 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 7630 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 7631 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 7632 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 7633 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 7634 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 7635 |
htest.pos=v; |
| 7636 |
mole.kart2frac(htest.pos,htest.frac); |
| 7637 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7638 |
.arg(htest.Label) |
| 7639 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7640 |
.arg(htest.frac.x,9,'f',5) |
| 7641 |
.arg(htest.frac.y,9,'f',5) |
| 7642 |
.arg(htest.frac.z,9,'f',5) |
| 7643 |
.arg(mole.asymm.at(i).sof_org) |
| 7644 |
.arg("-1.2"); |
| 7645 |
mole.asymm.append(htest); |
| 7646 |
|
| 7647 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 7648 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 7649 |
cursor.movePosition(QTextCursor::Start); |
| 7650 |
cursor = document->find(label,cursor); |
| 7651 |
if (cursor.isNull()){ |
| 7652 |
cursor = editor->textCursor(); |
| 7653 |
cursor.movePosition(QTextCursor::Start); |
| 7654 |
label.chop(10); |
| 7655 |
cursor = document->find(label,cursor); |
| 7656 |
if (cursor.isNull()) { |
| 7657 |
cursor = editor->textCursor(); |
| 7658 |
} |
| 7659 |
} |
| 7660 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 7661 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7662 |
while (cursor.selectedText().endsWith("=")) { |
| 7663 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 7664 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7665 |
} |
| 7666 |
cursor.clearSelection(); |
| 7667 |
cursor.movePosition(QTextCursor::Down); |
| 7668 |
cursor.insertText(QString("AFIX 163\n%1\nAFIX %2\n") |
| 7669 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 7670 |
.arg(mole.afix5(i)) |
| 7671 |
); |
| 7672 |
} |
| 7673 |
} |
| 7674 |
} |
| 7675 |
if (mole.knoepfe.at(i).neighbors.size()==2){//afix 43 oder 23 |
| 7676 |
if ((mole.asymm.at(i).an==6)&&(!istDonor.contains(i))) { |
| 7677 |
printf("%s is probably no donor \n",mole.asymm.at(i).Label.toStdString().c_str()); |
| 7678 |
continue; |
| 7679 |
} |
| 7680 |
double angle=0; |
| 7681 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0),b=V3(0,0,0),c=V3(0,0,0); |
| 7682 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0) ).pos - mole.asymm.at(i).pos; |
| 7683 |
b = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(1) ).pos - mole.asymm.at(i).pos; |
| 7684 |
double chi1 = sqrt(Norm(a))- |
| 7685 |
((mole.Kovalenz_Radien[mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).an]+ |
| 7686 |
mole.Kovalenz_Radien[mole.asymm.at(i).an])/100.0); |
| 7687 |
double chi2 = sqrt(Norm(b))- |
| 7688 |
((mole.Kovalenz_Radien[mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(1)).an]+ |
| 7689 |
mole.Kovalenz_Radien[mole.asymm.at(i).an])/100.0); |
| 7690 |
a = c = Normalize(a) ; |
| 7691 |
c = c+ (b= Normalize(b)); |
| 7692 |
angle=mole.winkel(a,b); |
| 7693 |
c = Normalize(c); |
| 7694 |
double andi=(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(1)).an+mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).an)/2.0-5.0; |
| 7695 |
andi= (andi)?0.8:1.0; |
| 7696 |
if (angle<160) { |
| 7697 |
if ((andi*(chi1+chi2))<-0.13) {//43 |
| 7698 |
c = (-(xh[3]-nh) * c)+mole.asymm.at(i).pos; |
| 7699 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 7700 |
htest.part=mole.asymm.at(i).part; |
| 7701 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 7702 |
htest.Label.replace(0,1,'H'); |
| 7703 |
int hindex=0; |
| 7704 |
QString nnn=htest.Label; |
| 7705 |
do { |
| 7706 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7707 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7708 |
if (htest.resiNr) |
| 7709 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7710 |
.arg(nnn) |
| 7711 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7712 |
else nn=nnn; |
| 7713 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7714 |
hindex++; |
| 7715 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7716 |
htest.Label=nnn; |
| 7717 |
alab.append(nn); |
| 7718 |
htest.isIso=true; |
| 7719 |
htest.ufiso_org=QString("-1.2"); |
| 7720 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 7721 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 7722 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 7723 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 7724 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 7725 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 7726 |
htest.pos=c; |
| 7727 |
mole.kart2frac(htest.pos,htest.frac); |
| 7728 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7729 |
.arg(htest.Label) |
| 7730 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7731 |
.arg(htest.frac.x,9,'f',5) |
| 7732 |
.arg(htest.frac.y,9,'f',5) |
| 7733 |
.arg(htest.frac.z,9,'f',5) |
| 7734 |
.arg(mole.asymm.at(i).sof_org) |
| 7735 |
.arg("-1.2"); |
| 7736 |
mole.asymm.append(htest); |
| 7737 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 7738 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 7739 |
cursor.movePosition(QTextCursor::Start); |
| 7740 |
cursor = document->find(label,cursor); |
| 7741 |
if (cursor.isNull()){ |
| 7742 |
cursor = editor->textCursor(); |
| 7743 |
cursor.movePosition(QTextCursor::Start); |
| 7744 |
label.chop(10); |
| 7745 |
cursor = document->find(label,cursor); |
| 7746 |
if (cursor.isNull()) { |
| 7747 |
cursor = editor->textCursor(); |
| 7748 |
} |
| 7749 |
} |
| 7750 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 7751 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7752 |
while (cursor.selectedText().endsWith("=")) { |
| 7753 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 7754 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7755 |
} |
| 7756 |
cursor.clearSelection(); |
| 7757 |
cursor.movePosition(QTextCursor::Down); |
| 7758 |
cursor.insertText(QString("AFIX 43\n%1\nAFIX %2\n") |
| 7759 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 7760 |
.arg(mole.afix5(i))); |
| 7761 |
} |
| 7762 |
else{//23 |
| 7763 |
w = Normalize(a); |
| 7764 |
u = Normalize(b); |
| 7765 |
double si=1.0376-0.0346*Norm(w-u); //=1.91063323625-((acos(u*w)-1.91063323625)/5.0);//-1.91063323625 = 109.47 grad ; 3.7 empirischer Wert |
| 7766 |
c = (-cos(si)*(xh[1]-nh) * c); |
| 7767 |
v = sin(si) *(xh[1]-nh) * Normalize(c%a); |
| 7768 |
a = mole.asymm.at(i).pos + c + v; |
| 7769 |
b = mole.asymm.at(i).pos + c - v; |
| 7770 |
c = c + mole.asymm.at(i).pos; |
| 7771 |
|
| 7772 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 7773 |
htest.part=mole.asymm.at(i).part; |
| 7774 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 7775 |
htest.Label.replace(0,1,'H'); |
| 7776 |
int hindex=1; |
| 7777 |
QString nnn=htest.Label; |
| 7778 |
QString ann=htest.Label; |
| 7779 |
do { |
| 7780 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7781 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7782 |
if (htest.resiNr) |
| 7783 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7784 |
.arg(nnn) |
| 7785 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7786 |
else nn=nnn; |
| 7787 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7788 |
hindex++; |
| 7789 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7790 |
htest.Label=nnn; |
| 7791 |
alab.append(nn); |
| 7792 |
htest.isIso=true; |
| 7793 |
htest.ufiso_org=QString("-1.2"); |
| 7794 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 7795 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 7796 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 7797 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 7798 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 7799 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 7800 |
htest.pos=a; |
| 7801 |
mole.kart2frac(htest.pos,htest.frac); |
| 7802 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7803 |
.arg(htest.Label) |
| 7804 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7805 |
.arg(htest.frac.x,9,'f',5) |
| 7806 |
.arg(htest.frac.y,9,'f',5) |
| 7807 |
.arg(htest.frac.z,9,'f',5) |
| 7808 |
.arg(mole.asymm.at(i).sof_org) |
| 7809 |
.arg("-1.2"); |
| 7810 |
mole.asymm.append(htest); |
| 7811 |
//printf("AB problem: htest%s nnn%s ann%s\n",htest.Label.toStdString().c_str(),nnn.toStdString().c_str(),ann.toStdString().c_str()); |
| 7812 |
do { |
| 7813 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 7814 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 7815 |
if (htest.resiNr) |
| 7816 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7817 |
.arg(nnn) |
| 7818 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7819 |
else nn=nnn; |
| 7820 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7821 |
hindex++; |
| 7822 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7823 |
htest.Label=nnn; |
| 7824 |
alab.append(nn); |
| 7825 |
//printf("AB problems: htest%s nnn%s nn%s\n",htest.Label.toStdString().c_str(),nnn.toStdString().c_str(),nn.toStdString().c_str()); |
| 7826 |
htest.pos=b; |
| 7827 |
mole.kart2frac(htest.pos,htest.frac); |
| 7828 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7829 |
.arg(htest.Label) |
| 7830 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7831 |
.arg(htest.frac.x,9,'f',5) |
| 7832 |
.arg(htest.frac.y,9,'f',5) |
| 7833 |
.arg(htest.frac.z,9,'f',5) |
| 7834 |
.arg(mole.asymm.at(i).sof_org) |
| 7835 |
.arg("-1.2"); |
| 7836 |
mole.asymm.append(htest); |
| 7837 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 7838 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 7839 |
cursor.movePosition(QTextCursor::Start); |
| 7840 |
cursor = document->find(label,cursor); |
| 7841 |
if (cursor.isNull()){ |
| 7842 |
cursor = editor->textCursor(); |
| 7843 |
cursor.movePosition(QTextCursor::Start); |
| 7844 |
label.chop(10); |
| 7845 |
cursor = document->find(label,cursor); |
| 7846 |
if (cursor.isNull()) { |
| 7847 |
cursor = editor->textCursor(); |
| 7848 |
} |
| 7849 |
} |
| 7850 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 7851 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7852 |
while (cursor.selectedText().endsWith("=")) { |
| 7853 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 7854 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7855 |
} |
| 7856 |
cursor.clearSelection(); |
| 7857 |
cursor.movePosition(QTextCursor::Down); |
| 7858 |
cursor.insertText(QString("AFIX 23\n%1\n%2\nAFIX %3\n") |
| 7859 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 7860 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 7861 |
.arg(mole.afix5(i))); |
| 7862 |
|
| 7863 |
} |
| 7864 |
} |
| 7865 |
} |
| 7866 |
|
| 7867 |
if (mole.knoepfe.at(i).neighbors.size()==3) { |
| 7868 |
if ((mole.asymm.at(i).an==6)&&(!istDonor.contains(i))) continue; |
| 7869 |
V3 v,w=V3(0,0,0),u ,a,b,c=V3(0,0,0); |
| 7870 |
double ch1=0; |
| 7871 |
for (int k=0; k<3; k++){ |
| 7872 |
a = Normalize(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(k) ).pos - mole.asymm.at(i).pos); |
| 7873 |
b = Normalize(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at((k+1)%3)).pos - mole.asymm.at(i).pos); |
| 7874 |
c = c + a; |
| 7875 |
v = Normalize(a%b); |
| 7876 |
if (k) {plan*=fabs(w*v);//1 for perfect flat |
| 7877 |
} |
| 7878 |
w = v; |
| 7879 |
ch1 += sqrt(Distance(mole.asymm.at(i).pos, |
| 7880 |
mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(k)).pos))- |
| 7881 |
((mole.Kovalenz_Radien[mole.asymm.at(i).an]+ |
| 7882 |
mole.Kovalenz_Radien[mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(k)).an])*0.01); |
| 7883 |
|
| 7884 |
} |
| 7885 |
c = Normalize(c); |
| 7886 |
ch1*=1.0/3; |
| 7887 |
if ((plan<0.8)&&(ch1>-0.09)){// not flat and not to short bonds |
| 7888 |
c *=-(xh[0]-nh); |
| 7889 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 7890 |
htest.part=mole.asymm.at(i).part; |
| 7891 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 7892 |
htest.Label.replace(0,1,'H'); |
| 7893 |
int hindex=0; |
| 7894 |
QString nnn=htest.Label; |
| 7895 |
do { |
| 7896 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7897 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7898 |
if (htest.resiNr) |
| 7899 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7900 |
.arg(nnn) |
| 7901 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7902 |
else nn=nnn; |
| 7903 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7904 |
hindex++; |
| 7905 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7906 |
htest.Label=nnn; |
| 7907 |
alab.append(nn); |
| 7908 |
htest.isIso=true; |
| 7909 |
htest.ufiso_org=QString("-1.2"); |
| 7910 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 7911 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 7912 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 7913 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 7914 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 7915 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 7916 |
htest.pos = mole.asymm.at(i).pos + c; |
| 7917 |
mole.kart2frac(htest.pos,htest.frac); |
| 7918 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 7919 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 7920 |
cursor.movePosition(QTextCursor::Start); |
| 7921 |
cursor = document->find(label,cursor); |
| 7922 |
if (cursor.isNull()){ |
| 7923 |
cursor = editor->textCursor(); |
| 7924 |
cursor.movePosition(QTextCursor::Start); |
| 7925 |
label.chop(10); |
| 7926 |
cursor = document->find(label,cursor); |
| 7927 |
if (cursor.isNull()) { |
| 7928 |
cursor = editor->textCursor(); |
| 7929 |
} |
| 7930 |
} |
| 7931 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 7932 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7933 |
while (cursor.selectedText().endsWith("=")) { |
| 7934 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 7935 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 7936 |
} |
| 7937 |
cursor.clearSelection(); |
| 7938 |
cursor.movePosition(QTextCursor::Down); |
| 7939 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 7940 |
.arg(htest.Label) |
| 7941 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 7942 |
.arg(htest.frac.x,9,'f',5) |
| 7943 |
.arg(htest.frac.y,9,'f',5) |
| 7944 |
.arg(htest.frac.z,9,'f',5) |
| 7945 |
.arg(mole.asymm.at(i).sof_org) |
| 7946 |
.arg("-1.2"); |
| 7947 |
cursor.insertText(QString("AFIX 13\n%1\nAFIX %2\n").arg(htest.orginalLine).arg(mole.afix5(i))); |
| 7948 |
mole.asymm.append(htest); |
| 7949 |
} |
| 7950 |
} |
| 7951 |
} |
| 7952 |
if (((mole.asymm.at(i).an==4)||(mole.asymm.at(i).an==5))&&((mole.knoepfe.at(i).neighbors.size()==4)||(mole.knoepfe.at(i).neighbors.size()==5))){//boron with 4 or 5 neighbors AFIX 153 |
| 7953 |
//qDebug()<<mole.knoepfe.at(i).neighbors.size()<<mole.asymm.at(i).Label; |
| 7954 |
V3 vsum = V3(0.,0.,0.); |
| 7955 |
int nbs=mole.knoepfe.at(i).neighbors.size(); |
| 7956 |
int nbr=0; |
| 7957 |
for (int k=0; k<mole.knoepfe.at(i).neighbors.size();k++){ |
| 7958 |
if (abs(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(k)).an-5)<2){ |
| 7959 |
nbr++; |
| 7960 |
vsum+=(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(k) ).pos - mole.asymm.at(i).pos); |
| 7961 |
} |
| 7962 |
} |
| 7963 |
//printf("153 test length = %f %d==%d %s\n",Norm(vsum), nbs, nbr, mole.asymm.at(i).Label.toStdString().c_str()); |
| 7964 |
if ((nbs==nbr)&&(Norm(vsum)>10)){ |
| 7965 |
vsum=Normalize(vsum); |
| 7966 |
vsum*=-1.0*xh[4]; |
| 7967 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 7968 |
htest.part=mole.asymm.at(i).part; |
| 7969 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 7970 |
htest.Label.replace(0,1,'H'); |
| 7971 |
int hindex=0; |
| 7972 |
QString nnn=htest.Label; |
| 7973 |
do { |
| 7974 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 7975 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 7976 |
if (htest.resiNr) |
| 7977 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 7978 |
.arg(nnn) |
| 7979 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 7980 |
else nn=nnn; |
| 7981 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 7982 |
hindex++; |
| 7983 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 7984 |
htest.Label=nnn; |
| 7985 |
alab.append(nn); |
| 7986 |
htest.isIso=true; |
| 7987 |
htest.ufiso_org=QString("-1.2"); |
| 7988 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 7989 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 7990 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 7991 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 7992 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 7993 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 7994 |
htest.pos = mole.asymm.at(i).pos + vsum; |
| 7995 |
mole.kart2frac(htest.pos,htest.frac); |
| 7996 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 7997 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 7998 |
cursor.movePosition(QTextCursor::Start); |
| 7999 |
cursor = document->find(label,cursor); |
| 8000 |
if (cursor.isNull()){ |
| 8001 |
cursor = editor->textCursor(); |
| 8002 |
cursor.movePosition(QTextCursor::Start); |
| 8003 |
label.chop(10); |
| 8004 |
cursor = document->find(label,cursor); |
| 8005 |
if (cursor.isNull()) { |
| 8006 |
cursor = editor->textCursor(); |
| 8007 |
} |
| 8008 |
} |
| 8009 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 8010 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8011 |
while (cursor.selectedText().endsWith("=")) { |
| 8012 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 8013 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8014 |
} |
| 8015 |
cursor.clearSelection(); |
| 8016 |
cursor.movePosition(QTextCursor::Down); |
| 8017 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8018 |
.arg(htest.Label) |
| 8019 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8020 |
.arg(htest.frac.x,9,'f',5) |
| 8021 |
.arg(htest.frac.y,9,'f',5) |
| 8022 |
.arg(htest.frac.z,9,'f',5) |
| 8023 |
.arg(mole.asymm.at(i).sof_org) |
| 8024 |
.arg("-1.2"); |
| 8025 |
cursor.insertText(QString("AFIX 153\n%1\nAFIX %2\n").arg(htest.orginalLine).arg(mole.afix5(i))); |
| 8026 |
mole.asymm.append(htest); |
| 8027 |
} |
| 8028 |
} |
| 8029 |
} |
| 8030 |
for (int j=0;j<mole.contact.size();j++){ |
| 8031 |
/* printf("??LINE %d %s %s\n",__LINE__, |
| 8032 |
mole.asymm.at(mole.contact.at(j).a1).Label.toStdString().c_str(), |
| 8033 |
mole.asymm.at(mole.contact.at(j).a2).Label.toStdString().c_str());*/ |
| 8034 |
if ((istDonor.contains(mole.contact.at(j).a1)||(!keinDonor.contains(mole.contact.at(j).a1))) |
| 8035 |
&&(mole.asymm.at(mole.contact.at(j).a1).an==7)) { |
| 8036 |
if (keinDonor.contains(mole.contact.at(j).a1)) continue; |
| 8037 |
if (fxle->n5) { |
| 8038 |
htest = findOH(mole.cell.symmops.at(mole.contact.at(j).sn) * mole.asymm.at(mole.contact.at(j).a1).frac |
| 8039 |
+ mole.cell.trans.at(mole.contact.at(j).sn) - mole.contact.at(j).floorD, |
| 8040 |
mole.asymm.at(mole.contact.at(j).a2).frac, |
| 8041 |
mole.contact.at(j).a1,alab); |
| 8042 |
|
| 8043 |
/*printf("LINE %d %s %s\n",__LINE__, |
| 8044 |
mole.asymm.at(mole.contact.at(j).a1).Label.toStdString().c_str(), |
| 8045 |
mole.asymm.at(mole.contact.at(j).a2).Label.toStdString().c_str());*/ |
| 8046 |
|
| 8047 |
if (Distance(htest.pos,V3(0,0,0))<0.001){ |
| 8048 |
htest = findOH(mole.asymm.at(mole.contact.at(j).a1).frac, |
| 8049 |
mole.cell.symmops.at(mole.contact.at(j).sn) * mole.asymm.at(mole.contact.at(j).a2).frac |
| 8050 |
+ mole.cell.trans.at(mole.contact.at(j).sn) , |
| 8051 |
mole.contact.at(j).a1,alab); |
| 8052 |
/* printf("LINE %d %s %s\n",__LINE__, |
| 8053 |
mole.asymm.at(mole.contact.at(j).a1).Label.toStdString().c_str(), |
| 8054 |
mole.asymm.at(mole.contact.at(j).a2).Label.toStdString().c_str());*/ |
| 8055 |
// if (Distance(htest.pos,V3(0,0,0))<0.001){ keinDonor[mole.contact.at(j).a2]++; } |
| 8056 |
} else { |
| 8057 |
keinDonor[mole.contact.at(j).a1]++; |
| 8058 |
// qDebug()<<"done"<<mole.asymm.at(mole.contact.at(j).a2).Label; |
| 8059 |
} |
| 8060 |
if (Distance(htest.pos,V3(0,0,0))){ |
| 8061 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8062 |
.arg(htest.Label) |
| 8063 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8064 |
.arg(htest.frac.x,9,'f',5) |
| 8065 |
.arg(htest.frac.y,9,'f',5) |
| 8066 |
.arg(htest.frac.z,9,'f',5) |
| 8067 |
.arg(mole.asymm.at(mole.contact.at(j).a1).sof_org) |
| 8068 |
.arg("-1.5"); |
| 8069 |
mole.asymm.append(htest); |
| 8070 |
QString label = mole.showatoms.at(mole.contact.at(j).a1).orginalLine.left(80).trimmed(); |
| 8071 |
// int afixfuenf=(mole.showatoms.at(mole.contact.at(j).a1).afix/10)?(mole.showatoms.at(mole.contact.at(j).a1).afix/10)*10+5:0; |
| 8072 |
cursor.movePosition(QTextCursor::Start); |
| 8073 |
cursor = document->find(label,cursor); |
| 8074 |
if (cursor.isNull()){ |
| 8075 |
cursor = editor->textCursor(); |
| 8076 |
cursor.movePosition(QTextCursor::Start); |
| 8077 |
label.chop(10); |
| 8078 |
cursor = document->find(label,cursor); |
| 8079 |
if (cursor.isNull()) { |
| 8080 |
cursor = editor->textCursor(); |
| 8081 |
} |
| 8082 |
} |
| 8083 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 8084 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8085 |
while (cursor.selectedText().endsWith("=")) { |
| 8086 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 8087 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8088 |
} |
| 8089 |
cursor.clearSelection(); |
| 8090 |
cursor.movePosition(QTextCursor::Down); |
| 8091 |
cursor.insertText(QString("AFIX 148\n%1\nAFIX %2\n") |
| 8092 |
.arg(mole.asymm.last().orginalLine) |
| 8093 |
.arg(mole.afix5(mole.contact.at(j).a1)) |
| 8094 |
); |
| 8095 |
}//Dist |
| 8096 |
}//fxle->n5 |
| 8097 |
}// is O is in list of donors and not in list of no donors |
| 8098 |
|
| 8099 |
}// all contacts |
| 8100 |
cursor.endEditBlock(); |
| 8101 |
if (gehtMichAn.size()) gehtMichAn.takeLast(); |
| 8102 |
if (mole.asymm.size()!=warmal){ |
| 8103 |
gehtMichAn.append(mole.asymm.size()-warmal+2); |
| 8104 |
} |
| 8105 |
|
| 8106 |
int jetztAtome=0; |
| 8107 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 8108 |
actionHFix->setDisabled(true); |
| 8109 |
fuse(); |
| 8110 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <h2>Please SAVE NOW!</h2></font>").arg(jetztAtome-warmalAtome); |
| 8111 |
infoKanalNews(info); |
| 8112 |
|
| 8113 |
switch (duplicates()){ |
| 8114 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 8115 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 8116 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 8117 |
} |
| 8118 |
chgl->update(); |
| 8119 |
} |
| 8120 |
|
| 8121 |
MyAtom Window::findOH(V3 donor, V3 acceptor,int dindex,QStringList alab){ |
| 8122 |
CEnvironment peaks; |
| 8123 |
QString nn; |
| 8124 |
peaks.clear(); |
| 8125 |
double minGoofy=100000.0,g=0; |
| 8126 |
int minG=0; |
| 8127 |
V3 mdz=(0.5*fxle->dx)+(0.5*fxle->dy)+(0.5*fxle->dz); |
| 8128 |
V3 df=donor; |
| 8129 |
V3 af=acceptor; |
| 8130 |
if (mole.fl(af.x-df.x, af.y-df.y,af.z-df.z)>3.3){ |
| 8131 |
V3 floors; |
| 8132 |
floors = af-df+ V3(0.5,0.5,0.5); |
| 8133 |
floors = V3(floor(floors.x),floor(floors.y),floor(floors.z)); |
| 8134 |
af+=-1.0*floors; |
| 8135 |
} |
| 8136 |
double ad=mole.fl(af.x-df.x, af.y-df.y,af.z-df.z); |
| 8137 |
MyAtom htest; |
| 8138 |
htest.an=0; |
| 8139 |
htest.part=0; |
| 8140 |
htest.resiNr=0; |
| 8141 |
htest.hidden=0; |
| 8142 |
htest.Label=mole.asymm.at(dindex).Label.section('_',0,0); |
| 8143 |
htest.part=mole.asymm.at(dindex).part; |
| 8144 |
htest.resiNr=mole.asymm.at(dindex).resiNr; |
| 8145 |
htest.Label.replace(0,1,'H'); |
| 8146 |
int hindex=0; |
| 8147 |
QString nnn=htest.Label; |
| 8148 |
do { |
| 8149 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 8150 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 8151 |
if (htest.resiNr) |
| 8152 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8153 |
.arg(nnn) |
| 8154 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8155 |
else nn=nnn; |
| 8156 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8157 |
hindex++; |
| 8158 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8159 |
htest.Label=nnn; |
| 8160 |
alab.append(nn); |
| 8161 |
htest.symmGroup=0; |
| 8162 |
htest.sg=0; |
| 8163 |
htest.scod=555;//the identity |
| 8164 |
htest.auidx=-1; |
| 8165 |
htest.frac=V3(0,0,0); |
| 8166 |
htest.pos=V3(0,0,0); |
| 8167 |
htest.isIso=true; |
| 8168 |
htest.ufiso_org=QString("-1.5"); |
| 8169 |
double uIso = mole.ueq(mole.asymm.at(dindex).uf)*1.5; |
| 8170 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 8171 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 8172 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 8173 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 8174 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 8175 |
if (fxle->n5==0) return htest; |
| 8176 |
double x,y,z,u,v,w,p,q,r,t; |
| 8177 |
for (int k=0;k<fxle->n3;k++){ |
| 8178 |
for (int j=0;j<fxle->n2;j++){ |
| 8179 |
for (int i=0;i<fxle->n1;i++){ |
| 8180 |
V3 o= (i*fxle->dx+j*fxle->dy+k*fxle->dz) + mdz; |
| 8181 |
mole.kart2frac(o,o); |
| 8182 |
V3 floors; |
| 8183 |
floors = o-df+ V3(0.5,0.5,0.5); |
| 8184 |
floors = V3(floor(floors.x),floor(floors.y),floor(floors.z)); |
| 8185 |
o+=-1.0*floors; |
| 8186 |
double ha,hd; |
| 8187 |
hd=mole.fl(df.x-o.x, df.y-o.y,df.z-o.z); |
| 8188 |
ha=mole.fl(af.x-o.x, af.y-o.y,af.z-o.z); |
| 8189 |
if (1.2<hd) continue;//donor H must be smaller 1.2 A |
| 8190 |
if (2.6<ha) continue;//donor H must be smaller 2.6 A |
| 8191 |
if (hd<0.6) continue;//donor H must be greater 0.6 A |
| 8192 |
if (((ha*ha+hd*hd-ad*ad)/(2*hd*ha))>-0.57)continue; //angle greater 125deg ok! |
| 8193 |
t = fxle->datfo_fc[i+ fxle->n1*(j+k*fxle->n2)]; |
| 8194 |
x = t - fxle->datfo_fc[((i+1)%fxle->n1) + fxle->n1*(j+k*fxle->n2)]; |
| 8195 |
y = t - fxle->datfo_fc[i+ fxle->n1*(((j+1)%fxle->n2)+k*fxle->n2)]; |
| 8196 |
z = t - fxle->datfo_fc[i+ fxle->n1*(j+((k+1)%fxle->n3)*fxle->n2)]; |
| 8197 |
u = t - fxle->datfo_fc[((i+fxle->n1-1)%fxle->n1)+ fxle->n1*(j+k*fxle->n2)]; |
| 8198 |
v = t - fxle->datfo_fc[i+ fxle->n1*(((j+fxle->n2-1)%fxle->n2)+k*fxle->n2)]; |
| 8199 |
w = t - fxle->datfo_fc[i+ fxle->n1*(j+((k+fxle->n2-1)%fxle->n3)*fxle->n2)]; |
| 8200 |
if (fmin(x,fmin(y,fmin(z,fmin(u,fmin(v,w)))))<0) continue;//if this is not a maximum then skip |
| 8201 |
p=0.5*(u-x)/(u+x); |
| 8202 |
q=0.5*(v-y)/(v+y); |
| 8203 |
r=0.5*(w-z)/(w+z); |
| 8204 |
t=t+0.25*(p*(u-x)+q*(v-y)+r*(w-z)); |
| 8205 |
if (t<fabs(fxle->iso[1])*1.2) continue;// if this is below the green iso surface then skip |
| 8206 |
htest.peakHeight=t; |
| 8207 |
htest.frac.x = ((double) i + p +0.5)/fxle->n1; |
| 8208 |
htest.frac.y = ((double) j + q +0.5)/fxle->n2; |
| 8209 |
htest.frac.z = ((double) k + r +0.5)/fxle->n3; |
| 8210 |
hd=mole.fl(df.x-htest.frac.x, df.y-htest.frac.y,df.z-htest.frac.z); |
| 8211 |
ha=mole.fl(af.x-htest.frac.x, af.y-htest.frac.y,af.z-htest.frac.z); |
| 8212 |
if (hd<0.6) continue;//to close to donor |
| 8213 |
g=(ha+hd)/htest.peakHeight; |
| 8214 |
minG=(g<minGoofy)?peaks.size():minG; |
| 8215 |
minGoofy=(g<minGoofy)?g:minGoofy; |
| 8216 |
mole.frac2kart( htest.frac, htest.pos); |
| 8217 |
peaks.append(htest); |
| 8218 |
} |
| 8219 |
} |
| 8220 |
} |
| 8221 |
if (peaks.isEmpty()) { |
| 8222 |
htest.frac=htest.pos=V3(0,0,0); |
| 8223 |
return htest; |
| 8224 |
} |
| 8225 |
V3 D,floorD,prime,nf,dp; |
| 8226 |
double min=1000,dk=0; |
| 8227 |
for (int nn=0;nn<mole.cell.symmops.size(); nn++){ |
| 8228 |
prime=mole.cell.symmops.at(nn) * peaks.at(minG).frac + mole.cell.trans.at(nn); |
| 8229 |
D=prime - mole.asymm.at(dindex).frac + V3(0.5,0.5,0.5) ; |
| 8230 |
floorD=V3(floor(D.x),floor(D.y),floor(D.z)); |
| 8231 |
dp=D - floorD - V3(0.5,0.5,0.5); |
| 8232 |
dk=mole.fl(dp.x,dp.y,dp.z); |
| 8233 |
if (dk<min){ |
| 8234 |
min=dk; |
| 8235 |
nf=prime-floorD; |
| 8236 |
} |
| 8237 |
} |
| 8238 |
peaks[minG].frac=nf; |
| 8239 |
mole.frac2kart(peaks[minG].frac,peaks[minG].pos); |
| 8240 |
return peaks[minG]; |
| 8241 |
} |
| 8242 |
|
| 8243 |
void Window::invert(){ |
| 8244 |
if (mole.asymm.isEmpty()) return; |
| 8245 |
//inverting structure |
| 8246 |
QList<V3> moves; |
| 8247 |
moves.append(V3(1,1,1));//most of the space groups |
| 8248 |
moves.append(V3(1,0.5,1));//I41, I41md, I41cd |
| 8249 |
moves.append(V3(1,0.5,0.25));//I4122, I-42d |
| 8250 |
moves.append(V3(0.25,0.25,1));//Fdd2 |
| 8251 |
moves.append(V3(0.25,0.25,0.25));//F4132 |
| 8252 |
int enantio=0; |
| 8253 |
QString kep,nextli; |
| 8254 |
QTextDocument *document = editor->document(); |
| 8255 |
QTextCursor cursor = editor->textCursor(); |
| 8256 |
cursor.beginEditBlock (); |
| 8257 |
if ((!mole.cell.centered)&&(!mole.cell.centeric)){ |
| 8258 |
for (int i=0; i<mole.cell.trans.size(); i++){ |
| 8259 |
V3 t = V3(1,1,1) - mole.cell.trans.at(i); |
| 8260 |
t.x=fmod(t.x,1); |
| 8261 |
t.y=fmod(t.y,1); |
| 8262 |
t.z=fmod(t.z,1); |
| 8263 |
if (!(t==mole.cell.trans.at(i))) { |
| 8264 |
enantio++; |
| 8265 |
mole.cell.trans[i]=t; |
| 8266 |
} |
| 8267 |
|
| 8268 |
} |
| 8269 |
} |
| 8270 |
if (enantio){ |
| 8271 |
|
| 8272 |
editor->replace->setText("REM SYMM "); |
| 8273 |
editor->searchLE->setText("^SYMM "); |
| 8274 |
editor->replaceAll(); |
| 8275 |
cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); |
| 8276 |
cursor = document->find("REM SYMM",cursor); |
| 8277 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 8278 |
for (int i=1; i<mole.cell.symmops.size(); i++){ |
| 8279 |
cursor.insertText(QString("SYMM %1\n").arg(mole.symmcode2human(i))); |
| 8280 |
} |
| 8281 |
|
| 8282 |
cursor.insertText("REM enantiomorph space group. SYMM cards changed!\n"); |
| 8283 |
editor->searchLE->setText(""); |
| 8284 |
editor->replace->setText(""); |
| 8285 |
} |
| 8286 |
//qDebug("test %d\n",enantio); |
| 8287 |
V3 testP=V3(0.3234,0.2234,0.1234); |
| 8288 |
QList<V3> tps,ips; |
| 8289 |
Matrix inv(-1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,-1.0); |
| 8290 |
for (int n=0;n<mole.cell.symmops.size(); n++){ |
| 8291 |
V3 pt=mole.cell.symmops.at(n) * testP + mole.cell.trans.at(n); |
| 8292 |
ips.append(pt); |
| 8293 |
} |
| 8294 |
int kkk=0,jjj=0,mo=0; |
| 8295 |
if (mole.cell.centered) do{ |
| 8296 |
kkk=jjj=0; |
| 8297 |
tps.clear(); |
| 8298 |
for (int z=0; z<ips.size();z++){ |
| 8299 |
V3 pt=inv*ips.at(z)+moves.at(mo); |
| 8300 |
tps.append(pt); |
| 8301 |
} |
| 8302 |
double dk; |
| 8303 |
V3 prime,dp,D,floorD; |
| 8304 |
for (int i=0; i<tps.size();i++){ |
| 8305 |
for (int j=0; j<tps.size();j++){ |
| 8306 |
for (int n=0;n<mole.cell.symmops.size(); n++){ |
| 8307 |
prime=mole.cell.symmops.at(n) * tps.at(i) + mole.cell.trans.at(n); |
| 8308 |
D=prime - tps.at(j)+ V3(0.5,0.5,0.5) ; |
| 8309 |
floorD=V3(floor(D.x),floor(D.y),floor(D.z)); |
| 8310 |
dp=D - floorD - V3(0.5,0.5,0.5); |
| 8311 |
dk=mole.fl(dp.x,dp.y,dp.z); |
| 8312 |
if (dk<0.1) kkk++; |
| 8313 |
} |
| 8314 |
} |
| 8315 |
} |
| 8316 |
for (int i=0; i<ips.size();i++){ |
| 8317 |
for (int j=0; j<ips.size();j++){ |
| 8318 |
for (int n=0;n<mole.cell.symmops.size(); n++){ |
| 8319 |
prime=mole.cell.symmops.at(n) * ips.at(i) + mole.cell.trans.at(n); |
| 8320 |
D=prime - ips.at(j)+ V3(0.5,0.5,0.5) ; |
| 8321 |
floorD=V3(floor(D.x),floor(D.y),floor(D.z)); |
| 8322 |
dp=D - floorD - V3(0.5,0.5,0.5); |
| 8323 |
dk=mole.fl(dp.x,dp.y,dp.z); |
| 8324 |
if (dk<0.1) jjj++; |
| 8325 |
} |
| 8326 |
} |
| 8327 |
} |
| 8328 |
mo++; |
| 8329 |
}while (kkk-jjj); |
| 8330 |
if (mo) mo--; |
| 8331 |
//printf("Move : %g %g %g\n",moves.at(mo).x,moves.at(mo).y,moves.at(mo).z); |
| 8332 |
for (int i = 0; i < mole.asymm.size(); i++){ |
| 8333 |
V3 f = inv * mole.asymm.at(i).frac + moves.at(mo); |
| 8334 |
mole.asymm[i].frac=f; |
| 8335 |
mole.frac2kart(mole.asymm.at(i).frac,mole.asymm[i].pos); |
| 8336 |
|
| 8337 |
if (mole.asymm.at(i).an==-1) continue; |
| 8338 |
QString source,target; |
| 8339 |
source=mole.asymm.at(i).Label; |
| 8340 |
target=source.section(QString::fromUtf8("»"),0,0); |
| 8341 |
MyAtom ato=mole.asymm.at(i); |
| 8342 |
ato.Label=target; |
| 8343 |
ato.symmGroup=0; |
| 8344 |
ato.sg=0; |
| 8345 |
ato.scod=555;//the identity |
| 8346 |
ato.auidx=-1; |
| 8347 |
int that=mole.asymm.indexOf(ato); |
| 8348 |
if ((that>=mole.asymm.size())||(that<0)) return; |
| 8349 |
QString susu=mole.asymm.at(that).orginalLine; |
| 8350 |
cursor.movePosition(QTextCursor::Start); |
| 8351 |
cursor = document->find(susu,cursor); |
| 8352 |
if (mole.asymm.at(that).isIso){ |
| 8353 |
ato.ufiso_org=mole.asymm.at(that).ufiso_org; |
| 8354 |
kep=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8355 |
.arg(ato.Label.section('_',0,0),-5) |
| 8356 |
.arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) |
| 8357 |
.arg(ato.frac.x,10,'f',6) |
| 8358 |
.arg(ato.frac.y,10,'f',6) |
| 8359 |
.arg(ato.frac.z,10,'f',6) |
| 8360 |
.arg(mole.asymm.at(that).sof_org,9,'f',5) |
| 8361 |
.arg(ato.ufiso_org) |
| 8362 |
; |
| 8363 |
cursor.deleteChar(); |
| 8364 |
cursor.insertText(kep); |
| 8365 |
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); |
| 8366 |
ato.sof_org=mole.asymm.at(that).sof_org; |
| 8367 |
// printf("debug:iso sof==%g atom#%d mole.asymm.at(that).afixParent %d \n",mole.asymm.at(that).sof_org,that,mole.asymm.at(that).afixParent); |
| 8368 |
ato.uf= mole.asymm.at(that).uf; |
| 8369 |
ato.uc= mole.asymm.at(that).uc; |
| 8370 |
ato.isIso=true; |
| 8371 |
editor->wholeLine->setChecked(false); |
| 8372 |
editor->replaceNext(); |
| 8373 |
}else{ |
| 8374 |
kep=QString("%1 %2 %3 %4 %5 %6 %7 %8 ") |
| 8375 |
.arg(ato.Label.section('_',0,0),-5) |
| 8376 |
.arg(qMax(1,editor->sfac.indexOf(ato.an)+1)) |
| 8377 |
.arg(ato.frac.x,10,'f',6) |
| 8378 |
.arg(ato.frac.y,10,'f',6) |
| 8379 |
.arg(ato.frac.z,10,'f',6) |
| 8380 |
.arg(mole.asymm.at(that).sof_org,9,'f',5) |
| 8381 |
.arg(ato.uf.m11,9,'f',5) |
| 8382 |
.arg(ato.uf.m22,9,'f',5); |
| 8383 |
// printf("debug:anis sof==%g atom#%d\n",mole.asymm.at(that).sof_org,that); |
| 8384 |
ato.sof_org=mole.asymm.at(that).sof_org; |
| 8385 |
cursor.deleteChar(); |
| 8386 |
cursor.insertText(kep); |
| 8387 |
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); |
| 8388 |
cursor.movePosition(QTextCursor::Down); |
| 8389 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 8390 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8391 |
nextli=cursor.selectedText(); |
| 8392 |
cursor = document->find(nextli,cursor); |
| 8393 |
|
| 8394 |
cursor.deleteChar(); |
| 8395 |
cursor.insertText(QString(" %1 %2 %3 %4") |
| 8396 |
.arg(ato.uf.m33,9,'f',5) |
| 8397 |
.arg(ato.uf.m23,9,'f',5) |
| 8398 |
.arg(ato.uf.m13,9,'f',5) |
| 8399 |
.arg(ato.uf.m12,9,'f',5)); |
| 8400 |
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); |
| 8401 |
} |
| 8402 |
ato.orginalLine=kep.section("=",0,0); |
| 8403 |
mole.asymm[that]=ato; |
| 8404 |
} |
| 8405 |
|
| 8406 |
cursor = editor->textCursor(); |
| 8407 |
cursor.endEditBlock(); |
| 8408 |
|
| 8409 |
mole.showatoms.clear(); |
| 8410 |
mole.showbonds.clear(); |
| 8411 |
chgl->mol->showatoms.clear(); |
| 8412 |
chgl->mol->showbonds.clear(); |
| 8413 |
chgl->mol->selectedatoms.clear(); |
| 8414 |
for (int o=0; o<mole.asymm.size();o++) |
| 8415 |
mole.showatoms.append(mole.asymm[o]); |
| 8416 |
mole.sdmcompleter(); |
| 8417 |
mole.showbonds = |
| 8418 |
mole.connecting(mole.showatoms); |
| 8419 |
chgl->setMolecule(&mole); |
| 8420 |
loadMolInTest(); |
| 8421 |
|
| 8422 |
chgl->mol->selectedatoms.clear(); |
| 8423 |
|
| 8424 |
bool growYes=chgl->fuse->isVisible (); |
| 8425 |
chgl->mol->fuse(); |
| 8426 |
if (growYes) chgl->mol->grow(); |
| 8427 |
editor->searchLE->setText(""); |
| 8428 |
editor->hideSearch(); |
| 8429 |
|
| 8430 |
// printf("%d\n",__LINE__); |
| 8431 |
|
| 8432 |
loadMolInTest(); |
| 8433 |
chgl->update(); |
| 8434 |
update(); |
| 8435 |
|
| 8436 |
} |
| 8437 |
|
| 8438 |
void Window::addDissorderedMethyl(){//127 |
| 8439 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 8440 |
int i=0; |
| 8441 |
if (action) |
| 8442 |
i=action->data().toInt(); |
| 8443 |
else return; |
| 8444 |
if (i>mole.asymm.size()) return; |
| 8445 |
int warmalAtome=0; |
| 8446 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)warmalAtome++; |
| 8447 |
|
| 8448 |
chgl->disSelection(); |
| 8449 |
MyAtom htest,qtest; |
| 8450 |
QStringList alab; |
| 8451 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 8452 |
alab.append(mole.asymm.at(i).Label); |
| 8453 |
} |
| 8454 |
QString nn; |
| 8455 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 8456 |
htest.an=0; |
| 8457 |
htest.part=0; |
| 8458 |
htest.resiNr=0; |
| 8459 |
htest.hidden=0; |
| 8460 |
htest.symmGroup=0; |
| 8461 |
htest.sg=0; |
| 8462 |
htest.scod=555;//the identity |
| 8463 |
htest.auidx=-1; |
| 8464 |
htest.isIso=true; |
| 8465 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 8466 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 8467 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 8468 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 8469 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 8470 |
qtest=htest; |
| 8471 |
qtest.an=-1; |
| 8472 |
QTextDocument *document = editor->document(); |
| 8473 |
QTextCursor cursor = editor->textCursor(); |
| 8474 |
cursor.beginEditBlock (); |
| 8475 |
// !!!Neue Freie Variable anlegen!!! |
| 8476 |
cursor.movePosition(QTextCursor::End); |
| 8477 |
cursor = document->find("FVAR",cursor,QTextDocument::FindBackward); |
| 8478 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 8479 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8480 |
while (cursor.selectedText().endsWith("=")) { |
| 8481 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 8482 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8483 |
} |
| 8484 |
QString fvstr = cursor.selectedText().trimmed(); |
| 8485 |
fvstr.append(" 0.666 "); |
| 8486 |
fvar.append(0.667); |
| 8487 |
cursor.deleteChar(); |
| 8488 |
cursor.insertText(fvstr); |
| 8489 |
updateTieFreeVar(); |
| 8490 |
int frei=fvar.size(); |
| 8491 |
// !!!! |
| 8492 |
double xh[8]={ |
| 8493 |
0.98,//1 |
| 8494 |
0.97,//2 |
| 8495 |
0.96,//3 |
| 8496 |
0.93,//4 |
| 8497 |
1.10,//15 B |
| 8498 |
0.82,//8 O |
| 8499 |
0.93,//9 |
| 8500 |
0.93// 16 |
| 8501 |
}; |
| 8502 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0);//,b=V3(0,0,0),c=V3(0,0,0); |
| 8503 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos - mole.asymm.at(i).pos; |
| 8504 |
int ji,ki,li; |
| 8505 |
a=Normalize(a); |
| 8506 |
double jx,kx,lx,mx,my,mz; |
| 8507 |
double val[24],merg[4],wink=0,t=0,mt=0; |
| 8508 |
for (int z=0; z<4;z++) merg[z]=0; |
| 8509 |
if (fxle->n5){ |
| 8510 |
for (int z=0; z<24; z++){ |
| 8511 |
w=Normalize(V3(0,0,1)%a); |
| 8512 |
u=Normalize(w%a); |
| 8513 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8514 |
qtest.pos=v; |
| 8515 |
mole.kart2frac(v,v); |
| 8516 |
int zplu=0; |
| 8517 |
do { |
| 8518 |
jx=((zplu+v.x)*fxle->n1+0.5); |
| 8519 |
zplu++; |
| 8520 |
}while (jx<0); |
| 8521 |
zplu=0; |
| 8522 |
do { |
| 8523 |
kx=((zplu+v.y)*fxle->n2+0.5); |
| 8524 |
zplu++; |
| 8525 |
}while (kx<0); |
| 8526 |
zplu=0; |
| 8527 |
do { |
| 8528 |
lx=((zplu+v.z)*fxle->n3+0.5); |
| 8529 |
zplu++; |
| 8530 |
}while (lx<0); |
| 8531 |
mx=jx-floor(jx); |
| 8532 |
my=kx-floor(kx); |
| 8533 |
mz=lx-floor(lx); |
| 8534 |
ji=((int)jx)%fxle->n1;// |
| 8535 |
ki=((int)kx)%fxle->n2;// |
| 8536 |
li=((int)lx)%fxle->n3;// |
| 8537 |
merg[z%4]+=val[z]=( |
| 8538 |
(1-mx)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 8539 |
mx*fxle->datfo_fc[((ji+1)+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 8540 |
(1-my)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 8541 |
my*fxle->datfo_fc[(ji+fxle->n1*((ki+1)+li*fxle->n2))%fxle->n5]+ |
| 8542 |
(1-mz)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 8543 |
mz*fxle->datfo_fc[(ji+fxle->n1*(ki+(li+1)*fxle->n2))%fxle->n5])/3.0; |
| 8544 |
qtest.peakHeight=val[z]; |
| 8545 |
qtest.frac=v; |
| 8546 |
qtest.Label=QString("Q%1").arg(z,-3); |
| 8547 |
mole.pmin=qMin(mole.pmin, qtest.peakHeight); |
| 8548 |
mole.pmax=qMax(mole.pmax, qtest.peakHeight); |
| 8549 |
qpv->cutoff=0;//mole.pmin; |
| 8550 |
qpv->setMin(mole.pmin); |
| 8551 |
qpv->setMax(mole.pmax); |
| 8552 |
mole.asymm.append(qtest); |
| 8553 |
wink+=0.261799387799; |
| 8554 |
} |
| 8555 |
for (int z=0; z<4;z++) { |
| 8556 |
t =merg[(z+4)%4] ; |
| 8557 |
double x = t - merg[(z+5)%4]; |
| 8558 |
double u = t - merg[(z+3)%4]; |
| 8559 |
if (fmin(x,u)<0) continue; |
| 8560 |
double p=0.5*(u-x)/(u+x); |
| 8561 |
t=t+0.25*(p*(u-x)); |
| 8562 |
mt=(mt>t)?mt:t; |
| 8563 |
if (t<mt)continue; |
| 8564 |
wink=((double) z + p )*0.261799387799; |
| 8565 |
} |
| 8566 |
}else{ |
| 8567 |
int zzz=0; |
| 8568 |
int z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 8569 |
while ((z==i)&&(zzz<mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.size())) { |
| 8570 |
z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 8571 |
} |
| 8572 |
w=Normalize(V3(0,0,1)%a); |
| 8573 |
u=Normalize(w%a); |
| 8574 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8575 |
// if z == i then dieder() returns nan, because A in dieder gets (0,0,0) |
| 8576 |
V3 increm = V3(0.0, 0.0, 0.0); |
| 8577 |
if ( z == i ) { |
| 8578 |
increm = V3(0.00001, 0.00001, 0.00001); |
| 8579 |
} |
| 8580 |
wink=mole.dieder(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos+increm-mole.asymm.at(z).pos, |
| 8581 |
mole.asymm.at(i).pos-mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos, |
| 8582 |
v-mole.asymm.at(i).pos)/180.0*M_PI; |
| 8583 |
} |
| 8584 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8585 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 8586 |
htest.Label.replace(0,1,'H'); |
| 8587 |
int hindex=1; |
| 8588 |
QString nnn=htest.Label; |
| 8589 |
QString ann=htest.Label; |
| 8590 |
do { |
| 8591 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 8592 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 8593 |
if (htest.resiNr) |
| 8594 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8595 |
.arg(nnn) |
| 8596 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8597 |
else nn=nnn; |
| 8598 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8599 |
hindex++; |
| 8600 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8601 |
htest.Label=nnn; |
| 8602 |
alab.append(nn); |
| 8603 |
|
| 8604 |
htest.part=mole.asymm.at(i).part; |
| 8605 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 8606 |
htest.isIso=true; |
| 8607 |
htest.ufiso_org=QString("-1.5"); |
| 8608 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.5; |
| 8609 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 8610 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 8611 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 8612 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 8613 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 8614 |
htest.pos=v; |
| 8615 |
mole.kart2frac(htest.pos,htest.frac); |
| 8616 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8617 |
.arg(htest.Label) |
| 8618 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8619 |
.arg(htest.frac.x,9,'f',5) |
| 8620 |
.arg(htest.frac.y,9,'f',5) |
| 8621 |
.arg(htest.frac.z,9,'f',5) |
| 8622 |
.arg(mole.asymm.at(i).sof+10*frei) |
| 8623 |
.arg("-1.5"); |
| 8624 |
mole.asymm.append(htest); |
| 8625 |
wink+=1.04719755119; |
| 8626 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8627 |
hindex+=2; |
| 8628 |
do { |
| 8629 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 8630 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 8631 |
if (htest.resiNr) |
| 8632 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8633 |
.arg(nnn) |
| 8634 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8635 |
else nn=nnn; |
| 8636 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8637 |
hindex++; |
| 8638 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8639 |
hindex-=3; |
| 8640 |
htest.Label=nnn; |
| 8641 |
alab.append(nn); |
| 8642 |
htest.pos=v; |
| 8643 |
mole.kart2frac(htest.pos,htest.frac); |
| 8644 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8645 |
.arg(htest.Label) |
| 8646 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8647 |
.arg(htest.frac.x,9,'f',5) |
| 8648 |
.arg(htest.frac.y,9,'f',5) |
| 8649 |
.arg(htest.frac.z,9,'f',5) |
| 8650 |
.arg(-1*(mole.asymm.at(i).sof+10*frei)) |
| 8651 |
.arg("-1.5"); |
| 8652 |
mole.asymm.append(htest); |
| 8653 |
wink+=1.04719755119; |
| 8654 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8655 |
do { |
| 8656 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 8657 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 8658 |
if (htest.resiNr) |
| 8659 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8660 |
.arg(nnn) |
| 8661 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8662 |
else nn=nnn; |
| 8663 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8664 |
hindex++; |
| 8665 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8666 |
htest.Label=nnn; |
| 8667 |
hindex+=2; |
| 8668 |
alab.append(nn); |
| 8669 |
htest.pos=v; |
| 8670 |
mole.kart2frac(htest.pos,htest.frac); |
| 8671 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8672 |
.arg(htest.Label) |
| 8673 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8674 |
.arg(htest.frac.x,9,'f',5) |
| 8675 |
.arg(htest.frac.y,9,'f',5) |
| 8676 |
.arg(htest.frac.z,9,'f',5) |
| 8677 |
.arg(mole.asymm.at(i).sof+10*frei) |
| 8678 |
.arg("-1.5"); |
| 8679 |
mole.asymm.append(htest); |
| 8680 |
wink+=1.04719755119; |
| 8681 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8682 |
do { |
| 8683 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 8684 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 8685 |
if (htest.resiNr) |
| 8686 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8687 |
.arg(nnn) |
| 8688 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8689 |
else nn=nnn; |
| 8690 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8691 |
hindex++; |
| 8692 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8693 |
htest.Label=nnn; |
| 8694 |
alab.append(nn); |
| 8695 |
htest.pos=v; |
| 8696 |
hindex-=3; |
| 8697 |
mole.kart2frac(htest.pos,htest.frac); |
| 8698 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8699 |
.arg(htest.Label) |
| 8700 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8701 |
.arg(htest.frac.x,9,'f',5) |
| 8702 |
.arg(htest.frac.y,9,'f',5) |
| 8703 |
.arg(htest.frac.z,9,'f',5) |
| 8704 |
.arg(-1*(mole.asymm.at(i).sof+10*frei)) |
| 8705 |
.arg("-1.5"); |
| 8706 |
mole.asymm.append(htest); |
| 8707 |
wink+=1.04719755119; |
| 8708 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8709 |
do { |
| 8710 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 8711 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 8712 |
if (htest.resiNr) |
| 8713 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8714 |
.arg(nnn) |
| 8715 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8716 |
else nn=nnn; |
| 8717 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8718 |
hindex++; |
| 8719 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8720 |
htest.Label=nnn; |
| 8721 |
alab.append(nn); |
| 8722 |
htest.pos=v; |
| 8723 |
hindex+=2; |
| 8724 |
mole.kart2frac(htest.pos,htest.frac); |
| 8725 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8726 |
.arg(htest.Label) |
| 8727 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8728 |
.arg(htest.frac.x,9,'f',5) |
| 8729 |
.arg(htest.frac.y,9,'f',5) |
| 8730 |
.arg(htest.frac.z,9,'f',5) |
| 8731 |
.arg(mole.asymm.at(i).sof+10*frei) |
| 8732 |
.arg("-1.5"); |
| 8733 |
mole.asymm.append(htest); |
| 8734 |
wink+=1.04719755119; |
| 8735 |
v=(-(xh[2])*0.33333*a)+ mole.asymm.at(i).pos+(xh[2])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 8736 |
do { |
| 8737 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 8738 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 8739 |
if (htest.resiNr) |
| 8740 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8741 |
.arg(nnn) |
| 8742 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8743 |
else nn=nnn; |
| 8744 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8745 |
hindex++; |
| 8746 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8747 |
htest.Label=nnn; |
| 8748 |
alab.append(nn); |
| 8749 |
htest.pos=v; |
| 8750 |
mole.kart2frac(htest.pos,htest.frac); |
| 8751 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8752 |
.arg(htest.Label) |
| 8753 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8754 |
.arg(htest.frac.x,9,'f',5) |
| 8755 |
.arg(htest.frac.y,9,'f',5) |
| 8756 |
.arg(htest.frac.z,9,'f',5) |
| 8757 |
.arg(-1*(mole.asymm.at(i).sof+10*frei)) |
| 8758 |
.arg("-1.5"); |
| 8759 |
mole.asymm.append(htest); |
| 8760 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 8761 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 8762 |
cursor.movePosition(QTextCursor::Start); |
| 8763 |
cursor = document->find(label,cursor); |
| 8764 |
if (cursor.isNull()){ |
| 8765 |
cursor = editor->textCursor(); |
| 8766 |
cursor.movePosition(QTextCursor::Start); |
| 8767 |
label.chop(10); |
| 8768 |
cursor = document->find(label,cursor); |
| 8769 |
if (cursor.isNull()) { |
| 8770 |
cursor = editor->textCursor(); |
| 8771 |
} |
| 8772 |
} |
| 8773 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 8774 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8775 |
while (cursor.selectedText().endsWith("=")) { |
| 8776 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 8777 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8778 |
} |
| 8779 |
cursor.clearSelection(); |
| 8780 |
cursor.movePosition(QTextCursor::Down); |
| 8781 |
cursor.insertText(QString("AFIX 127\n%1\n%2\n%3\n%5\n%6\n%7\nAFIX %4\n") |
| 8782 |
.arg(mole.asymm.at(mole.asymm.size()-6).orginalLine) |
| 8783 |
.arg(mole.asymm.at(mole.asymm.size()-4).orginalLine) |
| 8784 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 8785 |
.arg(mole.afix5(i)) |
| 8786 |
.arg(mole.asymm.at(mole.asymm.size()-5).orginalLine)//- |
| 8787 |
.arg(mole.asymm.at(mole.asymm.size()-3).orginalLine)//- |
| 8788 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine)//- |
| 8789 |
); |
| 8790 |
|
| 8791 |
cursor.endEditBlock(); |
| 8792 |
int jetztAtome=0; |
| 8793 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 8794 |
actionHFix->setDisabled(true); |
| 8795 |
fuse(); |
| 8796 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 8797 |
infoKanalNews(info); |
| 8798 |
} |
| 8799 |
|
| 8800 |
void Window::addH43(){//43 |
| 8801 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 8802 |
int i=0; |
| 8803 |
if (action) |
| 8804 |
i=action->data().toInt(); |
| 8805 |
else return; |
| 8806 |
if (i>mole.asymm.size()) return; |
| 8807 |
if (mole.knoepfe.at(i).neighbors.size()!=2)return;//we need 2 non h neighbors |
| 8808 |
int warmalAtome=0; |
| 8809 |
for (int j=0; j<mole.asymm.size();j++) if (mole.asymm.at(j).an>=0)warmalAtome++; |
| 8810 |
QStringList alab; |
| 8811 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 8812 |
alab.append(mole.asymm.at(i).Label); |
| 8813 |
} |
| 8814 |
QString nn; |
| 8815 |
double nh= (mole.asymm.at(i).an==6) ? 0.07 : 0; |
| 8816 |
|
| 8817 |
chgl->disSelection(); |
| 8818 |
MyAtom htest,qtest; |
| 8819 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 8820 |
htest.an=0; |
| 8821 |
htest.part=0; |
| 8822 |
htest.resiNr=0; |
| 8823 |
htest.hidden=0; |
| 8824 |
htest.symmGroup=0; |
| 8825 |
htest.sg=0; |
| 8826 |
htest.scod=555;//the identity |
| 8827 |
htest.auidx=-1; |
| 8828 |
htest.isIso=true; |
| 8829 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 8830 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 8831 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 8832 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 8833 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 8834 |
qtest=htest; |
| 8835 |
qtest.an=-1; |
| 8836 |
QTextDocument *document = editor->document(); |
| 8837 |
QTextCursor cursor = editor->textCursor(); |
| 8838 |
cursor.beginEditBlock (); |
| 8839 |
double xh[8]={ |
| 8840 |
0.98,//1 |
| 8841 |
0.97,//2 |
| 8842 |
0.96,//3 |
| 8843 |
0.93,//4 |
| 8844 |
1.10,//15 B |
| 8845 |
0.82,//8 O |
| 8846 |
0.93,//9 |
| 8847 |
0.93// 16 |
| 8848 |
}; |
| 8849 |
|
| 8850 |
double angle=0; |
| 8851 |
V3 a=V3(0,0,0),b=V3(0,0,0),c=V3(0,0,0); |
| 8852 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0) ).pos - mole.asymm.at(i).pos; |
| 8853 |
b = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(1) ).pos - mole.asymm.at(i).pos; |
| 8854 |
a = c = Normalize(a) ; |
| 8855 |
c = c+ (b= Normalize(b)); |
| 8856 |
angle=mole.winkel(a,b); |
| 8857 |
c = Normalize(c); |
| 8858 |
if (angle<160) { |
| 8859 |
c = (-(xh[3]-nh) * c)+mole.asymm.at(i).pos; |
| 8860 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 8861 |
htest.part=mole.asymm.at(i).part; |
| 8862 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 8863 |
htest.Label.replace(0,1,'H'); |
| 8864 |
int hindex=0; |
| 8865 |
QString nnn=htest.Label; |
| 8866 |
do { |
| 8867 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 8868 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 8869 |
if (htest.resiNr) |
| 8870 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 8871 |
.arg(nnn) |
| 8872 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 8873 |
else nn=nnn; |
| 8874 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 8875 |
hindex++; |
| 8876 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 8877 |
htest.Label=nnn; |
| 8878 |
alab.append(nn); |
| 8879 |
htest.isIso=true; |
| 8880 |
htest.ufiso_org=QString("-1.2"); |
| 8881 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 8882 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 8883 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 8884 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 8885 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 8886 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 8887 |
htest.pos=c; |
| 8888 |
mole.kart2frac(htest.pos,htest.frac); |
| 8889 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 8890 |
.arg(htest.Label) |
| 8891 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 8892 |
.arg(htest.frac.x,9,'f',5) |
| 8893 |
.arg(htest.frac.y,9,'f',5) |
| 8894 |
.arg(htest.frac.z,9,'f',5) |
| 8895 |
.arg(mole.asymm.at(i).sof_org) |
| 8896 |
.arg("-1.2"); |
| 8897 |
mole.asymm.append(htest); |
| 8898 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 8899 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 8900 |
cursor.movePosition(QTextCursor::Start); |
| 8901 |
cursor = document->find(label,cursor); |
| 8902 |
if (cursor.isNull()){ |
| 8903 |
cursor = editor->textCursor(); |
| 8904 |
cursor.movePosition(QTextCursor::Start); |
| 8905 |
label.chop(10); |
| 8906 |
cursor = document->find(label,cursor); |
| 8907 |
if (cursor.isNull()) { |
| 8908 |
cursor = editor->textCursor(); |
| 8909 |
} |
| 8910 |
} |
| 8911 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 8912 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8913 |
while (cursor.selectedText().endsWith("=")) { |
| 8914 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 8915 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 8916 |
} |
| 8917 |
cursor.clearSelection(); |
| 8918 |
cursor.movePosition(QTextCursor::Down); |
| 8919 |
cursor.insertText(QString("AFIX 43\n%1\nAFIX %2\n") |
| 8920 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 8921 |
.arg(mole.afix5(i))); |
| 8922 |
}//angle |
| 8923 |
cursor.endEditBlock(); |
| 8924 |
int jetztAtome=0; |
| 8925 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 8926 |
actionHFix->setDisabled(true); |
| 8927 |
fuse(); |
| 8928 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 8929 |
infoKanalNews(info); |
| 8930 |
}//43 |
| 8931 |
|
| 8932 |
void Window::addH23(){//23 |
| 8933 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 8934 |
int i=0; |
| 8935 |
if (action) |
| 8936 |
i=action->data().toInt(); |
| 8937 |
else return; |
| 8938 |
if (i>mole.asymm.size()) return; |
| 8939 |
if (mole.knoepfe.at(i).neighbors.size()!=2)return;//we need 2 non h neighbors |
| 8940 |
int warmalAtome=0; |
| 8941 |
for (int j=0; j<mole.asymm.size();j++) if (mole.asymm.at(j).an>=0)warmalAtome++; |
| 8942 |
QStringList alab; |
| 8943 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 8944 |
alab.append(mole.asymm.at(i).Label); |
| 8945 |
} |
| 8946 |
QString nn; |
| 8947 |
double nh= (mole.asymm.at(i).an==6) ? 0.07 : 0; |
| 8948 |
|
| 8949 |
chgl->disSelection(); |
| 8950 |
MyAtom htest,qtest; |
| 8951 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 8952 |
htest.an=0; |
| 8953 |
htest.part=0; |
| 8954 |
htest.resiNr=0; |
| 8955 |
htest.hidden=0; |
| 8956 |
htest.symmGroup=0; |
| 8957 |
htest.sg=0; |
| 8958 |
htest.scod=555;//the identity |
| 8959 |
htest.auidx=-1; |
| 8960 |
htest.isIso=true; |
| 8961 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 8962 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 8963 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 8964 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 8965 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 8966 |
qtest=htest; |
| 8967 |
qtest.an=-1; |
| 8968 |
QTextDocument *document = editor->document(); |
| 8969 |
QTextCursor cursor = editor->textCursor(); |
| 8970 |
cursor.beginEditBlock (); |
| 8971 |
double xh[8]={ |
| 8972 |
0.98,//1 |
| 8973 |
0.97,//2 |
| 8974 |
0.96,//3 |
| 8975 |
0.93,//4 |
| 8976 |
1.10,//15 B |
| 8977 |
0.82,//8 O |
| 8978 |
0.93,//9 |
| 8979 |
0.93// 16 |
| 8980 |
}; |
| 8981 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0),b=V3(0,0,0),c=V3(0,0,0); |
| 8982 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0) ).pos - mole.asymm.at(i).pos; |
| 8983 |
b = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(1) ).pos - mole.asymm.at(i).pos; |
| 8984 |
a = c = Normalize(a) ; |
| 8985 |
c = c+ (b= Normalize(b)); |
| 8986 |
double angle=mole.winkel(a,b); |
| 8987 |
c = Normalize(c); |
| 8988 |
if (angle<160) { |
| 8989 |
|
| 8990 |
w = Normalize(a); |
| 8991 |
u = Normalize(b); |
| 8992 |
double si=1.0376-0.0346*Norm(w-u); //=1.91063323625-((acos(u*w)-1.91063323625)/5.0);//-1.91063323625 = 109.47 grad ; 3.7 empirischer Wert |
| 8993 |
c = (-cos(si)*(xh[1]-nh) * c); |
| 8994 |
v = sin(si) *(xh[1]-nh) * Normalize(c%a); |
| 8995 |
a = mole.asymm.at(i).pos + c + v; |
| 8996 |
b = mole.asymm.at(i).pos + c - v; |
| 8997 |
c = c + mole.asymm.at(i).pos; |
| 8998 |
|
| 8999 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 9000 |
htest.part=mole.asymm.at(i).part; |
| 9001 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 9002 |
htest.Label.replace(0,1,'H'); |
| 9003 |
int hindex=1; |
| 9004 |
QString nnn=htest.Label; |
| 9005 |
QString ann=htest.Label; |
| 9006 |
do { |
| 9007 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 9008 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 9009 |
if (htest.resiNr) |
| 9010 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9011 |
.arg(nnn) |
| 9012 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9013 |
else nn=nnn; |
| 9014 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9015 |
hindex++; |
| 9016 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9017 |
htest.Label=nnn; |
| 9018 |
alab.append(nn); |
| 9019 |
htest.isIso=true; |
| 9020 |
htest.ufiso_org=QString("-1.2"); |
| 9021 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 9022 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 9023 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 9024 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 9025 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 9026 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 9027 |
htest.pos=a; |
| 9028 |
mole.kart2frac(htest.pos,htest.frac); |
| 9029 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9030 |
.arg(htest.Label) |
| 9031 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9032 |
.arg(htest.frac.x,9,'f',5) |
| 9033 |
.arg(htest.frac.y,9,'f',5) |
| 9034 |
.arg(htest.frac.z,9,'f',5) |
| 9035 |
.arg(mole.asymm.at(i).sof_org) |
| 9036 |
.arg("-1.2"); |
| 9037 |
mole.asymm.append(htest); |
| 9038 |
nnn=ann;//pevent HnAB labels |
| 9039 |
do { |
| 9040 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 9041 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 9042 |
if (htest.resiNr) |
| 9043 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9044 |
.arg(nnn) |
| 9045 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9046 |
else nn=nnn; |
| 9047 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9048 |
hindex++; |
| 9049 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9050 |
htest.Label=nnn; |
| 9051 |
alab.append(nn); |
| 9052 |
htest.pos=b; |
| 9053 |
mole.kart2frac(htest.pos,htest.frac); |
| 9054 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9055 |
.arg(htest.Label) |
| 9056 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9057 |
.arg(htest.frac.x,9,'f',5) |
| 9058 |
.arg(htest.frac.y,9,'f',5) |
| 9059 |
.arg(htest.frac.z,9,'f',5) |
| 9060 |
.arg(mole.asymm.at(i).sof_org) |
| 9061 |
.arg("-1.2"); |
| 9062 |
mole.asymm.append(htest); |
| 9063 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 9064 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 9065 |
cursor.movePosition(QTextCursor::Start); |
| 9066 |
cursor = document->find(label,cursor); |
| 9067 |
if (cursor.isNull()){ |
| 9068 |
cursor = editor->textCursor(); |
| 9069 |
cursor.movePosition(QTextCursor::Start); |
| 9070 |
label.chop(10); |
| 9071 |
cursor = document->find(label,cursor); |
| 9072 |
if (cursor.isNull()) { |
| 9073 |
cursor = editor->textCursor(); |
| 9074 |
} |
| 9075 |
} |
| 9076 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 9077 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9078 |
while (cursor.selectedText().endsWith("=")) { |
| 9079 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 9080 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9081 |
} |
| 9082 |
cursor.clearSelection(); |
| 9083 |
cursor.movePosition(QTextCursor::Down); |
| 9084 |
cursor.insertText(QString("AFIX 23\n%1\n%2\nAFIX %3\n") |
| 9085 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 9086 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 9087 |
.arg(mole.afix5(i))); |
| 9088 |
}//angle |
| 9089 |
cursor.endEditBlock(); |
| 9090 |
int jetztAtome=0; |
| 9091 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 9092 |
actionHFix->setDisabled(true); |
| 9093 |
fuse(); |
| 9094 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 9095 |
infoKanalNews(info); |
| 9096 |
|
| 9097 |
}//23 |
| 9098 |
|
| 9099 |
void Window::addH93(){ |
| 9100 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 9101 |
int idx=0; |
| 9102 |
if (action) |
| 9103 |
idx=action->data().toInt(); |
| 9104 |
else return; |
| 9105 |
if (idx>mole.asymm.size()) return; |
| 9106 |
if (mole.knoepfe.at(idx).neighbors.size()!=1)return;//we need 1 non h neighbors |
| 9107 |
int warmalAtome=0; |
| 9108 |
for (int jj=0; jj<mole.asymm.size();jj++) if (mole.asymm.at(jj).an>=0)warmalAtome++; |
| 9109 |
QStringList alab; |
| 9110 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 9111 |
alab.append(mole.asymm.at(i).Label); |
| 9112 |
} |
| 9113 |
QString nn; |
| 9114 |
double nh= (mole.asymm.at(idx).an==6) ? 0.07 : 0; |
| 9115 |
|
| 9116 |
chgl->disSelection(); |
| 9117 |
MyAtom htest,qtest; |
| 9118 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 9119 |
htest.an=0; |
| 9120 |
htest.part=0; |
| 9121 |
htest.resiNr=0; |
| 9122 |
htest.hidden=0; |
| 9123 |
htest.symmGroup=0; |
| 9124 |
htest.sg=0; |
| 9125 |
htest.scod=555;//the identity |
| 9126 |
htest.auidx=-1; |
| 9127 |
htest.isIso=true; |
| 9128 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 9129 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 9130 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 9131 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 9132 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 9133 |
qtest=htest; |
| 9134 |
qtest.an=-1; |
| 9135 |
QTextDocument *document = editor->document(); |
| 9136 |
QTextCursor cursor = editor->textCursor(); |
| 9137 |
cursor.beginEditBlock (); |
| 9138 |
double xh[8]={ |
| 9139 |
0.98,//1 |
| 9140 |
0.97,//2 |
| 9141 |
0.96,//3 |
| 9142 |
0.93,//4 |
| 9143 |
1.10,//15 B |
| 9144 |
0.82,//8 O |
| 9145 |
0.93,//9 |
| 9146 |
0.93// 16 |
| 9147 |
}; |
| 9148 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0),a=V3(0,0,0);//,b=V3(0,0,0),c=V3(0,0,0); |
| 9149 |
a = mole.showatoms.at(mole.knoepfe.at(idx).neighbors.at(0)).pos - mole.asymm.at(idx).pos; |
| 9150 |
int j,k,l; |
| 9151 |
a=Normalize(a); |
| 9152 |
double jx,kx,lx,mx,my,mz; |
| 9153 |
double val[24],merg[12],wink=0,t=0,mt=0; |
| 9154 |
if (fxle->n5){ |
| 9155 |
for (int z=0; z<12;z++) merg[z]=0; |
| 9156 |
for (int z=0; z<24; z++){ |
| 9157 |
wink=z*0.261799387799; |
| 9158 |
w=Normalize(V3(0,0,1)%a); |
| 9159 |
u=Normalize(w%a); |
| 9160 |
v=(-(xh[6]-nh)*0.33333*a)+ mole.asymm.at(idx).pos+(xh[6]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9161 |
qtest.pos=v; |
| 9162 |
mole.kart2frac(v,v); |
| 9163 |
jx=(v.x>0)?(v.x*fxle->n1+0.5):((1.0+v.x)*fxle->n1+0.5); |
| 9164 |
kx=(v.y>0)?(v.y*fxle->n2+0.5):((1.0+v.y)*fxle->n2+0.5); |
| 9165 |
lx=(v.z>0)?(v.z*fxle->n3+0.5):((1.0+v.z)*fxle->n3+0.5); |
| 9166 |
mx=jx-floor(jx); |
| 9167 |
my=kx-floor(kx); |
| 9168 |
mz=lx-floor(lx); |
| 9169 |
j=((int)jx)%fxle->n1;// |
| 9170 |
k=((int)kx)%fxle->n2;// |
| 9171 |
l=((int)lx)%fxle->n3;// |
| 9172 |
merg[z%12]+=val[z]=( |
| 9173 |
(1-mx)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 9174 |
mx*fxle->datfo_fc[((j+1)+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 9175 |
(1-my)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 9176 |
my*fxle->datfo_fc[(j+fxle->n1*((k+1)+l*fxle->n2))%fxle->n5]+ |
| 9177 |
(1-mz)*fxle->datfo_fc[(j+fxle->n1*(k+l*fxle->n2))%fxle->n5]+ |
| 9178 |
mz*fxle->datfo_fc[(j+fxle->n1*(k+(l+1)*fxle->n2))%fxle->n5])/3.0; |
| 9179 |
qtest.peakHeight=val[z]; |
| 9180 |
qtest.frac=v; |
| 9181 |
qtest.Label=QString("Q%1").arg(z+100); |
| 9182 |
mole.pmin=qMin(mole.pmin, qtest.peakHeight); |
| 9183 |
mole.pmax=qMax(mole.pmax, qtest.peakHeight); |
| 9184 |
qpv->cutoff=0;//mole.pmin; |
| 9185 |
qpv->setMin(mole.pmin); |
| 9186 |
qpv->setMax(mole.pmax); |
| 9187 |
mole.asymm.append(qtest); |
| 9188 |
} |
| 9189 |
for (int z=0; z<12;z++) { |
| 9190 |
t =merg[(z+12)%12] ; |
| 9191 |
double x = t - merg[(z+13)%12]; |
| 9192 |
double u = t - merg[(z+11)%12]; |
| 9193 |
if (fmin(x,u)<0) continue; |
| 9194 |
double p=0.5*(u-x)/(u+x); |
| 9195 |
t=t+0.25*(p*(u-x)); |
| 9196 |
mt=(mt>t)?mt:t; |
| 9197 |
if (t<mt)continue; |
| 9198 |
wink=((double) z + p )*0.261799387799; |
| 9199 |
|
| 9200 |
///////////////// |
| 9201 |
} |
| 9202 |
}else{ |
| 9203 |
int zzz=0; |
| 9204 |
int z=mole.knoepfe.at(mole.knoepfe.at(idx).neighbors.at(0)).neighbors.at(zzz++); |
| 9205 |
while ((z==idx)&&(zzz<mole.knoepfe.at(mole.knoepfe.at(idx).neighbors.at(0)).neighbors.size())) |
| 9206 |
z=mole.knoepfe.at(mole.knoepfe.at(idx).neighbors.at(0)).neighbors.at(zzz++); |
| 9207 |
w=Normalize(V3(0,0,1)%a); |
| 9208 |
u=Normalize(w%a); |
| 9209 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(idx).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9210 |
// if z == i then dieder() returns nan, because A in dieder gets (0,0,0) |
| 9211 |
V3 increm = V3(0.0, 0.0, 0.0); |
| 9212 |
if ( z == idx ) { |
| 9213 |
increm = V3(0.00001, 0.00001, 0.00001); |
| 9214 |
} |
| 9215 |
wink=mole.dieder(mole.showatoms.at(mole.knoepfe.at(idx).neighbors.at(0)).pos+increm-mole.asymm.at(z).pos, |
| 9216 |
mole.asymm.at(idx).pos-mole.showatoms.at(mole.knoepfe.at(idx).neighbors.at(0)).pos, |
| 9217 |
v-mole.asymm.at(idx).pos)/180.0*M_PI; |
| 9218 |
|
| 9219 |
} |
| 9220 |
|
| 9221 |
v=(-(xh[6]-nh)*0.5*a)+ mole.asymm.at(idx).pos+(xh[6]-nh)*0.866025403784*(sin(wink)*u+cos(wink)*w); |
| 9222 |
htest.Label=mole.asymm.at(idx).Label.section('_',0,0); |
| 9223 |
htest.part=mole.asymm.at(idx).part; |
| 9224 |
htest.resiNr=mole.asymm.at(idx).resiNr; |
| 9225 |
htest.Label.replace(0,1,'H'); |
| 9226 |
int hindex=1; |
| 9227 |
QString nnn=htest.Label; |
| 9228 |
QString baslab=htest.Label; |
| 9229 |
do { |
| 9230 |
htest.Label=baslab; |
| 9231 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 9232 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 9233 |
if (htest.resiNr) |
| 9234 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9235 |
.arg(nnn) |
| 9236 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9237 |
else nn=nnn; |
| 9238 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9239 |
hindex++; |
| 9240 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9241 |
htest.Label=nnn; |
| 9242 |
alab.append(nn); |
| 9243 |
htest.isIso=true; |
| 9244 |
htest.ufiso_org=QString("-1.2"); |
| 9245 |
double uIso = mole.ueq(mole.asymm.at(idx).uf)*1.2; |
| 9246 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 9247 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 9248 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 9249 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 9250 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 9251 |
htest.pos=v; |
| 9252 |
mole.kart2frac(htest.pos,htest.frac); |
| 9253 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9254 |
.arg(htest.Label) |
| 9255 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9256 |
.arg(htest.frac.x,9,'f',5) |
| 9257 |
.arg(htest.frac.y,9,'f',5) |
| 9258 |
.arg(htest.frac.z,9,'f',5) |
| 9259 |
.arg(mole.asymm.at(idx).sof_org) |
| 9260 |
.arg("-1.2"); |
| 9261 |
mole.asymm.append(htest); |
| 9262 |
wink+=3.14159265359; |
| 9263 |
v=(-(xh[6]-nh)*0.5*a)+ mole.asymm.at(idx).pos+(xh[6]-nh)*0.866025403784*(sin(wink)*u+cos(wink)*w); |
| 9264 |
do { |
| 9265 |
htest.Label=baslab; |
| 9266 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 9267 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 9268 |
if (htest.resiNr) |
| 9269 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9270 |
.arg(nnn) |
| 9271 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9272 |
else nn=nnn; |
| 9273 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9274 |
hindex++; |
| 9275 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9276 |
htest.Label=nnn; |
| 9277 |
alab.append(nn); |
| 9278 |
htest.pos=v; |
| 9279 |
mole.kart2frac(htest.pos,htest.frac); |
| 9280 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9281 |
.arg(htest.Label) |
| 9282 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9283 |
.arg(htest.frac.x,9,'f',5) |
| 9284 |
.arg(htest.frac.y,9,'f',5) |
| 9285 |
.arg(htest.frac.z,9,'f',5) |
| 9286 |
.arg(mole.asymm.at(idx).sof_org) |
| 9287 |
.arg("-1.2"); |
| 9288 |
mole.asymm.append(htest); |
| 9289 |
|
| 9290 |
QString label = mole.showatoms.at(idx).orginalLine.left(80).trimmed(); |
| 9291 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 9292 |
cursor.movePosition(QTextCursor::Start); |
| 9293 |
cursor = document->find(label,cursor); |
| 9294 |
if (cursor.isNull()){ |
| 9295 |
cursor = editor->textCursor(); |
| 9296 |
cursor.movePosition(QTextCursor::Start); |
| 9297 |
label.chop(10); |
| 9298 |
cursor = document->find(label,cursor); |
| 9299 |
if (cursor.isNull()) { |
| 9300 |
cursor = editor->textCursor(); |
| 9301 |
} |
| 9302 |
} |
| 9303 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 9304 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9305 |
while (cursor.selectedText().endsWith("=")) { |
| 9306 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 9307 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9308 |
} |
| 9309 |
cursor.clearSelection(); |
| 9310 |
cursor.movePosition(QTextCursor::Down); |
| 9311 |
cursor.insertText(QString("AFIX 93\n%1\n%2\nAFIX %3\n") |
| 9312 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 9313 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 9314 |
.arg(mole.afix5(idx)) |
| 9315 |
); |
| 9316 |
|
| 9317 |
|
| 9318 |
|
| 9319 |
cursor.endEditBlock(); |
| 9320 |
int jetztAtome=0; |
| 9321 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 9322 |
actionHFix->setDisabled(true); |
| 9323 |
fuse(); |
| 9324 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 9325 |
infoKanalNews(info); |
| 9326 |
}//93 |
| 9327 |
|
| 9328 |
void Window::addH163(){ |
| 9329 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 9330 |
int i=0; |
| 9331 |
if (action) |
| 9332 |
i=action->data().toInt(); |
| 9333 |
else return; |
| 9334 |
if (i>mole.asymm.size()) return; |
| 9335 |
if (mole.knoepfe.at(i).neighbors.size()!=1)return;//we need 1 non h neighbors |
| 9336 |
int warmalAtome=0; |
| 9337 |
for (int j=0; j<mole.asymm.size();j++) if (mole.asymm.at(j).an>=0)warmalAtome++; |
| 9338 |
QStringList alab; |
| 9339 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 9340 |
alab.append(mole.asymm.at(i).Label); |
| 9341 |
} |
| 9342 |
QString nn; |
| 9343 |
double nh= (mole.asymm.at(i).an==6) ? 0.07 : 0; |
| 9344 |
|
| 9345 |
chgl->disSelection(); |
| 9346 |
MyAtom htest,qtest; |
| 9347 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 9348 |
htest.an=0; |
| 9349 |
htest.part=0; |
| 9350 |
htest.resiNr=0; |
| 9351 |
htest.hidden=0; |
| 9352 |
htest.symmGroup=0; |
| 9353 |
htest.sg=0; |
| 9354 |
htest.scod=555;//the identity |
| 9355 |
htest.auidx=-1; |
| 9356 |
htest.isIso=true; |
| 9357 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 9358 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 9359 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 9360 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 9361 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 9362 |
qtest=htest; |
| 9363 |
qtest.an=-1; |
| 9364 |
QTextDocument *document = editor->document(); |
| 9365 |
QTextCursor cursor = editor->textCursor(); |
| 9366 |
cursor.beginEditBlock (); |
| 9367 |
double xh[8]={ |
| 9368 |
0.98,//1 |
| 9369 |
0.97,//2 |
| 9370 |
0.96,//3 |
| 9371 |
0.93,//4 |
| 9372 |
1.10,//15 B |
| 9373 |
0.82,//8 O |
| 9374 |
0.93,//9 |
| 9375 |
0.93// 16 |
| 9376 |
}; |
| 9377 |
V3 v=V3(0,0,0),a=V3(0,0,0); |
| 9378 |
a = Normalize(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos - mole.asymm.at(i).pos); |
| 9379 |
v=(-(xh[7]-nh)*a)+ mole.asymm.at(i).pos; |
| 9380 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 9381 |
htest.part=mole.asymm.at(i).part; |
| 9382 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 9383 |
htest.Label.replace(0,1,'H'); |
| 9384 |
int hindex=0; |
| 9385 |
QString nnn=htest.Label; |
| 9386 |
do { |
| 9387 |
if (hindex) nnn=htest.Label.left(3).append(QString::number(hindex+9,36)); |
| 9388 |
if (nnn.size()>4) nnn=htest.Label.left(2).append(QString::number(hindex+9,36)); |
| 9389 |
if (htest.resiNr) |
| 9390 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9391 |
.arg(nnn) |
| 9392 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9393 |
else nn=nnn; |
| 9394 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9395 |
hindex++; |
| 9396 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9397 |
htest.Label=nnn; |
| 9398 |
alab.append(nn); |
| 9399 |
htest.isIso=true; |
| 9400 |
htest.ufiso_org=QString("-1.2"); |
| 9401 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 9402 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 9403 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 9404 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 9405 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 9406 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 9407 |
htest.pos=v; |
| 9408 |
mole.kart2frac(htest.pos,htest.frac); |
| 9409 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9410 |
.arg(htest.Label) |
| 9411 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9412 |
.arg(htest.frac.x,9,'f',5) |
| 9413 |
.arg(htest.frac.y,9,'f',5) |
| 9414 |
.arg(htest.frac.z,9,'f',5) |
| 9415 |
.arg(mole.asymm.at(i).sof_org) |
| 9416 |
.arg("-1.2"); |
| 9417 |
mole.asymm.append(htest); |
| 9418 |
|
| 9419 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 9420 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 9421 |
cursor.movePosition(QTextCursor::Start); |
| 9422 |
cursor = document->find(label,cursor); |
| 9423 |
if (cursor.isNull()){ |
| 9424 |
cursor = editor->textCursor(); |
| 9425 |
cursor.movePosition(QTextCursor::Start); |
| 9426 |
label.chop(10); |
| 9427 |
cursor = document->find(label,cursor); |
| 9428 |
if (cursor.isNull()) { |
| 9429 |
cursor = editor->textCursor(); |
| 9430 |
} |
| 9431 |
} |
| 9432 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 9433 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9434 |
while (cursor.selectedText().endsWith("=")) { |
| 9435 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 9436 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9437 |
} |
| 9438 |
cursor.clearSelection(); |
| 9439 |
cursor.movePosition(QTextCursor::Down); |
| 9440 |
cursor.insertText(QString("AFIX 163\n%1\nAFIX %2\n") |
| 9441 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 9442 |
.arg(mole.afix5(i)) |
| 9443 |
); |
| 9444 |
|
| 9445 |
|
| 9446 |
|
| 9447 |
cursor.endEditBlock(); |
| 9448 |
int jetztAtome=0; |
| 9449 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 9450 |
actionHFix->setDisabled(true); |
| 9451 |
fuse(); |
| 9452 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 9453 |
infoKanalNews(info); |
| 9454 |
|
| 9455 |
}//163 |
| 9456 |
|
| 9457 |
void Window::addMethyl(){//137 |
| 9458 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 9459 |
int i=0; |
| 9460 |
if (action) |
| 9461 |
i=action->data().toInt(); |
| 9462 |
else return; |
| 9463 |
if (i>mole.asymm.size()) return; |
| 9464 |
int warmalAtome=0; |
| 9465 |
for (int j=0; j<mole.asymm.size();j++) if (mole.asymm.at(j).an>=0)warmalAtome++; |
| 9466 |
double nh= (mole.asymm.at(i).an==6) ? 0.07 : 0; |
| 9467 |
QStringList alab; |
| 9468 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 9469 |
alab.append(mole.asymm.at(i).Label); |
| 9470 |
} |
| 9471 |
QString nn; |
| 9472 |
chgl->disSelection(); |
| 9473 |
MyAtom htest,qtest; |
| 9474 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 9475 |
htest.an=0; |
| 9476 |
htest.part=0; |
| 9477 |
htest.resiNr=0; |
| 9478 |
htest.hidden=0; |
| 9479 |
htest.symmGroup=0; |
| 9480 |
htest.sg=0; |
| 9481 |
htest.scod=555;//the identity |
| 9482 |
htest.auidx=-1; |
| 9483 |
htest.isIso=true; |
| 9484 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 9485 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 9486 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 9487 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 9488 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 9489 |
qtest=htest; |
| 9490 |
qtest.an=-1; |
| 9491 |
QTextDocument *document = editor->document(); |
| 9492 |
QTextCursor cursor = editor->textCursor(); |
| 9493 |
cursor.beginEditBlock (); |
| 9494 |
double xh[8]={ |
| 9495 |
0.98,//1 |
| 9496 |
0.97,//2 |
| 9497 |
0.96,//3 |
| 9498 |
0.93,//4 |
| 9499 |
1.10,//15 B |
| 9500 |
0.82,//8 O |
| 9501 |
0.93,//9 |
| 9502 |
0.93// 16 |
| 9503 |
}; |
| 9504 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0);//,b=V3(0,0,0),c=V3(0,0,0); |
| 9505 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos - mole.asymm.at(i).pos; |
| 9506 |
int ji,ki,li; |
| 9507 |
a=Normalize(a); |
| 9508 |
double jx,kx,lx,mx,my,mz; |
| 9509 |
double val[24],merg[8],wink=0,t=0,mt=0; |
| 9510 |
for (int z=0; z<8;z++) merg[z]=0; |
| 9511 |
if (fxle->n5){ |
| 9512 |
for (int z=0; z<24; z++){ |
| 9513 |
w=Normalize(V3(0,0,1)%a); |
| 9514 |
u=Normalize(w%a); |
| 9515 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9516 |
qtest.pos=v; |
| 9517 |
mole.kart2frac(v,v); |
| 9518 |
int zplu=0; |
| 9519 |
do { |
| 9520 |
jx=((zplu+v.x)*fxle->n1+0.5); |
| 9521 |
zplu++; |
| 9522 |
}while (jx<0); |
| 9523 |
zplu=0; |
| 9524 |
do { |
| 9525 |
kx=((zplu+v.y)*fxle->n2+0.5); |
| 9526 |
zplu++; |
| 9527 |
}while (kx<0); |
| 9528 |
zplu=0; |
| 9529 |
do { |
| 9530 |
lx=((zplu+v.z)*fxle->n3+0.5); |
| 9531 |
zplu++; |
| 9532 |
}while (lx<0); |
| 9533 |
mx=jx-floor(jx); |
| 9534 |
my=kx-floor(kx); |
| 9535 |
mz=lx-floor(lx); |
| 9536 |
ji=((int)jx)%fxle->n1;// |
| 9537 |
ki=((int)kx)%fxle->n2;// |
| 9538 |
li=((int)lx)%fxle->n3;// |
| 9539 |
merg[z%8]+=val[z]=( |
| 9540 |
(1-mx)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9541 |
mx*fxle->datfo_fc[((ji+1)+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9542 |
(1-my)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9543 |
my*fxle->datfo_fc[(ji+fxle->n1*((ki+1)+li*fxle->n2))%fxle->n5]+ |
| 9544 |
(1-mz)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9545 |
mz*fxle->datfo_fc[(ji+fxle->n1*(ki+(li+1)*fxle->n2))%fxle->n5])/3.0; |
| 9546 |
qtest.peakHeight=val[z]; |
| 9547 |
qtest.frac=v; |
| 9548 |
qtest.Label=QString("Q%1").arg(z,-3); |
| 9549 |
mole.pmin=qMin(mole.pmin, qtest.peakHeight); |
| 9550 |
mole.pmax=qMax(mole.pmax, qtest.peakHeight); |
| 9551 |
qpv->cutoff=0;//mole.pmin; |
| 9552 |
qpv->setMin(mole.pmin); |
| 9553 |
qpv->setMax(mole.pmax); |
| 9554 |
mole.asymm.append(qtest); |
| 9555 |
wink+=0.261799387799; |
| 9556 |
} |
| 9557 |
for (int z=0; z<8;z++) { |
| 9558 |
t =merg[(z+8)%8] ; |
| 9559 |
double x = t - merg[(z+9)%8]; |
| 9560 |
double u = t - merg[(z+7)%8]; |
| 9561 |
if (fmin(x,u)<0) continue; |
| 9562 |
double p=0.5*(u-x)/(u+x); |
| 9563 |
t=t+0.25*(p*(u-x)); |
| 9564 |
mt=(mt>t)?mt:t; |
| 9565 |
if (t<mt)continue; |
| 9566 |
wink=((double) z + p )*0.261799387799; |
| 9567 |
} |
| 9568 |
}else{ |
| 9569 |
int zzz=0; |
| 9570 |
int z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 9571 |
while ((z==i)&&(zzz<mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.size())) { |
| 9572 |
z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 9573 |
} |
| 9574 |
w=Normalize(V3(0,0,1)%a); |
| 9575 |
u=Normalize(w%a); |
| 9576 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9577 |
// if z == i then dieder() returns nan, because A in dieder gets (0,0,0) |
| 9578 |
V3 increm = V3(0.0, 0.0, 0.0); |
| 9579 |
if ( z == i ) { |
| 9580 |
increm = V3(0.00001, 0.00001, 0.00001); |
| 9581 |
} |
| 9582 |
wink=mole.dieder(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos+increm-mole.asymm.at(z).pos, |
| 9583 |
mole.asymm.at(i).pos-mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos, |
| 9584 |
v-mole.asymm.at(i).pos)/180.0*M_PI; |
| 9585 |
} |
| 9586 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9587 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 9588 |
htest.part=mole.asymm.at(i).part; |
| 9589 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 9590 |
htest.Label.replace(0,1,'H'); |
| 9591 |
int hindex=1; |
| 9592 |
QString nnn=htest.Label; |
| 9593 |
QString ann=htest.Label; |
| 9594 |
do { |
| 9595 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 9596 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 9597 |
if (htest.resiNr) |
| 9598 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9599 |
.arg(nnn) |
| 9600 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9601 |
else nn=nnn; |
| 9602 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9603 |
hindex++; |
| 9604 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9605 |
htest.Label=nnn; |
| 9606 |
alab.append(nn); |
| 9607 |
|
| 9608 |
htest.isIso=true; |
| 9609 |
htest.ufiso_org=QString("-1.5"); |
| 9610 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.5; |
| 9611 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 9612 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 9613 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 9614 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 9615 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 9616 |
htest.pos=v; |
| 9617 |
mole.kart2frac(htest.pos,htest.frac); |
| 9618 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9619 |
.arg(htest.Label) |
| 9620 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9621 |
.arg(htest.frac.x,9,'f',5) |
| 9622 |
.arg(htest.frac.y,9,'f',5) |
| 9623 |
.arg(htest.frac.z,9,'f',5) |
| 9624 |
.arg(mole.asymm.at(i).sof_org) |
| 9625 |
.arg("-1.5"); |
| 9626 |
mole.asymm.append(htest); |
| 9627 |
wink+=2.09439510239; |
| 9628 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9629 |
do { |
| 9630 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 9631 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 9632 |
if (htest.resiNr) |
| 9633 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9634 |
.arg(nnn) |
| 9635 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9636 |
else nn=nnn; |
| 9637 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9638 |
hindex++; |
| 9639 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9640 |
htest.Label=nnn; |
| 9641 |
alab.append(nn); |
| 9642 |
htest.pos=v; |
| 9643 |
mole.kart2frac(htest.pos,htest.frac); |
| 9644 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9645 |
.arg(htest.Label) |
| 9646 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9647 |
.arg(htest.frac.x,9,'f',5) |
| 9648 |
.arg(htest.frac.y,9,'f',5) |
| 9649 |
.arg(htest.frac.z,9,'f',5) |
| 9650 |
.arg(mole.asymm.at(i).sof_org) |
| 9651 |
.arg("-1.5"); |
| 9652 |
mole.asymm.append(htest); |
| 9653 |
wink+=2.09439510239; |
| 9654 |
v=(-(xh[2]-nh)*0.33333*a)+ mole.asymm.at(i).pos+(xh[2]-nh)*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9655 |
do { |
| 9656 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 9657 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 9658 |
if (htest.resiNr) |
| 9659 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9660 |
.arg(nnn) |
| 9661 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9662 |
else nn=nnn; |
| 9663 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9664 |
hindex++; |
| 9665 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9666 |
htest.Label=nnn; |
| 9667 |
alab.append(nn); |
| 9668 |
htest.pos=v; |
| 9669 |
mole.kart2frac(htest.pos,htest.frac); |
| 9670 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9671 |
.arg(htest.Label) |
| 9672 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9673 |
.arg(htest.frac.x,9,'f',5) |
| 9674 |
.arg(htest.frac.y,9,'f',5) |
| 9675 |
.arg(htest.frac.z,9,'f',5) |
| 9676 |
.arg(mole.asymm.at(i).sof_org) |
| 9677 |
.arg("-1.5"); |
| 9678 |
mole.asymm.append(htest); |
| 9679 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 9680 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 9681 |
cursor.movePosition(QTextCursor::Start); |
| 9682 |
cursor = document->find(label,cursor); |
| 9683 |
if (cursor.isNull()){ |
| 9684 |
cursor = editor->textCursor(); |
| 9685 |
cursor.movePosition(QTextCursor::Start); |
| 9686 |
label.chop(10); |
| 9687 |
cursor = document->find(label,cursor); |
| 9688 |
if (cursor.isNull()) { |
| 9689 |
cursor = editor->textCursor(); |
| 9690 |
} |
| 9691 |
} |
| 9692 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 9693 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9694 |
while (cursor.selectedText().endsWith("=")) { |
| 9695 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 9696 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9697 |
} |
| 9698 |
cursor.clearSelection(); |
| 9699 |
cursor.movePosition(QTextCursor::Down); |
| 9700 |
cursor.insertText(QString("AFIX 137\n%1\n%2\n%3\nAFIX %4\n") |
| 9701 |
.arg(mole.asymm.at(mole.asymm.size()-3).orginalLine) |
| 9702 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 9703 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 9704 |
.arg(mole.afix5(i)) |
| 9705 |
); |
| 9706 |
|
| 9707 |
cursor.endEditBlock(); |
| 9708 |
int jetztAtome=0; |
| 9709 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 9710 |
actionHFix->setDisabled(true); |
| 9711 |
fuse(); |
| 9712 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 9713 |
infoKanalNews(info); |
| 9714 |
} |
| 9715 |
|
| 9716 |
|
| 9717 |
void Window::addHydroxyl(){//148 |
| 9718 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 9719 |
int idx=0; |
| 9720 |
if (action) |
| 9721 |
idx=action->data().toInt(); |
| 9722 |
else return; |
| 9723 |
if (idx>mole.asymm.size()) return; |
| 9724 |
int warmalAtome=0; |
| 9725 |
for (int j=0; j<mole.asymm.size();j++) if (mole.asymm.at(j).an>=0)warmalAtome++; |
| 9726 |
|
| 9727 |
QStringList alab; |
| 9728 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 9729 |
alab.append(mole.asymm.at(i).Label); |
| 9730 |
} |
| 9731 |
QString nn; |
| 9732 |
chgl->disSelection(); |
| 9733 |
MyAtom htest,qtest; |
| 9734 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 9735 |
htest.an=0; |
| 9736 |
htest.part=0; |
| 9737 |
htest.resiNr=0; |
| 9738 |
htest.hidden=0; |
| 9739 |
htest.symmGroup=0; |
| 9740 |
htest.sg=0; |
| 9741 |
htest.scod=555;//the identity |
| 9742 |
htest.auidx=-1; |
| 9743 |
htest.isIso=true; |
| 9744 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 9745 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 9746 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 9747 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 9748 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 9749 |
qtest=htest; |
| 9750 |
qtest.an=-1; |
| 9751 |
QTextDocument *document = editor->document(); |
| 9752 |
QTextCursor cursor = editor->textCursor(); |
| 9753 |
cursor.beginEditBlock (); |
| 9754 |
//printf("editblock begins\n"); |
| 9755 |
double xh[8]={ |
| 9756 |
0.98,//1 |
| 9757 |
0.97,//2 |
| 9758 |
0.96,//3 |
| 9759 |
0.93,//4 |
| 9760 |
1.10,//15 B |
| 9761 |
0.82,//8 O |
| 9762 |
0.93,//9 |
| 9763 |
0.93// 16 |
| 9764 |
}; |
| 9765 |
//qDebug()<<mole.showatoms.at(mole.knoepfe.at(idx).neighbors.at(0)).Label<<mole.asymm.at(idx).Label; |
| 9766 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0);//,b=V3(0,0,0),c=V3(0,0,0); |
| 9767 |
a = mole.showatoms.at(mole.knoepfe.at(idx).neighbors.at(0)).pos - mole.asymm.at(idx).pos; |
| 9768 |
int ji,ki,li; |
| 9769 |
a=Normalize(a); |
| 9770 |
double jx,kx,lx,mx,my,mz; |
| 9771 |
double val[24],wink=0,t=0,mt=0; |
| 9772 |
|
| 9773 |
if (fxle->n5){ |
| 9774 |
for (int z=0; z<24; z++){ |
| 9775 |
w=Normalize(V3(0,0,1)%a); |
| 9776 |
u=Normalize(w%a); |
| 9777 |
v=(-(xh[5])*0.33333*a)+ mole.asymm.at(idx).pos+(xh[5])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9778 |
qtest.pos=v; |
| 9779 |
mole.kart2frac(v,v); |
| 9780 |
int zplu=0; |
| 9781 |
do { |
| 9782 |
jx=((zplu+v.x)*fxle->n1+0.5); |
| 9783 |
zplu++; |
| 9784 |
}while (jx<0); |
| 9785 |
zplu=0; |
| 9786 |
do { |
| 9787 |
kx=((zplu+v.y)*fxle->n2+0.5); |
| 9788 |
zplu++; |
| 9789 |
}while (kx<0); |
| 9790 |
zplu=0; |
| 9791 |
do { |
| 9792 |
lx=((zplu+v.z)*fxle->n3+0.5); |
| 9793 |
zplu++; |
| 9794 |
}while (lx<0); |
| 9795 |
mx=jx-floor(jx); |
| 9796 |
my=kx-floor(kx); |
| 9797 |
mz=lx-floor(lx); |
| 9798 |
ji=((int)jx)%fxle->n1;// |
| 9799 |
ki=((int)kx)%fxle->n2;// |
| 9800 |
li=((int)lx)%fxle->n3;// |
| 9801 |
val[z]=( |
| 9802 |
(1-mx)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9803 |
mx*fxle->datfo_fc[((ji+1)+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9804 |
(1-my)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9805 |
my*fxle->datfo_fc[(ji+fxle->n1*((ki+1)+li*fxle->n2))%fxle->n5]+ |
| 9806 |
(1-mz)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9807 |
mz*fxle->datfo_fc[(ji+fxle->n1*(ki+(li+1)*fxle->n2))%fxle->n5])/3.0; |
| 9808 |
qtest.peakHeight=val[z]; |
| 9809 |
qtest.frac=v; |
| 9810 |
qtest.Label=QString("Q%1").arg(z,-3); |
| 9811 |
mole.pmin=qMin(mole.pmin, qtest.peakHeight); |
| 9812 |
mole.pmax=qMax(mole.pmax, qtest.peakHeight); |
| 9813 |
qpv->cutoff=0;//mole.pmin; |
| 9814 |
qpv->setMin(mole.pmin); |
| 9815 |
qpv->setMax(mole.pmax); |
| 9816 |
mole.asymm.append(qtest); |
| 9817 |
wink+=0.261799387799; |
| 9818 |
} |
| 9819 |
for (int z=0; z<24;z++) { |
| 9820 |
t =val[z%24] ; |
| 9821 |
double x = t - val[(z+25)%24]; |
| 9822 |
double u = t - val[(z+23)%24]; |
| 9823 |
if (fmin(x,u)<0) continue; |
| 9824 |
double p=0.5*(u-x)/(u+x); |
| 9825 |
t=t+0.25*(p*(u-x)); |
| 9826 |
mt=(mt>t)?mt:t; |
| 9827 |
if (t<mt)continue; |
| 9828 |
wink=((double) z + p )*0.261799387799; |
| 9829 |
} |
| 9830 |
}else {qDebug()<<"Please enable Fourier maps!";cursor.endEditBlock(); return; } |
| 9831 |
v=(-(xh[5])*0.33333*a)+ mole.asymm.at(idx).pos+(xh[5])*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 9832 |
htest.Label=mole.asymm.at(idx).Label.section('_',0,0); |
| 9833 |
htest.part=mole.asymm.at(idx).part; |
| 9834 |
htest.resiNr=mole.asymm.at(idx).resiNr; |
| 9835 |
htest.Label.replace(0,1,'H'); |
| 9836 |
int hindex=1; |
| 9837 |
QString nnn=htest.Label; |
| 9838 |
QString ann=htest.Label; |
| 9839 |
do { |
| 9840 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 9841 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 9842 |
if (htest.resiNr) |
| 9843 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 9844 |
.arg(nnn) |
| 9845 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 9846 |
else nn=nnn; |
| 9847 |
// qDebug()<<nn<<nnn<<(alab.contains(nn,Qt::CaseInsensitive)); |
| 9848 |
hindex++; |
| 9849 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 9850 |
htest.Label=nnn; |
| 9851 |
alab.append(nn); |
| 9852 |
|
| 9853 |
htest.isIso=true; |
| 9854 |
htest.ufiso_org=QString("-1.5"); |
| 9855 |
double uIso = mole.ueq(mole.asymm.at(idx).uf)*1.5; |
| 9856 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 9857 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 9858 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 9859 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 9860 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 9861 |
htest.pos=v; |
| 9862 |
mole.kart2frac(htest.pos,htest.frac); |
| 9863 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 9864 |
.arg(htest.Label) |
| 9865 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 9866 |
.arg(htest.frac.x,9,'f',5) |
| 9867 |
.arg(htest.frac.y,9,'f',5) |
| 9868 |
.arg(htest.frac.z,9,'f',5) |
| 9869 |
.arg(mole.asymm.at(idx).sof_org) |
| 9870 |
.arg("-1.5"); |
| 9871 |
mole.asymm.append(htest); |
| 9872 |
QString label = mole.showatoms.at(idx).orginalLine.left(80).trimmed(); |
| 9873 |
// int afixfuenf=(mole.showatoms.at(i).afix/10)?(mole.showatoms.at(i).afix/10)*10+5:0; |
| 9874 |
cursor.movePosition(QTextCursor::Start); |
| 9875 |
cursor = document->find(label,cursor); |
| 9876 |
if (cursor.isNull()){ |
| 9877 |
cursor = editor->textCursor(); |
| 9878 |
cursor.movePosition(QTextCursor::Start); |
| 9879 |
label.chop(10); |
| 9880 |
cursor = document->find(label,cursor); |
| 9881 |
if (cursor.isNull()) { |
| 9882 |
cursor = editor->textCursor(); |
| 9883 |
} |
| 9884 |
} |
| 9885 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 9886 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9887 |
while (cursor.selectedText().endsWith("=")) { |
| 9888 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 9889 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 9890 |
} |
| 9891 |
cursor.clearSelection(); |
| 9892 |
cursor.movePosition(QTextCursor::Down); |
| 9893 |
cursor.insertText(QString("AFIX 148\n%1\nAFIX %2\n") |
| 9894 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 9895 |
.arg(mole.afix5(idx)) |
| 9896 |
); |
| 9897 |
//printf("%d cursor will end edit block\n",cursor.isNull()); |
| 9898 |
cursor.endEditBlock(); |
| 9899 |
int jetztAtome=0; |
| 9900 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 9901 |
actionHFix->setDisabled(true); |
| 9902 |
fuse(); |
| 9903 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 9904 |
infoKanalNews(info); |
| 9905 |
} |
| 9906 |
|
| 9907 |
|
| 9908 |
|
| 9909 |
|
| 9910 |
void Window::addHnonplanarAminR2(){ |
| 9911 |
//<! there is no afix for R-NH2 for the nonplanar case |
| 9912 |
//this trys to find similar to 23 the highest density in the terahedal cone |
| 9913 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 9914 |
int i=0; |
| 9915 |
if (action) |
| 9916 |
i=action->data().toInt(); |
| 9917 |
else return; |
| 9918 |
if (i>mole.asymm.size()) return; |
| 9919 |
if (mole.knoepfe.at(i).neighbors.size()!=2)return;//we need 2 non h neighbors |
| 9920 |
int warmalAtome=0; |
| 9921 |
for (int j=0; j<mole.asymm.size();j++) if (mole.asymm.at(j).an>=0)warmalAtome++; |
| 9922 |
QStringList alab; |
| 9923 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 9924 |
alab.append(mole.asymm.at(i).Label); |
| 9925 |
} |
| 9926 |
QString nn; |
| 9927 |
double dist=0.9;//nh= (mole.asymm.at(i).an==6) ? 0.07 : 0; |
| 9928 |
|
| 9929 |
chgl->disSelection(); |
| 9930 |
MyAtom htest,qtest; |
| 9931 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 9932 |
htest.an=0; |
| 9933 |
htest.part=0; |
| 9934 |
htest.resiNr=0; |
| 9935 |
htest.hidden=0; |
| 9936 |
htest.symmGroup=0; |
| 9937 |
htest.sg=0; |
| 9938 |
htest.scod=555;//the identity |
| 9939 |
htest.auidx=-1; |
| 9940 |
htest.isIso=true; |
| 9941 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 9942 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 9943 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 9944 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 9945 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 9946 |
qtest=htest; |
| 9947 |
qtest.an=-1; |
| 9948 |
QTextDocument *document = editor->document(); |
| 9949 |
QTextCursor cursor = editor->textCursor(); |
| 9950 |
cursor.beginEditBlock (); |
| 9951 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0),b=V3(0,0,0),c=V3(0,0,0); |
| 9952 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0) ).pos - mole.asymm.at(i).pos; |
| 9953 |
b = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(1) ).pos - mole.asymm.at(i).pos; |
| 9954 |
a = c = Normalize(a) ; |
| 9955 |
c = c+ (b= Normalize(b)); |
| 9956 |
c = Normalize(c); |
| 9957 |
|
| 9958 |
w = Normalize(a); |
| 9959 |
u = Normalize(b); |
| 9960 |
double si=1.0376-0.0346*Norm(w-u); //=1.91063323625-((acos(u*w)-1.91063323625)/5.0);//-1.91063323625 = 109.47 grad ; 3.7 empirischer Wert |
| 9961 |
c = (-cos(si)*dist * c); |
| 9962 |
v = sin(si) *dist * Normalize(c%a); |
| 9963 |
a = mole.asymm.at(i).pos + c + v; |
| 9964 |
b = mole.asymm.at(i).pos + c - v; |
| 9965 |
// test if pos a or b has the higher residual density |
| 9966 |
double densA=0.,densB=0.; |
| 9967 |
if (fxle->n5){ |
| 9968 |
double jx,kx,lx,mx,my,mz; |
| 9969 |
mole.kart2frac(a,v); |
| 9970 |
int zplu=0,ji,ki,li; |
| 9971 |
do { |
| 9972 |
jx=((zplu+v.x)*fxle->n1+0.5); |
| 9973 |
zplu++; |
| 9974 |
}while (jx<0); |
| 9975 |
zplu=0; |
| 9976 |
do { |
| 9977 |
kx=((zplu+v.y)*fxle->n2+0.5); |
| 9978 |
zplu++; |
| 9979 |
}while (kx<0); |
| 9980 |
zplu=0; |
| 9981 |
do { |
| 9982 |
lx=((zplu+v.z)*fxle->n3+0.5); |
| 9983 |
zplu++; |
| 9984 |
}while (lx<0); |
| 9985 |
mx=jx-floor(jx); |
| 9986 |
my=kx-floor(kx); |
| 9987 |
mz=lx-floor(lx); |
| 9988 |
ji=((int)jx)%fxle->n1;// |
| 9989 |
ki=((int)kx)%fxle->n2;// |
| 9990 |
li=((int)lx)%fxle->n3;// |
| 9991 |
densA=( |
| 9992 |
(1-mx)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9993 |
mx*fxle->datfo_fc[((ji+1)+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9994 |
(1-my)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9995 |
my*fxle->datfo_fc[(ji+fxle->n1*((ki+1)+li*fxle->n2))%fxle->n5]+ |
| 9996 |
(1-mz)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 9997 |
mz*fxle->datfo_fc[(ji+fxle->n1*(ki+(li+1)*fxle->n2))%fxle->n5]); |
| 9998 |
|
| 9999 |
mole.kart2frac(b,v); |
| 10000 |
zplu=0; |
| 10001 |
do { |
| 10002 |
jx=((zplu+v.x)*fxle->n1+0.5); |
| 10003 |
zplu++; |
| 10004 |
}while (jx<0); |
| 10005 |
zplu=0; |
| 10006 |
do { |
| 10007 |
kx=((zplu+v.y)*fxle->n2+0.5); |
| 10008 |
zplu++; |
| 10009 |
}while (kx<0); |
| 10010 |
zplu=0; |
| 10011 |
do { |
| 10012 |
lx=((zplu+v.z)*fxle->n3+0.5); |
| 10013 |
zplu++; |
| 10014 |
}while (lx<0); |
| 10015 |
mx=jx-floor(jx); |
| 10016 |
my=kx-floor(kx); |
| 10017 |
mz=lx-floor(lx); |
| 10018 |
ji=((int)jx)%fxle->n1;// |
| 10019 |
ki=((int)kx)%fxle->n2;// |
| 10020 |
li=((int)lx)%fxle->n3;// |
| 10021 |
densB=( |
| 10022 |
(1-mx)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10023 |
mx*fxle->datfo_fc[((ji+1)+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10024 |
(1-my)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10025 |
my*fxle->datfo_fc[(ji+fxle->n1*((ki+1)+li*fxle->n2))%fxle->n5]+ |
| 10026 |
(1-mz)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10027 |
mz*fxle->datfo_fc[(ji+fxle->n1*(ki+(li+1)*fxle->n2))%fxle->n5]); |
| 10028 |
}//n5 |
| 10029 |
c = c + mole.asymm.at(i).pos; |
| 10030 |
|
| 10031 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 10032 |
htest.part=mole.asymm.at(i).part; |
| 10033 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 10034 |
htest.Label.replace(0,1,'H'); |
| 10035 |
int hindex=14;//N |
| 10036 |
QString nnn=htest.Label; |
| 10037 |
QString ann=nnn; |
| 10038 |
if (densA>densB) { |
| 10039 |
//HA |
| 10040 |
do { |
| 10041 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 10042 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 10043 |
if (htest.resiNr) |
| 10044 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 10045 |
.arg(nnn) |
| 10046 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 10047 |
else nn=nnn; |
| 10048 |
hindex++; |
| 10049 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 10050 |
htest.Label=nnn; |
| 10051 |
alab.append(nn); |
| 10052 |
htest.isIso=true; |
| 10053 |
htest.ufiso_org=QString("-1.2"); |
| 10054 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.2; |
| 10055 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 10056 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 10057 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 10058 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 10059 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 10060 |
htest.pos=a; |
| 10061 |
mole.kart2frac(htest.pos,htest.frac); |
| 10062 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 10063 |
.arg(htest.Label) |
| 10064 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 10065 |
.arg(htest.frac.x,9,'f',5) |
| 10066 |
.arg(htest.frac.y,9,'f',5) |
| 10067 |
.arg(htest.frac.z,9,'f',5) |
| 10068 |
.arg(mole.asymm.at(i).sof_org) |
| 10069 |
.arg("-1.2"); |
| 10070 |
mole.asymm.append(htest); |
| 10071 |
} else { |
| 10072 |
//HB |
| 10073 |
do { |
| 10074 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 10075 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 10076 |
if (htest.resiNr) |
| 10077 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 10078 |
.arg(nnn) |
| 10079 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 10080 |
else nn=nnn; |
| 10081 |
hindex++; |
| 10082 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 10083 |
htest.Label=nnn; |
| 10084 |
alab.append(nn); |
| 10085 |
htest.pos=b; |
| 10086 |
mole.kart2frac(htest.pos,htest.frac); |
| 10087 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 10088 |
.arg(htest.Label) |
| 10089 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 10090 |
.arg(htest.frac.x,9,'f',5) |
| 10091 |
.arg(htest.frac.y,9,'f',5) |
| 10092 |
.arg(htest.frac.z,9,'f',5) |
| 10093 |
.arg(mole.asymm.at(i).sof_org) |
| 10094 |
.arg("-1.2"); |
| 10095 |
mole.asymm.append(htest); |
| 10096 |
} |
| 10097 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 10098 |
cursor.movePosition(QTextCursor::Start); |
| 10099 |
cursor = document->find(label,cursor); |
| 10100 |
if (cursor.isNull()){ |
| 10101 |
cursor = editor->textCursor(); |
| 10102 |
cursor.movePosition(QTextCursor::Start); |
| 10103 |
label.chop(10); |
| 10104 |
cursor = document->find(label,cursor); |
| 10105 |
if (cursor.isNull()) { |
| 10106 |
cursor = editor->textCursor(); |
| 10107 |
} |
| 10108 |
} |
| 10109 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 10110 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 10111 |
while (cursor.selectedText().endsWith("=")) { |
| 10112 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 10113 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 10114 |
} |
| 10115 |
cursor.clearSelection(); |
| 10116 |
cursor.movePosition(QTextCursor::Down); |
| 10117 |
cursor.insertText(QString("REM HFIX R2N-H\n%1\n") .arg(mole.asymm.last().orginalLine)); |
| 10118 |
//now comes some DFIX/DANG/SADI stuff |
| 10119 |
cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); |
| 10120 |
cursor = document->find(unitinst,cursor); |
| 10121 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 10122 |
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); |
| 10123 |
QString rns=""; |
| 10124 |
if (mole.asymm.at(i).resiNr!=0) rns=QString("_%1").arg(mole.asymm.at(i).resiNr); |
| 10125 |
QString buffer = QString("DFIX%1 %2 %3 %4\n") |
| 10126 |
.arg(rns) |
| 10127 |
.arg(dist,0,'f',2) |
| 10128 |
.arg(mole.asymm.at(i).Label.section('_',0,0)) |
| 10129 |
.arg(mole.asymm.last().Label); |
| 10130 |
cursor.insertText(buffer); |
| 10131 |
for (int z = 0; z < mole.knoepfe.at(i).neighbors.size(); z++){ |
| 10132 |
buffer.clear(); |
| 10133 |
double einsdrei=sqrt(Distance(mole.asymm.last().pos,mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(z)).pos));//showatoms because this might be not in asymmeric unit |
| 10134 |
QString LL=mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(z)).Label.section('_',0,0),dollarN=""; |
| 10135 |
if (mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(z)).symmGroup>0){ |
| 10136 |
int eq = document->toPlainText().count("EQIV", Qt::CaseInsensitive)+1; |
| 10137 |
dollarN=QString("$%1").arg(eq); |
| 10138 |
buffer = QString("EQIV %1 %2\n").arg(dollarN).arg(mole.symmcode2human(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(z)).sg)); |
| 10139 |
dollarN.prepend('_'); |
| 10140 |
LL=LL.section(QString::fromUtf8("»"),0,0); |
| 10141 |
} |
| 10142 |
buffer += QString("DANG%1 %2 %3%4 %5\n") |
| 10143 |
.arg(rns) |
| 10144 |
.arg(einsdrei,0,'f',2) |
| 10145 |
.arg(LL) |
| 10146 |
.arg(dollarN) |
| 10147 |
.arg(mole.asymm.last().Label); |
| 10148 |
cursor.insertText(buffer); |
| 10149 |
|
| 10150 |
} |
| 10151 |
cursor.endEditBlock(); |
| 10152 |
int jetztAtome=0; |
| 10153 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 10154 |
actionHFix->setDisabled(true); |
| 10155 |
fuse(); |
| 10156 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 10157 |
infoKanalNews(info); |
| 10158 |
} |
| 10159 |
|
| 10160 |
void Window::addHnonplanarAminR1(){ |
| 10161 |
//<! there is no afix for R-NH2 for the nonplanar case |
| 10162 |
//this trys to find similar to 137 the highest density in the terahedal cone |
| 10163 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 10164 |
int i=0; |
| 10165 |
if (action) |
| 10166 |
i=action->data().toInt(); |
| 10167 |
else return; |
| 10168 |
if (i>mole.asymm.size()) return; |
| 10169 |
int warmalAtome=0; |
| 10170 |
for (int j=0; j<mole.asymm.size();j++) if (mole.asymm.at(j).an>=0)warmalAtome++; |
| 10171 |
|
| 10172 |
chgl->disSelection(); |
| 10173 |
MyAtom htest,qtest; |
| 10174 |
if (editor->sfac.indexOf(0)==-1)addNewScatteringFactor(0,false); |
| 10175 |
QStringList alab; |
| 10176 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 10177 |
alab.append(mole.asymm.at(i).Label); |
| 10178 |
} |
| 10179 |
QString nn; |
| 10180 |
htest.an=0; |
| 10181 |
htest.part=0; |
| 10182 |
htest.resiNr=0; |
| 10183 |
htest.hidden=0; |
| 10184 |
htest.symmGroup=0; |
| 10185 |
htest.sg=0; |
| 10186 |
htest.scod=555;//the identity |
| 10187 |
htest.auidx=-1; |
| 10188 |
htest.isIso=true; |
| 10189 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=0.05; |
| 10190 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 10191 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 10192 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 10193 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 10194 |
qtest=htest; |
| 10195 |
qtest.an=-1; |
| 10196 |
QTextDocument *document = editor->document(); |
| 10197 |
QTextCursor cursor = editor->textCursor(); |
| 10198 |
cursor.beginEditBlock (); |
| 10199 |
V3 v=V3(0,0,0),w=V3(0,0,0),u=V3(0,0,0) ,a=V3(0,0,0);//,b=V3(0,0,0),c=V3(0,0,0); |
| 10200 |
a = mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos - mole.asymm.at(i).pos; |
| 10201 |
int ji, ki, li, main[24], fi=0,az=0,bz=0; |
| 10202 |
a=Normalize(a); |
| 10203 |
double jx,kx,lx,mx,my,mz,dist=0.89; |
| 10204 |
bool andersrum=false; |
| 10205 |
double val[24],wink=0,t=0,mt=0.0,mava[24]; |
| 10206 |
if (fxle->n5){ |
| 10207 |
for (int z=0; z<24; z++){ |
| 10208 |
main[z] = -1; |
| 10209 |
mava[z] = 0.0; |
| 10210 |
w=Normalize(V3(0,0,1)%a); |
| 10211 |
u=Normalize(w%a); |
| 10212 |
v=(-dist*0.33333*a)+ mole.asymm.at(i).pos+dist*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 10213 |
qtest.pos=v; |
| 10214 |
mole.kart2frac(v,v); |
| 10215 |
int zplu=0; |
| 10216 |
do { |
| 10217 |
jx=((zplu+v.x)*fxle->n1+0.5); |
| 10218 |
zplu++; |
| 10219 |
}while (jx<0); |
| 10220 |
zplu=0; |
| 10221 |
do { |
| 10222 |
kx=((zplu+v.y)*fxle->n2+0.5); |
| 10223 |
zplu++; |
| 10224 |
}while (kx<0); |
| 10225 |
zplu=0; |
| 10226 |
do { |
| 10227 |
lx=((zplu+v.z)*fxle->n3+0.5); |
| 10228 |
zplu++; |
| 10229 |
}while (lx<0); |
| 10230 |
mx=jx-floor(jx); |
| 10231 |
my=kx-floor(kx); |
| 10232 |
mz=lx-floor(lx); |
| 10233 |
ji=((int)jx)%fxle->n1;// |
| 10234 |
ki=((int)kx)%fxle->n2;// |
| 10235 |
li=((int)lx)%fxle->n3;// |
| 10236 |
val[z]=( |
| 10237 |
(1-mx)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10238 |
mx*fxle->datfo_fc[((ji+1)+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10239 |
(1-my)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10240 |
my*fxle->datfo_fc[(ji+fxle->n1*((ki+1)+li*fxle->n2))%fxle->n5]+ |
| 10241 |
(1-mz)*fxle->datfo_fc[(ji+fxle->n1*(ki+li*fxle->n2))%fxle->n5]+ |
| 10242 |
mz*fxle->datfo_fc[(ji+fxle->n1*(ki+(li+1)*fxle->n2))%fxle->n5]); |
| 10243 |
qtest.peakHeight=val[z]; |
| 10244 |
qtest.frac=v; |
| 10245 |
qtest.Label=QString("Q%1").arg(z,-3); |
| 10246 |
mole.pmin=qMin(mole.pmin, qtest.peakHeight); |
| 10247 |
mole.pmax=qMax(mole.pmax, qtest.peakHeight); |
| 10248 |
qpv->cutoff=0;//mole.pmin; |
| 10249 |
qpv->setMin(mole.pmin); |
| 10250 |
qpv->setMax(mole.pmax); |
| 10251 |
mole.asymm.append(qtest); |
| 10252 |
wink+=0.261799387799; |
| 10253 |
} |
| 10254 |
for (int z=0; z<24;z++) { |
| 10255 |
t = val[(z+24)%24] ; |
| 10256 |
double x = t - val[(z+25)%24]; |
| 10257 |
double u = t - val[(z+23)%24]; |
| 10258 |
if (fmin(x,u)<0.0) continue; |
| 10259 |
double p=0.5*(u-x)/(u+x); |
| 10260 |
t=t+0.25*(p*(u-x)); |
| 10261 |
mt=(mt>t)?mt:t; |
| 10262 |
main[fi]=z; |
| 10263 |
mava[fi]=t; |
| 10264 |
fi++; |
| 10265 |
if (t<mt)continue; |
| 10266 |
az=z; |
| 10267 |
wink=((double) z + p )*0.261799387799; |
| 10268 |
} |
| 10269 |
double m2t=0.0; |
| 10270 |
for (int z=0; z<fi; z++){ |
| 10271 |
//printf("%d#%f ",main[z],mava[z]); |
| 10272 |
if (main[z] != az) if (m2t < mava[z]) {bz = main[z]; m2t = mava[z];} |
| 10273 |
} |
| 10274 |
//printf("\n"); |
| 10275 |
andersrum=((((bz-az)+36)%24)<12);//decide on which side is the other H |
| 10276 |
//printf("2nd->%d andersrum %d %d %d\n", ((bz-az)+36)%24, andersrum,az,bz); |
| 10277 |
}else{ |
| 10278 |
int zzz=0; |
| 10279 |
int z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 10280 |
while ((z==i)&&(zzz<mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.size())) { |
| 10281 |
z=mole.knoepfe.at(mole.knoepfe.at(i).neighbors.at(0)).neighbors.at(zzz++); |
| 10282 |
} |
| 10283 |
w=Normalize(V3(0,0,1)%a); |
| 10284 |
u=Normalize(w%a); |
| 10285 |
v=(-dist*0.33333*a)+ mole.asymm.at(i).pos+dist*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 10286 |
V3 increm = V3(0.0, 0.0, 0.0); |
| 10287 |
if ( z == i ) { |
| 10288 |
increm = V3(0.00001, 0.00001, 0.00001); |
| 10289 |
} |
| 10290 |
wink=mole.dieder(mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos+increm-mole.asymm.at(z).pos, |
| 10291 |
mole.asymm.at(i).pos-mole.showatoms.at(mole.knoepfe.at(i).neighbors.at(0)).pos, |
| 10292 |
v-mole.asymm.at(i).pos)/180.0*M_PI; |
| 10293 |
} |
| 10294 |
v=(-dist*0.33333*a)+ mole.asymm.at(i).pos+dist*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 10295 |
htest.Label=mole.asymm.at(i).Label.section('_',0,0); |
| 10296 |
htest.part=mole.asymm.at(i).part; |
| 10297 |
htest.resiNr=mole.asymm.at(i).resiNr; |
| 10298 |
htest.Label.replace(0,1,'H'); |
| 10299 |
QString nnn=htest.Label; |
| 10300 |
QString ann=nnn; |
| 10301 |
int hindex=1; |
| 10302 |
//HA |
| 10303 |
do { |
| 10304 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 10305 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 10306 |
if (htest.resiNr) |
| 10307 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 10308 |
.arg(nnn) |
| 10309 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 10310 |
else nn=nnn; |
| 10311 |
hindex++; |
| 10312 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 10313 |
htest.Label=nnn; |
| 10314 |
htest.isIso=true; |
| 10315 |
htest.ufiso_org=QString("-1.5"); |
| 10316 |
double uIso = mole.ueq(mole.asymm.at(i).uf)*1.5; |
| 10317 |
htest.uf.m11 = htest.uf.m22 = htest.uf.m33 = uIso; |
| 10318 |
htest.uf.m23 = uIso * mole.cell.cosra; |
| 10319 |
htest.uf.m13 = uIso * mole.cell.cosrb; |
| 10320 |
htest.uf.m12 = uIso * mole.cell.cosrg; |
| 10321 |
mole.Uf2Uo(htest.uf,htest.uc); |
| 10322 |
htest.pos=v; |
| 10323 |
mole.kart2frac(htest.pos,htest.frac); |
| 10324 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 10325 |
.arg(htest.Label) |
| 10326 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 10327 |
.arg(htest.frac.x,9,'f',5) |
| 10328 |
.arg(htest.frac.y,9,'f',5) |
| 10329 |
.arg(htest.frac.z,9,'f',5) |
| 10330 |
.arg(mole.asymm.at(i).sof_org) |
| 10331 |
.arg("-1.5"); |
| 10332 |
mole.asymm.append(htest); |
| 10333 |
wink+=2.09439510239; |
| 10334 |
if (andersrum) wink+=2.09439510239; |
| 10335 |
v=(-dist*0.33333*a)+ mole.asymm.at(i).pos+dist*0.942809041582*(sin(wink)*u+cos(wink)*w); |
| 10336 |
//HB |
| 10337 |
do { |
| 10338 |
if (hindex) nnn=ann.left(3).append(QString::number(hindex+9,36)); |
| 10339 |
if (nnn.size()>4) nnn=ann.left(2).append(QString::number(hindex+9,36)); |
| 10340 |
if (htest.resiNr) |
| 10341 |
nn=QString("%1_%2")//for shelxl same names in different parts are no problem but for platon so this should fix it. |
| 10342 |
.arg(nnn) |
| 10343 |
.arg((htest.resiNr)?QString::number(htest.resiNr):""); |
| 10344 |
else nn=nnn; |
| 10345 |
hindex++; |
| 10346 |
}while(alab.contains(nn,Qt::CaseInsensitive)); |
| 10347 |
htest.Label=nnn; |
| 10348 |
htest.pos=v; |
| 10349 |
mole.kart2frac(htest.pos,htest.frac); |
| 10350 |
htest.orginalLine=QString("%1 %2 %3 %4 %5 %6 %7") |
| 10351 |
.arg(htest.Label) |
| 10352 |
.arg(qMax(1,editor->sfac.indexOf(0)+1)) |
| 10353 |
.arg(htest.frac.x,9,'f',5) |
| 10354 |
.arg(htest.frac.y,9,'f',5) |
| 10355 |
.arg(htest.frac.z,9,'f',5) |
| 10356 |
.arg(mole.asymm.at(i).sof_org) |
| 10357 |
.arg("-1.5"); |
| 10358 |
mole.asymm.append(htest); |
| 10359 |
QString label = mole.showatoms.at(i).orginalLine.left(80).trimmed(); |
| 10360 |
cursor.movePosition(QTextCursor::Start); |
| 10361 |
cursor = document->find(label,cursor); |
| 10362 |
if (cursor.isNull()){ |
| 10363 |
cursor = editor->textCursor(); |
| 10364 |
cursor.movePosition(QTextCursor::Start); |
| 10365 |
label.chop(10); |
| 10366 |
cursor = document->find(label,cursor); |
| 10367 |
if (cursor.isNull()) { |
| 10368 |
cursor = editor->textCursor(); |
| 10369 |
} |
| 10370 |
} |
| 10371 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 10372 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 10373 |
while (cursor.selectedText().endsWith("=")) { |
| 10374 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 10375 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 10376 |
} |
| 10377 |
cursor.clearSelection(); |
| 10378 |
cursor.movePosition(QTextCursor::Down); |
| 10379 |
cursor.insertText(QString("REM R-NH2 (non planar) FIX \n%1\n%2\n") |
| 10380 |
.arg(mole.asymm.at(mole.asymm.size()-2).orginalLine) |
| 10381 |
.arg(mole.asymm.at(mole.asymm.size()-1).orginalLine) |
| 10382 |
); |
| 10383 |
//now comes some DFIX/DANG/SADI stuff |
| 10384 |
// |
| 10385 |
cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); |
| 10386 |
cursor = document->find(unitinst,cursor); |
| 10387 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 10388 |
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); |
| 10389 |
//printf("Resinr %d %d\n",mole.asymm.at(i).resiNr,(mole.asymm.at(i).resiNr!=0) ); |
| 10390 |
QString rns=""; |
| 10391 |
if (mole.asymm.at(i).resiNr!=0) rns=QString("_%1").arg(mole.asymm.at(i).resiNr); |
| 10392 |
QString buffer = QString("DFIX%1 %2 %3 %4\n") |
| 10393 |
.arg(rns) |
| 10394 |
.arg(dist,0,'f',2) |
| 10395 |
.arg(mole.asymm.at(i).Label.section('_',0,0)) |
| 10396 |
.arg(mole.asymm.at(mole.asymm.size()-2).Label); |
| 10397 |
cursor.insertText(buffer); |
| 10398 |
buffer = QString("DFIX%1 %2 %3 %4\n") |
| 10399 |
.arg(rns) |
| 10400 |
.arg(dist,0,'f',2) |
| 10401 |
.arg(mole.asymm.at(i).Label.section('_',0,0)) |
| 10402 |
.arg(mole.asymm.at(mole.asymm.size()-1).Label); |
| 10403 |
cursor.insertText(buffer); |
| 10404 |
buffer = QString("DANG%1 %2 %3 %4! 1,3 dist H..H\n") |
| 10405 |
.arg(rns) |
| 10406 |
.arg(1.5) |
| 10407 |
.arg(mole.asymm.at(mole.asymm.size()-2).Label) |
| 10408 |
.arg(mole.asymm.at(mole.asymm.size()-1).Label); |
| 10409 |
cursor.insertText(buffer); |
| 10410 |
int nnb=mole.knoepfe.at(i).neighbors.at(0); |
| 10411 |
rns=""; |
| 10412 |
if (mole.asymm.at(nnb).resiNr!=0) rns=QString("_%1").arg(mole.asymm.at(nnb).resiNr); |
| 10413 |
|
| 10414 |
buffer = QString("SADI%1 %2 %3 %4 %5\n") |
| 10415 |
.arg(rns) |
| 10416 |
.arg(mole.asymm.at(nnb).Label.section('_',0,0)) |
| 10417 |
.arg(mole.asymm.at(mole.asymm.size()-2).Label) |
| 10418 |
.arg(mole.asymm.at(nnb).Label.section('_',0,0)) |
| 10419 |
.arg(mole.asymm.at(mole.asymm.size()-1).Label); |
| 10420 |
|
| 10421 |
buffer = QString("DANG%1 %2 %3 %4 %3 %5!\n") |
| 10422 |
.arg(rns) |
| 10423 |
.arg(2.0) |
| 10424 |
.arg(mole.asymm.at(nnb).Label.section('_',0,0)) |
| 10425 |
.arg(mole.asymm.at(mole.asymm.size()-2).Label) |
| 10426 |
.arg(mole.asymm.at(mole.asymm.size()-1).Label); |
| 10427 |
|
| 10428 |
cursor.insertText(buffer); |
| 10429 |
|
| 10430 |
// |
| 10431 |
cursor.endEditBlock(); |
| 10432 |
int jetztAtome=0; |
| 10433 |
for (int i=0; i<mole.asymm.size();i++) if (mole.asymm.at(i).an>=0)jetztAtome++; |
| 10434 |
actionHFix->setDisabled(true); |
| 10435 |
fuse(); |
| 10436 |
QString info=QString("<font color=\"green\"><b>%1</b> Hydrogen atoms added. <b>Please SAVE before GROW!</font>").arg(jetztAtome-warmalAtome); |
| 10437 |
infoKanalNews(info); |
| 10438 |
} |
| 10439 |
|
| 10440 |
bool peakcomp(MyAtom &a1,MyAtom &a2){ |
| 10441 |
return (a1.peakHeight>a2.peakHeight); |
| 10442 |
} |
| 10443 |
|
| 10444 |
void Window::addMoreQPeaks(){ |
| 10445 |
if (mole.asymm.isEmpty()) return; |
| 10446 |
if (fxle->n5==0) return; |
| 10447 |
|
| 10448 |
for (int i=mole.asymm.size()-1; i>=0; i--){ |
| 10449 |
if (mole.asymm.at(i).an<0) mole.asymm.removeAt(i); |
| 10450 |
} |
| 10451 |
MyAtom htest; |
| 10452 |
htest.an=-1; |
| 10453 |
htest.part=0; |
| 10454 |
htest.resiNr=0; |
| 10455 |
htest.hidden=0; |
| 10456 |
htest.frac=V3(0,0,0); |
| 10457 |
htest.pos=V3(0,0,0); |
| 10458 |
htest.resiNr=0; |
| 10459 |
htest.part=0; |
| 10460 |
htest.style=1; |
| 10461 |
htest.symmGroup=0; |
| 10462 |
htest.sg=0; |
| 10463 |
htest.scod=555;//the identity |
| 10464 |
htest.auidx=-1; |
| 10465 |
htest.uc.m12=htest.uc.m23=htest.uc.m13=0.0; |
| 10466 |
htest.uc.m21=htest.uc.m32=htest.uc.m31=0.0; |
| 10467 |
htest.uf.m12=htest.uf.m23=htest.uf.m13=0.0; |
| 10468 |
htest.uf.m21=htest.uf.m32=htest.uf.m31=0.0; |
| 10469 |
htest.uf.m11=0.05; |
| 10470 |
htest.isIso=true; |
| 10471 |
htest.uc.m11=htest.uc.m22=htest.uc.m33=htest.uf.m11; |
| 10472 |
float x,y,z,u,v,w,p,q,r,t; |
| 10473 |
int ipeak=0; |
| 10474 |
mole.pmin=10000; |
| 10475 |
mole.pmax=-10000; |
| 10476 |
QList<MyAtom> peaks; |
| 10477 |
for (int k=0;k<fxle->n3;k++){ |
| 10478 |
for (int j=0;j<fxle->n2;j++){ |
| 10479 |
for (int i=0;i<fxle->n1;i++){ |
| 10480 |
if (ipeak>MaxNumberOfPeaks) continue; |
| 10481 |
t = fxle->datfo_fc[i+ fxle->n1*(j+k*fxle->n2)]; |
| 10482 |
x = t - fxle->datfo_fc[((i+1)%fxle->n1) + fxle->n1*(j+k*fxle->n2)]; |
| 10483 |
y = t - fxle->datfo_fc[i+ fxle->n1*(((j+1)%fxle->n2)+k*fxle->n2)]; |
| 10484 |
z = t - fxle->datfo_fc[i+ fxle->n1*(j+((k+1)%fxle->n3)*fxle->n2)]; |
| 10485 |
u = t - fxle->datfo_fc[((i+fxle->n1-1)%fxle->n1)+ fxle->n1*(j+k*fxle->n2)]; |
| 10486 |
v = t - fxle->datfo_fc[i+ fxle->n1*(((j+fxle->n2-1)%fxle->n2)+k*fxle->n2)]; |
| 10487 |
w = t - fxle->datfo_fc[i+ fxle->n1*(j+((k+fxle->n2-1)%fxle->n3)*fxle->n2)]; |
| 10488 |
if (fmin(x,fmin(y,fmin(z,fmin(u,fmin(v,w)))))<0) continue; |
| 10489 |
p=0.5*(u-x)/(u+x); |
| 10490 |
q=0.5*(v-y)/(v+y); |
| 10491 |
r=0.5*(w-z)/(w+z); |
| 10492 |
t=t+0.25*(p*(u-x)+q*(v-y)+r*(w-z)); |
| 10493 |
if (t<fabs(fxle->iso[1])*1.02) continue; |
| 10494 |
htest.peakHeight=t; |
| 10495 |
htest.frac.x = ((double) i + p +0.5)/fxle->n1; |
| 10496 |
htest.frac.y = ((double) j + q +0.5)/fxle->n2; |
| 10497 |
htest.frac.z = ((double) k + r +0.5)/fxle->n3; |
| 10498 |
mole.frac2kart( htest.frac, htest.pos); |
| 10499 |
if (!std_isfinite(htest.frac.x)||!std_isfinite(htest.frac.y)||!std_isfinite(htest.frac.z))continue; |
| 10500 |
ipeak++; |
| 10501 |
mole.pmin=qMin(mole.pmin, htest.peakHeight); |
| 10502 |
mole.pmax=qMax(mole.pmax, htest.peakHeight); |
| 10503 |
qpv->cutoff=0;//mole.pmin; |
| 10504 |
qpv->setMin(mole.pmin); |
| 10505 |
qpv->setMax(mole.pmax); |
| 10506 |
htest.Label=QString("Q%1").arg(ipeak,3,36,QChar('0')); |
| 10507 |
peaks.append(htest); |
| 10508 |
} |
| 10509 |
} |
| 10510 |
} |
| 10511 |
if (chgl->neutrons){ |
| 10512 |
for (int k=0;k<fxle->n3;k++){ |
| 10513 |
for (int j=0;j<fxle->n2;j++){ |
| 10514 |
for (int i=0;i<fxle->n1;i++){ |
| 10515 |
if (ipeak>MaxNumberOfPeaks) continue; |
| 10516 |
t = fxle->datfo_fc[i+ fxle->n1*(j+k*fxle->n2)]; |
| 10517 |
x = t - fxle->datfo_fc[((i+1)%fxle->n1) + fxle->n1*(j+k*fxle->n2)]; |
| 10518 |
y = t - fxle->datfo_fc[i+ fxle->n1*(((j+1)%fxle->n2)+k*fxle->n2)]; |
| 10519 |
z = t - fxle->datfo_fc[i+ fxle->n1*(j+((k+1)%fxle->n3)*fxle->n2)]; |
| 10520 |
u = t - fxle->datfo_fc[((i+fxle->n1-1)%fxle->n1)+ fxle->n1*(j+k*fxle->n2)]; |
| 10521 |
v = t - fxle->datfo_fc[i+ fxle->n1*(((j+fxle->n2-1)%fxle->n2)+k*fxle->n2)]; |
| 10522 |
w = t - fxle->datfo_fc[i+ fxle->n1*(j+((k+fxle->n2-1)%fxle->n3)*fxle->n2)]; |
| 10523 |
if (fmax(x,fmax(y,fmax(z,fmax(u,fmax(v,w)))))>0) continue; |
| 10524 |
p=0.5*(u-x)/(u+x); |
| 10525 |
q=0.5*(v-y)/(v+y); |
| 10526 |
r=0.5*(w-z)/(w+z); |
| 10527 |
t=t+0.25*(p*(u-x)+q*(v-y)+r*(w-z)); |
| 10528 |
if (t>-fabs(fxle->iso[1])*1.02) continue; |
| 10529 |
htest.peakHeight=t; |
| 10530 |
htest.frac.x = ((double) i + p +0.5)/fxle->n1; |
| 10531 |
htest.frac.y = ((double) j + q +0.5)/fxle->n2; |
| 10532 |
htest.frac.z = ((double) k + r +0.5)/fxle->n3; |
| 10533 |
mole.frac2kart( htest.frac, htest.pos); |
| 10534 |
if (!std_isfinite(htest.frac.x)||!std_isfinite(htest.frac.y)||!std_isfinite(htest.frac.z))continue; |
| 10535 |
ipeak++; |
| 10536 |
mole.pmin=qMin(mole.pmin, htest.peakHeight); |
| 10537 |
mole.pmax=qMax(mole.pmax, htest.peakHeight); |
| 10538 |
qpv->cutoff=0;//mole.pmin; |
| 10539 |
qpv->setMin(mole.pmin); |
| 10540 |
qpv->setMax(mole.pmax); |
| 10541 |
htest.Label=QString("Q%1").arg(ipeak,3,36,QChar('0')); |
| 10542 |
peaks.append(htest); |
| 10543 |
} |
| 10544 |
} |
| 10545 |
} |
| 10546 |
} |
| 10547 |
|
| 10548 |
#if (QT_VERSION >= 0x050000) |
| 10549 |
std::sort(peaks.begin(),peaks.end(),peakcomp ); |
| 10550 |
#else |
| 10551 |
qSort(peaks.begin(),peaks.end(),peakcomp ); |
| 10552 |
#endif |
| 10553 |
mole.asymm+=peaks; |
| 10554 |
mole.sdmcompleter(); |
| 10555 |
QList<MyAtom> duplicate; |
| 10556 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 10557 |
for (int j=i+1; j<mole.asymm.size(); j++){ |
| 10558 |
if ((mole.asymm.at(i).an>-1)||(mole.asymm.at(j).an>-1)) continue; |
| 10559 |
if (Distance(mole.asymm.at(i).pos,mole.asymm.at(j).pos)<0.1) duplicate.append(mole.asymm.at(j)); |
| 10560 |
} |
| 10561 |
} |
| 10562 |
//printf("Duplicate size %d\n",duplicate.size()); |
| 10563 |
for (int i=0; i<duplicate.size();i++) { |
| 10564 |
int rr=mole.asymm.indexOf(duplicate.at(i)); |
| 10565 |
if (rr<0) continue; |
| 10566 |
mole.asymm.removeAt(rr); |
| 10567 |
} |
| 10568 |
QTextCursor cursor = editor->textCursor(); |
| 10569 |
cursor.beginEditBlock(); |
| 10570 |
editor->replace->setText(""); |
| 10571 |
editor->searchLE->setText("^Q\\S+\\s+1\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s*"); |
| 10572 |
editor->replaceAll(); |
| 10573 |
editor->searchLE->setText(""); |
| 10574 |
cursor.movePosition(QTextCursor::End); |
| 10575 |
cursor.movePosition(QTextCursor::StartOfLine); |
| 10576 |
ipeak=1; |
| 10577 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 10578 |
if (mole.asymm.at(i).an>-1) continue; |
| 10579 |
mole.asymm[i].Label=QString("Q%1").arg(ipeak,3,36,QChar('0')).toUpper(); |
| 10580 |
ipeak++; |
| 10581 |
mole.asymm[i].orginalLine= |
| 10582 |
QString("%1 1 %2 %3 %4 %5 0.05 %6") |
| 10583 |
.arg(mole.asymm.at(i).Label,-4) |
| 10584 |
.arg(mole.asymm.at(i).frac.x,10,'f',6) |
| 10585 |
.arg(mole.asymm.at(i).frac.y,10,'f',6) |
| 10586 |
.arg(mole.asymm.at(i).frac.z,10,'f',6) |
| 10587 |
.arg(mole.asymm[i].sof_org=(10+(1.0/mole.asymm.at(i).style)),9,'f',5) |
| 10588 |
.arg(mole.asymm.at(i).peakHeight,9,'f',3) |
| 10589 |
; |
| 10590 |
mole.asymm[i].sof=mole.asymm[i].sof_org-10; |
| 10591 |
|
| 10592 |
cursor.insertText(mole.asymm[i].orginalLine); |
| 10593 |
cursor.insertText("\n"); |
| 10594 |
|
| 10595 |
} |
| 10596 |
cursor.endEditBlock(); |
| 10597 |
|
| 10598 |
mole.showatoms.clear(); |
| 10599 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 10600 |
mole.showatoms.append(mole.asymm.at(i)); |
| 10601 |
} |
| 10602 |
//// |
| 10603 |
bool growYes=chgl->fuse->isVisible (); |
| 10604 |
bool fuseYes=chgl->grow->isVisible (); |
| 10605 |
chgl->fuse->setVisible(true); |
| 10606 |
chgl->grow->setVisible(false); |
| 10607 |
mole.sdmcompleter(); |
| 10608 |
mole.showbonds = mole.connecting(mole.showatoms); |
| 10609 |
|
| 10610 |
chgl->mol->fuse(); |
| 10611 |
if (((!fuseYes)&&(growYes))||((!fuseYes)&&(!growYes))) chgl->mol->grow(); |
| 10612 |
else { |
| 10613 |
chgl->fuse->setVisible(false); |
| 10614 |
chgl->grow->setVisible(true); |
| 10615 |
} |
| 10616 |
infoKanalNews(mole.HumanSymmetry); |
| 10617 |
|
| 10618 |
loadMolInTest(); |
| 10619 |
chgl->update(); |
| 10620 |
} |
| 10621 |
|
| 10622 |
void Window::setShelxlPath(){ |
| 10623 |
QString s = |
| 10624 |
QFileDialog::getOpenFileName(this, "Path to SHELXL executable", shelxlPath,QString(),nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 10625 |
if (!s.isEmpty()){ |
| 10626 |
shelxlPath=s; |
| 10627 |
einstellung->beginGroup("Window"); |
| 10628 |
einstellung->setValue("SHELXL-PATH",shelxlPath); |
| 10629 |
einstellung->endGroup(); |
| 10630 |
if (shxPath!=NULL) shxPath->setText(shelxlPath); |
| 10631 |
} |
| 10632 |
} |
| 10633 |
|
| 10634 |
|
| 10635 |
void Window::setFFMPEGEXE(){ |
| 10636 |
mole.ffmpegexe= QFileDialog::getOpenFileName(this,"path to ffmpeg.exe","ffmpeg.exe","",nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 10637 |
if (ffmpegedt!=NULL) ffmpegedt->setText(mole.ffmpegexe); |
| 10638 |
einstellung->beginGroup("Window"); |
| 10639 |
einstellung->setValue("FFMPEG.EXE",mole.ffmpegexe); |
| 10640 |
einstellung->endGroup(); |
| 10641 |
|
| 10642 |
} |
| 10643 |
|
| 10644 |
void Window::setMP4(){ |
| 10645 |
QString pth=dirName; |
| 10646 |
pth.remove(resorins); |
| 10647 |
QString s = QFileDialog::getSaveFileName(this, |
| 10648 |
"save mp4 file", |
| 10649 |
QString("%1.mp4").arg(pth), |
| 10650 |
"Movie file (*.mp4)",nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 10651 |
if (mp4file!=NULL) mp4file->setText(s); |
| 10652 |
} |
| 10653 |
|
| 10654 |
void Window::updateOutput(){ |
| 10655 |
#if (QT_VERSION >= 0x050300) |
| 10656 |
if (runffmpeg->processId()) { |
| 10657 |
#else |
| 10658 |
if (runffmpeg->pid()) { |
| 10659 |
#endif |
| 10660 |
brs->show(); |
| 10661 |
QString s=brs->toPlainText(); |
| 10662 |
s.append(runffmpeg->readAllStandardOutput()); |
| 10663 |
s.append(runffmpeg->readAllStandardError()); |
| 10664 |
brs->setPlainText(s); |
| 10665 |
}else{ |
| 10666 |
brs->show(); |
| 10667 |
QString s=brs->toPlainText(); |
| 10668 |
s.append(runffmpeg->readAllStandardOutput()); |
| 10669 |
s.append(runffmpeg->readAllStandardError()); |
| 10670 |
brs->setPlainText(s); |
| 10671 |
QDir d=QDir::current(); |
| 10672 |
|
| 10673 |
QStringList clips; |
| 10674 |
clips.append("molisoclip*"); |
| 10675 |
clips = d.entryList(clips); |
| 10676 |
for (int i=0; i<clips.size();i++) QFile::remove(clips.at(i)); |
| 10677 |
QFile::remove("mcqwatermark.png"); |
| 10678 |
qint64 size = 0; |
| 10679 |
QFile myFile(fffn); |
| 10680 |
if (myFile.open(QIODevice::ReadOnly)){ |
| 10681 |
size = myFile.size(); //when file does open. |
| 10682 |
myFile.close(); |
| 10683 |
} |
| 10684 |
int kMGT=0; |
| 10685 |
double siz=(double)size; |
| 10686 |
while (siz>1024){ |
| 10687 |
siz/=1024; |
| 10688 |
kMGT++; |
| 10689 |
} |
| 10690 |
QString byte="B"; |
| 10691 |
switch (kMGT){ |
| 10692 |
case 1: byte.prepend("k"); break; |
| 10693 |
case 2: byte.prepend("M"); break; |
| 10694 |
case 3: byte.prepend("G"); break; |
| 10695 |
case 4: byte.prepend("T"); break; |
| 10696 |
} |
| 10697 |
QString fss=QString("%1 %2").arg(siz, 0, 'f', 2).arg(byte); |
| 10698 |
|
| 10699 |
ffl->setText(QString("finished! %1 has %2").arg(fffn).arg(fss)); |
| 10700 |
bar->hide(); |
| 10701 |
closeFF->show(); |
| 10702 |
} |
| 10703 |
} |
| 10704 |
|
| 10705 |
void Window::makeRotMovi(){ |
| 10706 |
QDialog *tdlg = new QDialog(this); |
| 10707 |
QGridLayout *l = new QGridLayout(tdlg); |
| 10708 |
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 10709 |
connect(buttonBox, SIGNAL(accepted()), tdlg, SLOT(accept())); |
| 10710 |
connect(buttonBox, SIGNAL(rejected()), tdlg, SLOT(reject())); |
| 10711 |
ffmpegedt = new QLineEdit(mole.ffmpegexe); |
| 10712 |
QPushButton *ffbrs = new QPushButton("Browse"); |
| 10713 |
connect(ffbrs,SIGNAL(pressed()),this,SLOT(setFFMPEGEXE())); |
| 10714 |
QLabel *ffmpegtxt =new QLabel("Path to ffmpeg.exe <br>(You need ffmpeg.exe. You can get it from here <a href=\"https://ffmpeg.org/download.html\">https://ffmpeg.org/download.html</a> )"); |
| 10715 |
ffmpegtxt->setOpenExternalLinks(true); |
| 10716 |
/* QRadioButton *hd720 = new QRadioButton("1280x720",tdlg); |
| 10717 |
QRadioButton *hd1080 = new QRadioButton("1920x1080",tdlg); |
| 10718 |
hd1080->setChecked(true);*/ |
| 10719 |
mp4file = new QLineEdit(QString("%1.mp4").arg(dirName)); |
| 10720 |
QPushButton *mp4brs = new QPushButton("Browse"); |
| 10721 |
connect(mp4brs,SIGNAL(pressed()),this,SLOT(setMP4())); |
| 10722 |
QSpinBox *dura= new QSpinBox(tdlg); |
| 10723 |
dura->setMinimum(5); |
| 10724 |
dura->setMaximum(300); |
| 10725 |
dura->setValue(10); |
| 10726 |
dura->setSuffix("s"); |
| 10727 |
QSpinBox *fps= new QSpinBox(tdlg); |
| 10728 |
fps->setMinimum(12); |
| 10729 |
fps->setMaximum(60); |
| 10730 |
fps->setValue(30); |
| 10731 |
|
| 10732 |
l->addWidget(ffmpegtxt,0,0,1,20); |
| 10733 |
l->addWidget(ffmpegedt,1,0,1,18); |
| 10734 |
l->addWidget(ffbrs,1,19,1,1); |
| 10735 |
//l->addWidget(hd720,2,0,1,5); |
| 10736 |
// l->addWidget(hd1080,2,6,1,5); |
| 10737 |
l->addWidget(new QLabel("Duration"),3,0,1,1); |
| 10738 |
l->addWidget(dura,3,1,1,1); |
| 10739 |
l->addWidget(new QLabel("Frames per second (FPS)"),4,0,1,1); |
| 10740 |
l->addWidget(fps,4,1,1,1); |
| 10741 |
l->addWidget(new QLabel("mp4 file name"),5,0,1,1); |
| 10742 |
l->addWidget(mp4file,5,1,1,18); |
| 10743 |
l->addWidget(mp4brs,5,19,1,1); |
| 10744 |
|
| 10745 |
l->addWidget(buttonBox,20,0,1,20); |
| 10746 |
if(tdlg->exec()==QDialog::Accepted) { |
| 10747 |
if (mole.ffmpegexe.isEmpty()||mp4file->text().isEmpty()) return; |
| 10748 |
QString fileName=mp4file->text(); |
| 10749 |
if (QFile::exists(fileName)) { |
| 10750 |
QString n=fileName; |
| 10751 |
QString re=QString("_%1_.mp4").arg(QDateTime::currentMSecsSinceEpoch (),0,36); |
| 10752 |
n.replace(QRegularExpression(".mp4$"),re); |
| 10753 |
QFile::rename(fileName,n); |
| 10754 |
} |
| 10755 |
int d,e; |
| 10756 |
// bool hd=(hd720->isChecked()) ; |
| 10757 |
int frameRate=fps->value(); |
| 10758 |
int frames = dura->value()*frameRate; |
| 10759 |
d = chgl->width(); |
| 10760 |
e = chgl->height(); |
| 10761 |
//printf("%dx%d\n",d,e); |
| 10762 |
//printf("!ungerade->%d %d\n",(d%2),d); |
| 10763 |
if (d%2){ |
| 10764 |
chgl->setMinimumWidth(d+1); |
| 10765 |
update(); |
| 10766 |
chgl->update(); |
| 10767 |
} |
| 10768 |
int wi = 0; |
| 10769 |
int hi = 0; |
| 10770 |
d = chgl->width(); |
| 10771 |
e = chgl->height(); |
| 10772 |
wi=d; |
| 10773 |
hi=e; |
| 10774 |
// printf("%dx%d\n",d,e); |
| 10775 |
//chgl->resize(wi,hi); |
| 10776 |
//f = chgl->myFont.pointSize (); |
| 10777 |
// h = chgl->MLegendFont.pointSize (); |
| 10778 |
//printf("%p\n",chgl); |
| 10779 |
QDialog *q =new QDialog(this); |
| 10780 |
q->setWindowTitle("Wait! Movie file creation in progress"); |
| 10781 |
bar = new QProgressBar(q); |
| 10782 |
bar->setMinimum(0); |
| 10783 |
bar->setMaximum(frames); |
| 10784 |
QGridLayout *g= new QGridLayout(q); |
| 10785 |
g->addWidget(bar,0,0); |
| 10786 |
ffl=new QLabel(QString("Please wait until movie is created!! %1 frames will be created and joined to a mp4 movie file.").arg(frames)); |
| 10787 |
g->addWidget(ffl,1,0); |
| 10788 |
brs=new QTextBrowser(q); |
| 10789 |
QTextCharFormat fmt; |
| 10790 |
brs->setFontFamily(FONTFAM); |
| 10791 |
QPalette p = brs->palette(); |
| 10792 |
p.setBrush(QPalette::Active,QPalette::Base,QColor("#242424")); |
| 10793 |
brs->setPalette (p ); |
| 10794 |
fmt.setFontFamily(FONTFAM); |
| 10795 |
fmt.setBackground(QColor("#242424")); |
| 10796 |
fmt.setForeground(QColor("#DDDD00")); |
| 10797 |
fmt.setFontWeight(50); |
| 10798 |
brs->setCurrentCharFormat(fmt); |
| 10799 |
brs->setWordWrapMode(QTextOption::WordWrap); |
| 10800 |
brs->setPlainText("====================\n Output of ffmpeg: \n====================\n\n"); |
| 10801 |
|
| 10802 |
brs->hide(); |
| 10803 |
g->addWidget(brs,2,0); |
| 10804 |
closeFF = new QPushButton("close", q); |
| 10805 |
g->addWidget(closeFF,3,0); |
| 10806 |
connect(closeFF,SIGNAL(released()),q,SLOT(close())); |
| 10807 |
closeFF->hide(); |
| 10808 |
|
| 10809 |
q->show(); |
| 10810 |
//double stepssi= 1.0/frames; |
| 10811 |
//QPixmap map; |
| 10812 |
//printf("stepsize=%f frames %d\n",stepssi,frames); |
| 10813 |
glReadBuffer(GL_FRONT); |
| 10814 |
for (int i=0; i<frames; i++){ |
| 10815 |
ffl->setText(QString("Please wait until movie is created!! %1 of %2").arg(i).arg(frames)); |
| 10816 |
bar->setValue(i); |
| 10817 |
char fname[255] ; |
| 10818 |
// statusBar()->showMessage(tr("create pic #%1 of %2").arg(i+1).arg(frames) ); |
| 10819 |
sprintf(fname, "molisoclip%04d.png", i); |
| 10820 |
//chgl->noWaitLabel=true; |
| 10821 |
//chgl->paparazi=true; |
| 10822 |
//glGetDoublev(GL_MODELVIEW_MATRIX,chgl->MM); |
| 10823 |
/* |
| 10824 |
map = chgl->renderPixmap(wi,hi); |
| 10825 |
//chgl->paparazi=false; |
| 10826 |
map.save(fname);*/ |
| 10827 |
QImage mapi=chgl->grabFramebuffer(); |
| 10828 |
int h = mapi.height(); |
| 10829 |
int w = mapi.width(); |
| 10830 |
mapi = mapi.scaled((w/2)*2,(h/2)*2); |
| 10831 |
mapi.save(fname); |
| 10832 |
chgl->rotY(18.0/(frames-1)); |
| 10833 |
//chgl->rotX(54.0/frames); |
| 10834 |
//glRotated(360.0/frames,0.0,1.0,0.0); |
| 10835 |
//glRotated(360/M_PI/frames,1.0,0.0,0.0); |
| 10836 |
chgl->update(); |
| 10837 |
//printf("%d/%d\n",i,frames); |
| 10838 |
q->update(); |
| 10839 |
q->repaint(); |
| 10840 |
} |
| 10841 |
if (!fileName.isEmpty()) { |
| 10842 |
QPixmap watermark = (chgl->dipc.name() == QString("#008080"))?QIcon(theIconPath+"IDEAL-text.png").pixmap(202, 76): |
| 10843 |
QIcon(theIconPath+"shelxle-text.png").pixmap(235, 91); |
| 10844 |
watermark.save("mcqwatermark.png"); |
| 10845 |
int wawi=watermark.width()+3; |
| 10846 |
int wahi=watermark.height()+3; |
| 10847 |
QStringList al; |
| 10848 |
al <<"-r"<< QString("%1").arg(frameRate)<< "-f"<< "image2"<< "-s"<< QString("%1x%2").arg(wi).arg(hi)//QString("%1").arg((hd)?"1280x720":"1920x1080") |
| 10849 |
<<"-start_number"<< "0"<< "-i"<< "molisoclip%04d.png"<< |
| 10850 |
"-i"<< "mcqwatermark.png"<< "-filter_complex"<< QString("[0:v][1:v] overlay=%1:%2").arg(wi-wawi).arg(hi-wahi)<< |
| 10851 |
"-vframes"<< QString("%1").arg(frames)<< "-codec:v"<< "libx264" <<"-crf" <<"25"<< "-pix_fmt"<< "yuv420p"<< fileName; |
| 10852 |
|
| 10853 |
runffmpeg = new QProcess(this); |
| 10854 |
QDir dn=QDir(QDir::current()); |
| 10855 |
runffmpeg->setWorkingDirectory(QDir::current().absolutePath()); // updateXLput() |
| 10856 |
connect(runffmpeg,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateOutput())); |
| 10857 |
connect(runffmpeg,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateOutput())); |
| 10858 |
connect(runffmpeg,SIGNAL(errorOccurred(QProcess::ProcessError)),this,SLOT(updateOutput())); |
| 10859 |
|
| 10860 |
runffmpeg->start(mole.ffmpegexe,al); |
| 10861 |
fffn=fileName; |
| 10862 |
updateOutput(); |
| 10863 |
|
| 10864 |
} |
| 10865 |
//chgl->myFont.setPointSize(f); |
| 10866 |
//chgl->MLegendFont.setPointSize(h); |
| 10867 |
//chgl->_win_width=d; |
| 10868 |
//chgl->_win_height=e; |
| 10869 |
//chgl->noWaitLabel=chgl->quickRot->isChecked(); |
| 10870 |
//q->close(); |
| 10871 |
// filmFred = new TMovieThread(frames,wi,hi,d,e,f,h,chgl,fileName,hd720->isChecked()); |
| 10872 |
//connect(filmFred,SIGNAL(finished ()),q,SLOT(close())); |
| 10873 |
// filmFred->start(); |
| 10874 |
} |
| 10875 |
} |
| 10876 |
|
| 10877 |
void Window::savePovRay(){ |
| 10878 |
// printf("save p o v r a y\n"); |
| 10879 |
QString s1="",s2="",s3=""; |
| 10880 |
GLdouble mv[16]; |
| 10881 |
chgl->makeCurrent(); |
| 10882 |
//glGetDoublev(GL_MODELVIEW_MATRIX, mv); |
| 10883 |
chgl->getMVmat(mv); |
| 10884 |
|
| 10885 |
QString povName = dirName, iniName,incName; |
| 10886 |
povName.replace(resorins,".pov"); |
| 10887 |
QString fn=QFileDialog::getSaveFileName(this, tr("Export POV-Ray scene"), povName, tr("POV-Ray files (*.pov)")); |
| 10888 |
if (fn.isEmpty()) return; |
| 10889 |
savePovInc(fn); |
| 10890 |
povName=fn; |
| 10891 |
iniName=fn; |
| 10892 |
iniName.replace(punktpov,".ini"); |
| 10893 |
incName=fn; |
| 10894 |
incName.replace(punktpov,".inc"); |
| 10895 |
pngName=fn; |
| 10896 |
pngName.replace(punktpov,".png"); |
| 10897 |
QFile f(fn); |
| 10898 |
QString headerPOV; // 1st part of PoV-Ray file |
| 10899 |
QString visableAtoms; // used to save ellipsoids of _un-selected_ atoms in _visable_ part of pov-file |
| 10900 |
QString hiddenAtoms; // used to save ellipsoids of _selected_ atoms in _hidden_ part of pov-file |
| 10901 |
QString hydrogenAtoms; // used to save hydrogens data |
| 10902 |
QString hiddenHAtoms; // used to save hydrogens data of _selected_ atoms in _hidden_ part of pov-file |
| 10903 |
QString qpeaks; //Q peaks... |
| 10904 |
QString unitCell; |
| 10905 |
QString densityMaps; //Fo and Fo-Fc map or the IDEAL BODD map. |
| 10906 |
QString labels; |
| 10907 |
QString bondsPOV; // used for bonds in povray |
| 10908 |
QString hidePOV; |
| 10909 |
QString ringsPOV; |
| 10910 |
QString voron; |
| 10911 |
QString footerPOV; |
| 10912 |
QString body; |
| 10913 |
bool foundInSelected = false; |
| 10914 |
GLdouble det=pow(mv[0]*mv[5]*mv[10] - mv[8]*mv[5]*mv[2] + mv[1]*mv[6]*mv[8] - mv[9]*mv[6]*mv[0] + mv[2]*mv[4]*mv[9] - mv[10]*mv[4]*mv[1], 1.0/3.0); |
| 10915 |
mv[0]/=det; mv[1]/=det; mv[2]/=det; mv[4]/=det; mv[5]/=det; mv[6]/=det; mv[8]/=det; mv[9]/=det; mv[10]/=det; |
| 10916 |
Matrix rm = Matrix(mv[0], mv[1], mv[2], mv[4], mv[5], mv[6], mv[8], mv[9], mv[10]); |
| 10917 |
//for (int i=0; i<16; i++) printf("%10.5f i=%d%c",mv[i],i,((i % 4)==3)?'\n':' '); |
| 10918 |
Matrix irm = inverse(rm); |
| 10919 |
// POV-Ray Header |
| 10920 |
headerPOV.append(QString("/*\n POV-Ray - 3.7 Scene Description File \n")); |
| 10921 |
headerPOV.append(QString("Experimental POV-ray shelXLe-exporter by K.Radacki and C.B.Hubschle\n")); |
| 10922 |
headerPOV.append(QString("This file is generated from: \n")); |
| 10923 |
headerPOV.append(QString("%1 \n*/\n\n").arg(dirName)); |
| 10924 |
headerPOV.append(QString("#version 3.7;\n")); |
| 10925 |
headerPOV.append(QString("global_settings{charset utf8}\n")); |
| 10926 |
headerPOV.append(QString("#include \"transforms.inc\"\n")); |
| 10927 |
headerPOV.append(QString("#include \"colors.inc\"\n")); |
| 10928 |
headerPOV.append(QString("#include \"textures.inc\"\n")); |
| 10929 |
//headerPOV.append(QString("#include \"metals.inc\"\n")); |
| 10930 |
headerPOV.append(QString("#include \"shapes.inc\"\n")); |
| 10931 |
headerPOV.append(QString("#include \"shapes2.inc\"\n")); |
| 10932 |
headerPOV.append(QString("global_settings { assumed_gamma 1.2 ambient_light rgb < 1, 1, 1 > }\n")); |
| 10933 |
|
| 10934 |
headerPOV.append(QString("#declare InvMat = transform {matrix \n<%1, %2, %3,\n %4, %5, %6,\n %7, %8, %9,\n 0.0, 0.0, 0.0>};\n") |
| 10935 |
.arg(irm.m11,9,'g',6) |
| 10936 |
.arg(irm.m12,9,'g',6) |
| 10937 |
.arg(irm.m13,9,'g',6) |
| 10938 |
.arg(irm.m21,9,'g',6) |
| 10939 |
.arg(irm.m22,9,'g',6) |
| 10940 |
.arg(irm.m23,9,'g',6) |
| 10941 |
.arg(irm.m31,9,'g',6) |
| 10942 |
.arg(irm.m32,9,'g',6) |
| 10943 |
.arg(irm.m33,9,'g',6)); |
| 10944 |
headerPOV.append(QString("#declare EyeDir = vtransform(<0,0,1>,InvMat);//This is for the labels. It moves them closer to You. change it to move all label.s\n")); |
| 10945 |
headerPOV.append(QString("#declare CameraDistance = %1;\n").arg((-mv[14]),0,'f',3)); |
| 10946 |
headerPOV.append(QString("#declare ViewAngle = %1;\n").arg(chgl->viewAngle,0,'f',3)); |
| 10947 |
|
| 10948 |
headerPOV.append(QString("#declare SCALE = %1/(image_width/image_height);// scale factor L=%2 dim=%3 %4 %5\n\n") |
| 10949 |
.arg(chgl->getScaleing()/(.34*det*29.0/(chgl->viewAngle))) |
| 10950 |
.arg(chgl->getScaleing()) |
| 10951 |
.arg(mole.dimension()) |
| 10952 |
.arg((.34*det*29.0/(chgl->viewAngle))) |
| 10953 |
.arg(det)); |
| 10954 |
|
| 10955 |
headerPOV.append(QString("camera { perspective\n")); |
| 10956 |
headerPOV.append(QString(" location < 0, 0 , CameraDistance >\n")); |
| 10957 |
headerPOV.append(QString(" right < -image_width/image_height, 0, 0>\n")); |
| 10958 |
headerPOV.append(QString(" look_at < 0, 0 , 0 >\n")); |
| 10959 |
headerPOV.append(QString(" angle ViewAngle\n}\n\n"));//.arg(chgl->viewAngle,7,'f',1)); |
| 10960 |
headerPOV.append(QString("#declare DrawAromaticRings = true; // You need to place Centroids in the center of each ring for this.\n")); |
| 10961 |
headerPOV.append(QString("#declare DrawRoundCorners = true;\n")); |
| 10962 |
headerPOV.append(QString("#declare BW = false; // true = Black&White false = Color\n")); |
| 10963 |
headerPOV.append(QString("#declare NoADP4Selected = true; // true = Visible false = Hidden\n")); |
| 10964 |
headerPOV.append(QString("#declare Hiso = false; // true = Uiso false = r=Bond_Radius*1.3*Prob\n")); |
| 10965 |
headerPOV.append(QString("#declare DrawHydrogens = true; // true = Visible false = Hidden\n")); |
| 10966 |
headerPOV.append(QString("/* 'Hydrogens' here are all atoms with an isotropic ADP. Atoms with anisotropic ADP are considered to be non Hydrogen atoms.*/ \n")); |
| 10967 |
//printf("sur vive %d %p \n",__LINE__,chgl->h_bonds); |
| 10968 |
//printf("sur vive %d %p \n",__LINE__,chgl->togUnit); |
| 10969 |
//printf("sur vive %d %p \n",__LINE__,chgl->atomLegend); |
| 10970 |
//printf("sur vive %d %p \n",__LINE__,chgl->qPeakBonds); |
| 10971 |
//printf("sur vive %d %d \n",__LINE__,chgl->mol->noQPeaksPlease); |
| 10972 |
//printf("sur vive %d %p \n",__LINE__,chgl->qPeakBonds); |
| 10973 |
headerPOV.append(QString("#declare DrawH_Bonds = %1; // true = Visible false = Hidden\n").arg(chgl->h_bonds->isChecked()?"true":"false")); |
| 10974 |
headerPOV.append(QString("#declare DrawUnitCell = %1; // true = Visible false = Hidden\n").arg(chgl->togUnit->isChecked()?"true":"false")); |
| 10975 |
headerPOV.append(QString("#declare CellWidth = 0.02; // line width of unit cell\n")); |
| 10976 |
headerPOV.append(QString("#declare DrawLegend = %1; // true = Visible false = Hidden\n").arg(chgl->atomLegend->isChecked()?"true":"false")); |
| 10977 |
headerPOV.append(QString("#declare DrawQPeaks = %1; // true = Visible false = Hidden\n").arg(chgl->mol->noQPeaksPlease?"false ":"true ")); |
| 10978 |
headerPOV.append(QString("#declare DrawQPeaksBonds = %1; // connecting lines between Q-peaks\n").arg(chgl->qPeakBonds->isChecked()?"true":"false")); |
| 10979 |
headerPOV.append(QString("#declare BGGradient = %1; // Background Gradient as in ShelXle!\n\n").arg(togBackGr->isChecked()?"true":"false")); |
| 10980 |
headerPOV.append(QString("#declare QPeakRad = %1; // icosahedron size\n").arg(chgl->mol->qPeakRad * 2.0)); |
| 10981 |
headerPOV.append(QString("#declare DrawMaps = %1;\n").arg((!chgl->fVertexes[0].isEmpty()||!chgl->fVertexes[1].isEmpty())?"true":"false")); |
| 10982 |
headerPOV.append(QString("#declare DrawFo_Fc = %1;\n").arg(chgl->fofcact->isChecked()?"true":"false")); |
| 10983 |
headerPOV.append(QString("#declare DrawFobserved = %1;\n").arg(chgl->foact->isChecked()?"true":"false")); |
| 10984 |
headerPOV.append(QString("#declare DrawWireframeMaps = %1;\n").arg((!chgl->fillMap->isChecked())?"true":"false")); |
| 10985 |
headerPOV.append(QString("#declare ForceWhiteBG = false;\n")); |
| 10986 |
headerPOV.append(QString("#declare TransparentBG = true ;\n")); |
| 10987 |
|
| 10988 |
headerPOV.append(QString("#declare UniColorBonds = %1;\n").arg((mole.bondColorStyle)?"true":"false")); |
| 10989 |
headerPOV.append(QString("#declare NoShadows = true;\n")); |
| 10990 |
headerPOV.append(QString("#declare DrawLabels = %1;\n").arg((togLabel->isChecked())?"true":"false")); |
| 10991 |
|
| 10992 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 10993 |
headerPOV.append(QString("#declare atomfont = \"C:/Windows/Fonts/Arial.ttf\"//replace by any font path you like and works on your system\n"));//.arg(chgl->myFont.rawName())); |
| 10994 |
#elif defined Q_WS_MAC || defined Q_OS_MAC |
| 10995 |
headerPOV.append(QString("#declare atomfont = \"/System/Library/Fonts/Supplemental/Arial.ttf\"//replace by any font path you like and works on your system\n")); |
| 10996 |
#else |
| 10997 |
headerPOV.append(QString("#declare atomfont = \"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf\"//replace by any font path you like and works on your system\n")); |
| 10998 |
#endif |
| 10999 |
headerPOV.append(QString("//ADP probability\n" |
| 11000 |
"//#declare Prob = 0.76; // 10%\n" |
| 11001 |
"//#declare Prob = 1.1932; // 30%\n" |
| 11002 |
"//#declare Prob = 1.3672; // 40%\n" |
| 11003 |
"#declare Prob = 1.5382; // 50%\n" |
| 11004 |
"//#declare Prob = 1.7164; // 60%\n" |
| 11005 |
"//#declare Prob = 1.9144; // 70%\n" |
| 11006 |
"//#declare Prob = 2.5; // 90%\n" |
| 11007 |
"\n")); |
| 11008 |
headerPOV.append(QString("#declare CubeSize = 0.2; // cube size for NPD-atom\n")); |
| 11009 |
headerPOV.append(QString("#declare Origin = < 0,0,0>; // declare origin \n\n")); |
| 11010 |
headerPOV.append(QString("#include \"%1\"//<-This contains additional declarations.\n\n").arg(incName)); |
| 11011 |
|
| 11012 |
headerPOV.append(QString("#if (!TransparentBG)\n")); |
| 11013 |
headerPOV.append(QString("#if (ForceWhiteBG)\n")); |
| 11014 |
headerPOV.append(QString("background { color White}\n#else\n")); |
| 11015 |
headerPOV.append(QString("#if (BW)\n background { color rgb< %1, %1, %1> }\n#else\n").arg(chgl->backGroundColor.valueF())); |
| 11016 |
headerPOV.append(QString("background { color rgb<%1,%2,%3> }\n#end\n") |
| 11017 |
.arg(chgl->backGroundColor.redF() ,9,'f',5) |
| 11018 |
.arg(chgl->backGroundColor.greenF(),9,'f',5) |
| 11019 |
.arg(chgl->backGroundColor.blueF() ,9,'f',5)); |
| 11020 |
headerPOV.append(QString("//Gradient Background\n")); |
| 11021 |
headerPOV.append(QString("#if (BGGradient)\n")); |
| 11022 |
headerPOV.append(QString("#declare dis=CameraDistance/tan(radians(ViewAngle/2));\n")); |
| 11023 |
headerPOV.append(QString("mesh {\n")); |
| 11024 |
headerPOV.append(QString("triangle{ <-image_width,-image_height,-dis>,< image_width,-image_height,-dis>,<-image_width, image_height,-dis> uv_vectors <0,0>, <0,0>, <0,1>}\n")); |
| 11025 |
headerPOV.append(QString("triangle{<-image_width, image_height,-dis>,< image_width, image_height,-dis>,< image_width,-image_height,-dis> uv_vectors <0,1>, <0,1>, <0,0>}\n")); |
| 11026 |
headerPOV.append(QString("texture {uv_mapping pigment {gradient <0,1,0>color_map {[0.0 color rgbt <1.0, 1.0, 1.0, 0.5>][1.0 color rgbt <0.3, 0.3, 0.3, 0.3>]}}finish { ambient 0.5 }}}\n")); |
| 11027 |
headerPOV.append(QString("#end\n")); |
| 11028 |
headerPOV.append(QString("#end //force white bg\n")); |
| 11029 |
headerPOV.append(QString("#end //not transparent bg\n")); |
| 11030 |
headerPOV.append(QString("light_source { < -100.0 , 100.0 , 100.0 > color rgb<1.0,1.0,1.0> parallel}\n" |
| 11031 |
"//================================================================================================================================================\n")); |
| 11032 |
headerPOV.append(QString("#if (DrawLegend)\n")); |
| 11033 |
headerPOV.append(QString("#declare ww=tan(radians(ViewAngle/2))*CameraDistance;\n")); |
| 11034 |
headerPOV.append(QString("#declare hh=ww/image_width*image_height;\n")); |
| 11035 |
//headerPOV.append(QString("#debug \"HALLOHALLO\\n\"\n")); |
| 11036 |
//headerPOV.append(QString("#debug concat(\"Value is:\",str(ww,0,6),\"\\n\")\n")); |
| 11037 |
densityMaps.append(QString("\n//Density Maps \n#if (DrawMaps)\n#if (DrawFo_Fc)\n")); |
| 11038 |
if (!chgl->fVertexes[0].isEmpty()){ |
| 11039 |
densityMaps.append(QString("#if (DrawWireframeMaps)\n")); |
| 11040 |
|
| 11041 |
densityMaps.append(QString("union{\n")); |
| 11042 |
for (int i=0; i<chgl->fVertexes[0].size();i+=9){ |
| 11043 |
if (Distance( |
| 11044 |
V3( chgl->fVertexes[0].at(i+0), chgl->fVertexes[0].at(i+1), chgl->fVertexes[0].at(i+2)), |
| 11045 |
V3( chgl->fVertexes[0].at(i+3), chgl->fVertexes[0].at(i+4), chgl->fVertexes[0].at(i+5) |
| 11046 |
))>0.0001) |
| 11047 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{diffPosCol}}\n") |
| 11048 |
.arg(chgl->fVertexes[0].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11049 |
.arg(chgl->fVertexes[0].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11050 |
.arg(chgl->fVertexes[0].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11051 |
.arg(chgl->fVertexes[0].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11052 |
.arg(chgl->fVertexes[0].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11053 |
.arg(chgl->fVertexes[0].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11054 |
.arg(chgl->linwidth*0.01)); |
| 11055 |
if (Distance( |
| 11056 |
V3( chgl->fVertexes[0].at(i+3), chgl->fVertexes[0].at(i+4), chgl->fVertexes[0].at(i+5)), |
| 11057 |
V3( chgl->fVertexes[0].at(i+6), chgl->fVertexes[0].at(i+7), chgl->fVertexes[0].at(i+8) |
| 11058 |
))>0.0001) |
| 11059 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{diffPosCol}}\n") |
| 11060 |
.arg(chgl->fVertexes[0].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11061 |
.arg(chgl->fVertexes[0].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11062 |
.arg(chgl->fVertexes[0].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11063 |
.arg(chgl->fVertexes[0].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11064 |
.arg(chgl->fVertexes[0].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11065 |
.arg(chgl->fVertexes[0].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11066 |
.arg(chgl->linwidth*0.01)); |
| 11067 |
if (Distance( |
| 11068 |
V3( chgl->fVertexes[0].at(i+6), chgl->fVertexes[0].at(i+7), chgl->fVertexes[0].at(i+8)), |
| 11069 |
V3( chgl->fVertexes[0].at(i+0), chgl->fVertexes[0].at(i+1), chgl->fVertexes[0].at(i+2) |
| 11070 |
))>0.0001) |
| 11071 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{diffPosCol}}\n") |
| 11072 |
.arg(chgl->fVertexes[0].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11073 |
.arg(chgl->fVertexes[0].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11074 |
.arg(chgl->fVertexes[0].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11075 |
.arg(chgl->fVertexes[0].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11076 |
.arg(chgl->fVertexes[0].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11077 |
.arg(chgl->fVertexes[0].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11078 |
.arg(chgl->linwidth*0.01)); |
| 11079 |
} |
| 11080 |
densityMaps.append(QString("}")); |
| 11081 |
densityMaps.append(QString("#else\n")); |
| 11082 |
densityMaps.append(QString("mesh {\n")); |
| 11083 |
for (int i=0; i<chgl->fVertexes[0].size();i+=9){ |
| 11084 |
densityMaps.append(QString("smooth_triangle{\n<%1,%2,%3>,<%10,%11,%12>,\n<%4,%5,%6>,<%13,%14,%15>,\n<%7,%8,%9>,<%16,%17,%19>\n}\n") |
| 11085 |
.arg(chgl->fVertexes[0].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11086 |
.arg(chgl->fVertexes[0].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11087 |
.arg(chgl->fVertexes[0].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11088 |
.arg(chgl->fVertexes[0].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11089 |
.arg(chgl->fVertexes[0].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11090 |
.arg(chgl->fVertexes[0].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11091 |
.arg(chgl->fVertexes[0].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11092 |
.arg(chgl->fVertexes[0].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11093 |
.arg(chgl->fVertexes[0].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11094 |
.arg(chgl->fNormals[0].at(i+0),10,'g',6) |
| 11095 |
.arg(chgl->fNormals[0].at(i+1),10,'g',6) |
| 11096 |
.arg(chgl->fNormals[0].at(i+2),10,'g',6) |
| 11097 |
.arg(chgl->fNormals[0].at(i+3),10,'g',6) |
| 11098 |
.arg(chgl->fNormals[0].at(i+4),10,'g',6) |
| 11099 |
.arg(chgl->fNormals[0].at(i+5),10,'g',6) |
| 11100 |
.arg(chgl->fNormals[0].at(i+6),10,'g',6) |
| 11101 |
.arg(chgl->fNormals[0].at(i+7),10,'g',6) |
| 11102 |
.arg(chgl->fNormals[0].at(i+8),10,'g',6) |
| 11103 |
); |
| 11104 |
} |
| 11105 |
densityMaps.append(QString("texture {diffPosCol}\n}\n")); |
| 11106 |
densityMaps.append(QString("#end\n")); |
| 11107 |
} |
| 11108 |
if (!chgl->fVertexes[1].isEmpty()){ |
| 11109 |
|
| 11110 |
densityMaps.append(QString("#if (DrawWireframeMaps)\n")); |
| 11111 |
|
| 11112 |
densityMaps.append(QString("union{\n")); |
| 11113 |
for (int i=0; i<chgl->fVertexes[1].size();i+=9){ |
| 11114 |
if (Distance( |
| 11115 |
V3( chgl->fVertexes[1].at(i+0), chgl->fVertexes[1].at(i+1), chgl->fVertexes[1].at(i+2)), |
| 11116 |
V3( chgl->fVertexes[1].at(i+3), chgl->fVertexes[1].at(i+4), chgl->fVertexes[1].at(i+5) |
| 11117 |
))>0.0001) |
| 11118 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{diffMinCol}}\n") |
| 11119 |
.arg(chgl->fVertexes[1].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11120 |
.arg(chgl->fVertexes[1].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11121 |
.arg(chgl->fVertexes[1].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11122 |
.arg(chgl->fVertexes[1].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11123 |
.arg(chgl->fVertexes[1].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11124 |
.arg(chgl->fVertexes[1].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11125 |
.arg(chgl->linwidth*0.01) |
| 11126 |
); |
| 11127 |
if (Distance( |
| 11128 |
V3( chgl->fVertexes[1].at(i+3), chgl->fVertexes[1].at(i+4), chgl->fVertexes[1].at(i+5)), |
| 11129 |
V3( chgl->fVertexes[1].at(i+6), chgl->fVertexes[1].at(i+7), chgl->fVertexes[1].at(i+8) |
| 11130 |
))>0.0001) |
| 11131 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{diffMinCol}}\n") |
| 11132 |
.arg(chgl->fVertexes[1].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11133 |
.arg(chgl->fVertexes[1].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11134 |
.arg(chgl->fVertexes[1].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11135 |
.arg(chgl->fVertexes[1].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11136 |
.arg(chgl->fVertexes[1].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11137 |
.arg(chgl->fVertexes[1].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11138 |
.arg(chgl->linwidth*0.01) |
| 11139 |
); |
| 11140 |
if (Distance( |
| 11141 |
V3( chgl->fVertexes[1].at(i+6), chgl->fVertexes[1].at(i+7), chgl->fVertexes[1].at(i+8)), |
| 11142 |
V3( chgl->fVertexes[1].at(i+0), chgl->fVertexes[1].at(i+1), chgl->fVertexes[1].at(i+2) |
| 11143 |
))>0.0001) |
| 11144 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{diffMinCol}}\n") |
| 11145 |
.arg(chgl->fVertexes[1].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11146 |
.arg(chgl->fVertexes[1].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11147 |
.arg(chgl->fVertexes[1].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11148 |
.arg(chgl->fVertexes[1].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11149 |
.arg(chgl->fVertexes[1].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11150 |
.arg(chgl->fVertexes[1].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11151 |
.arg(chgl->linwidth*0.01) |
| 11152 |
); |
| 11153 |
} |
| 11154 |
densityMaps.append(QString("}")); |
| 11155 |
densityMaps.append(QString("#else\n")); |
| 11156 |
densityMaps.append(QString("mesh{\n")); |
| 11157 |
for (int i=0; i<chgl->fVertexes[1].size();i+=9){ |
| 11158 |
densityMaps.append(QString("smooth_triangle{\n<%1,%2,%3>,<%10,%11,%12>,\n<%4,%5,%6>,<%13,%14,%15>,\n<%7,%8,%9>,<%16,%17,%19>\n}\n") |
| 11159 |
.arg(chgl->fVertexes[1].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11160 |
.arg(chgl->fVertexes[1].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11161 |
.arg(chgl->fVertexes[1].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11162 |
.arg(chgl->fVertexes[1].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11163 |
.arg(chgl->fVertexes[1].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11164 |
.arg(chgl->fVertexes[1].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11165 |
.arg(chgl->fVertexes[1].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11166 |
.arg(chgl->fVertexes[1].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11167 |
.arg(chgl->fVertexes[1].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11168 |
.arg(chgl->fNormals[1].at(i+0),10,'g',6) |
| 11169 |
.arg(chgl->fNormals[1].at(i+1),10,'g',6) |
| 11170 |
.arg(chgl->fNormals[1].at(i+2),10,'g',6) |
| 11171 |
.arg(chgl->fNormals[1].at(i+3),10,'g',6) |
| 11172 |
.arg(chgl->fNormals[1].at(i+4),10,'g',6) |
| 11173 |
.arg(chgl->fNormals[1].at(i+5),10,'g',6) |
| 11174 |
.arg(chgl->fNormals[1].at(i+6),10,'g',6) |
| 11175 |
.arg(chgl->fNormals[1].at(i+7),10,'g',6) |
| 11176 |
.arg(chgl->fNormals[1].at(i+8),10,'g',6) |
| 11177 |
); |
| 11178 |
} |
| 11179 |
densityMaps.append(QString("texture {diffMinCol}\n}\n")); |
| 11180 |
densityMaps.append(QString("#end\n")); |
| 11181 |
} |
| 11182 |
if (!chgl->fVertexes[2].isEmpty()){ |
| 11183 |
densityMaps.append(QString("#end\n\n#if (DrawFobserved)\n")); |
| 11184 |
densityMaps.append(QString("#if (DrawWireframeMaps)\n")); |
| 11185 |
densityMaps.append(QString("union{\n")); |
| 11186 |
for (int i=0; i<chgl->fVertexes[2].size();i+=9){ |
| 11187 |
if (Distance( |
| 11188 |
V3( chgl->fVertexes[2].at(i+0), chgl->fVertexes[2].at(i+1), chgl->fVertexes[2].at(i+2)), |
| 11189 |
V3( chgl->fVertexes[2].at(i+3), chgl->fVertexes[2].at(i+4), chgl->fVertexes[2].at(i+5) |
| 11190 |
))>0.0001) |
| 11191 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>, %7 texture{FobsPosCol}}\n") |
| 11192 |
.arg(chgl->fVertexes[2].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11193 |
.arg(chgl->fVertexes[2].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11194 |
.arg(chgl->fVertexes[2].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11195 |
.arg(chgl->fVertexes[2].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11196 |
.arg(chgl->fVertexes[2].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11197 |
.arg(chgl->fVertexes[2].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11198 |
.arg(chgl->linwidth*0.01) |
| 11199 |
); |
| 11200 |
if (Distance( |
| 11201 |
V3( chgl->fVertexes[2].at(i+3), chgl->fVertexes[2].at(i+4), chgl->fVertexes[2].at(i+5)), |
| 11202 |
V3( chgl->fVertexes[2].at(i+6), chgl->fVertexes[2].at(i+7), chgl->fVertexes[2].at(i+8) |
| 11203 |
))>0.0001) |
| 11204 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>, %7 texture{FobsPosCol}}\n") |
| 11205 |
.arg(chgl->fVertexes[2].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11206 |
.arg(chgl->fVertexes[2].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11207 |
.arg(chgl->fVertexes[2].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11208 |
.arg(chgl->fVertexes[2].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11209 |
.arg(chgl->fVertexes[2].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11210 |
.arg(chgl->fVertexes[2].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11211 |
.arg(chgl->linwidth*0.01) |
| 11212 |
); |
| 11213 |
if (Distance( |
| 11214 |
V3( chgl->fVertexes[2].at(i+6), chgl->fVertexes[2].at(i+7), chgl->fVertexes[2].at(i+8)), |
| 11215 |
V3( chgl->fVertexes[2].at(i+0), chgl->fVertexes[2].at(i+1), chgl->fVertexes[2].at(i+2) |
| 11216 |
))>0.0001) |
| 11217 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>, %7 texture{FobsPosCol}}\n") |
| 11218 |
.arg(chgl->fVertexes[2].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11219 |
.arg(chgl->fVertexes[2].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11220 |
.arg(chgl->fVertexes[2].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11221 |
.arg(chgl->fVertexes[2].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11222 |
.arg(chgl->fVertexes[2].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11223 |
.arg(chgl->fVertexes[2].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11224 |
.arg(chgl->linwidth*0.01) |
| 11225 |
); |
| 11226 |
} |
| 11227 |
densityMaps.append(QString("}")); |
| 11228 |
densityMaps.append(QString("#else\n")); |
| 11229 |
densityMaps.append(QString("mesh{\n")); |
| 11230 |
for (int i=0; i<chgl->fVertexes[2].size();i+=9){ |
| 11231 |
densityMaps.append(QString("smooth_triangle{\n<%1,%2,%3>,<%10,%11,%12>,\n<%4,%5,%6>,<%13,%14,%15>,\n<%7,%8,%9>,<%16,%17,%19>\n}\n") |
| 11232 |
.arg(chgl->fVertexes[2].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11233 |
.arg(chgl->fVertexes[2].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11234 |
.arg(chgl->fVertexes[2].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11235 |
.arg(chgl->fVertexes[2].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11236 |
.arg(chgl->fVertexes[2].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11237 |
.arg(chgl->fVertexes[2].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11238 |
.arg(chgl->fVertexes[2].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11239 |
.arg(chgl->fVertexes[2].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11240 |
.arg(chgl->fVertexes[2].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11241 |
.arg(chgl->fNormals[2].at(i+0),10,'g',6) |
| 11242 |
.arg(chgl->fNormals[2].at(i+1),10,'g',6) |
| 11243 |
.arg(chgl->fNormals[2].at(i+2),10,'g',6) |
| 11244 |
.arg(chgl->fNormals[2].at(i+3),10,'g',6) |
| 11245 |
.arg(chgl->fNormals[2].at(i+4),10,'g',6) |
| 11246 |
.arg(chgl->fNormals[2].at(i+5),10,'g',6) |
| 11247 |
.arg(chgl->fNormals[2].at(i+6),10,'g',6) |
| 11248 |
.arg(chgl->fNormals[2].at(i+7),10,'g',6) |
| 11249 |
.arg(chgl->fNormals[2].at(i+8),10,'g',6) |
| 11250 |
); |
| 11251 |
} |
| 11252 |
densityMaps.append(QString("texture {FobsPosCol}\n}\n")); |
| 11253 |
densityMaps.append(QString("#end\n")); |
| 11254 |
} |
| 11255 |
if (!chgl->fVertexes[3].isEmpty()){ |
| 11256 |
densityMaps.append(QString("#if (DrawWireframeMaps)\n")); |
| 11257 |
|
| 11258 |
densityMaps.append(QString("union{\n")); |
| 11259 |
for (int i=0; i<chgl->fVertexes[3].size();i+=9){ |
| 11260 |
if (Distance( |
| 11261 |
V3( chgl->fVertexes[3].at(i+0), chgl->fVertexes[3].at(i+1), chgl->fVertexes[3].at(i+2)), |
| 11262 |
V3( chgl->fVertexes[3].at(i+3), chgl->fVertexes[3].at(i+4), chgl->fVertexes[3].at(i+5) |
| 11263 |
))>0.0001) |
| 11264 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>, %7 texture{FobsMinCol}}\n") |
| 11265 |
.arg(chgl->fVertexes[3].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11266 |
.arg(chgl->fVertexes[3].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11267 |
.arg(chgl->fVertexes[3].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11268 |
.arg(chgl->fVertexes[3].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11269 |
.arg(chgl->fVertexes[3].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11270 |
.arg(chgl->fVertexes[3].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11271 |
.arg(chgl->linwidth*0.01) |
| 11272 |
); |
| 11273 |
if (Distance( |
| 11274 |
V3( chgl->fVertexes[3].at(i+3), chgl->fVertexes[3].at(i+4), chgl->fVertexes[3].at(i+5)), |
| 11275 |
V3( chgl->fVertexes[3].at(i+6), chgl->fVertexes[3].at(i+7), chgl->fVertexes[3].at(i+8) |
| 11276 |
))>0.0001) |
| 11277 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{FobsMinCol}}\n") |
| 11278 |
.arg(chgl->fVertexes[3].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11279 |
.arg(chgl->fVertexes[3].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11280 |
.arg(chgl->fVertexes[3].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11281 |
.arg(chgl->fVertexes[3].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11282 |
.arg(chgl->fVertexes[3].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11283 |
.arg(chgl->fVertexes[3].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11284 |
.arg(chgl->linwidth*0.01) |
| 11285 |
); |
| 11286 |
if (Distance( |
| 11287 |
V3( chgl->fVertexes[3].at(i+6), chgl->fVertexes[3].at(i+7), chgl->fVertexes[3].at(i+8)), |
| 11288 |
V3( chgl->fVertexes[3].at(i+0), chgl->fVertexes[3].at(i+1), chgl->fVertexes[3].at(i+2) |
| 11289 |
))>0.0001) |
| 11290 |
densityMaps.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,%7 texture{FobsMinCol}}\n") |
| 11291 |
.arg(chgl->fVertexes[3].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11292 |
.arg(chgl->fVertexes[3].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11293 |
.arg(chgl->fVertexes[3].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11294 |
.arg(chgl->fVertexes[3].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11295 |
.arg(chgl->fVertexes[3].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11296 |
.arg(chgl->fVertexes[3].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11297 |
.arg(chgl->linwidth*0.01) |
| 11298 |
); |
| 11299 |
} |
| 11300 |
densityMaps.append(QString("}")); |
| 11301 |
densityMaps.append(QString("#else\n")); |
| 11302 |
densityMaps.append(QString("mesh{\n")); |
| 11303 |
for (int i=0; i<chgl->fVertexes[3].size();i+=9){ |
| 11304 |
densityMaps.append(QString("smooth_triangle{\n<%1,%2,%3>,<%10,%11,%12>,\n<%4,%5,%6>,<%13,%14,%15>,\n<%7,%8,%9>,<%16,%17,%19>\n}\n") |
| 11305 |
.arg(chgl->fVertexes[3].at(i+0)-chgl->altemitte.x,10,'g',6) |
| 11306 |
.arg(chgl->fVertexes[3].at(i+1)-chgl->altemitte.y,10,'g',6) |
| 11307 |
.arg(chgl->fVertexes[3].at(i+2)-chgl->altemitte.z,10,'g',6) |
| 11308 |
.arg(chgl->fVertexes[3].at(i+3)-chgl->altemitte.x,10,'g',6) |
| 11309 |
.arg(chgl->fVertexes[3].at(i+4)-chgl->altemitte.y,10,'g',6) |
| 11310 |
.arg(chgl->fVertexes[3].at(i+5)-chgl->altemitte.z,10,'g',6) |
| 11311 |
.arg(chgl->fVertexes[3].at(i+6)-chgl->altemitte.x,10,'g',6) |
| 11312 |
.arg(chgl->fVertexes[3].at(i+7)-chgl->altemitte.y,10,'g',6) |
| 11313 |
.arg(chgl->fVertexes[3].at(i+8)-chgl->altemitte.z,10,'g',6) |
| 11314 |
.arg(chgl->fNormals[3].at(i+0),10,'g',6) |
| 11315 |
.arg(chgl->fNormals[3].at(i+1),10,'g',6) |
| 11316 |
.arg(chgl->fNormals[3].at(i+2),10,'g',6) |
| 11317 |
.arg(chgl->fNormals[3].at(i+3),10,'g',6) |
| 11318 |
.arg(chgl->fNormals[3].at(i+4),10,'g',6) |
| 11319 |
.arg(chgl->fNormals[3].at(i+5),10,'g',6) |
| 11320 |
.arg(chgl->fNormals[3].at(i+6),10,'g',6) |
| 11321 |
.arg(chgl->fNormals[3].at(i+7),10,'g',6) |
| 11322 |
.arg(chgl->fNormals[3].at(i+8),10,'g',6) |
| 11323 |
); |
| 11324 |
} |
| 11325 |
densityMaps.append(QString("texture {FobsMinCol}\n}\n")); |
| 11326 |
densityMaps.append(QString("#end\n")); |
| 11327 |
} |
| 11328 |
densityMaps.append(QString("#end\n#end // maps\n\n")); |
| 11329 |
if (!chgl->mol->vtriangles.isEmpty()){ |
| 11330 |
voron.append(QString("//voronoij polyherodron \n")); |
| 11331 |
|
| 11332 |
for (int k=0; k<editor->sfac.size();k++){ |
| 11333 |
voron.append(QString("#declare _%1_%2_ = texture{pigment{color rgbt< %3, %4, %5, %6>}}\n") |
| 11334 |
.arg(mole.pse(editor->sfac.at(k))) |
| 11335 |
.arg("a") |
| 11336 |
|
| 11337 |
.arg(mole.AtomColor[editor->sfac.at(k)].redF()) |
| 11338 |
.arg(mole.AtomColor[editor->sfac.at(k)].greenF()) |
| 11339 |
.arg(mole.AtomColor[editor->sfac.at(k)].blueF()) |
| 11340 |
.arg("0.97") |
| 11341 |
); |
| 11342 |
voron.append(QString("#declare _%1_%2_ = texture{pigment{color rgbt< %3, %4, %5, %6>}}\n") |
| 11343 |
.arg(mole.pse(editor->sfac.at(k))) |
| 11344 |
.arg("b") |
| 11345 |
.arg(mole.AtomColor[editor->sfac.at(k)].redF()) |
| 11346 |
.arg(mole.AtomColor[editor->sfac.at(k)].greenF()) |
| 11347 |
.arg(mole.AtomColor[editor->sfac.at(k)].blueF()) |
| 11348 |
.arg("0.4") |
| 11349 |
); |
| 11350 |
} |
| 11351 |
voron.append(QString("union{\n")); |
| 11352 |
for (int ti=0; ti<mole.vtriangles.size(); ti++){ |
| 11353 |
voron.append(QString("cylinder {< %1, %2, %3 >,< %4, %5, %6>,0.01 texture{pigment{color rgbt< %7, %8, %9, 0.5>}}}\n") |
| 11354 |
.arg(mole.vtriangles.at(ti).verts0.x-chgl->altemitte.x) |
| 11355 |
.arg(mole.vtriangles.at(ti).verts0.y-chgl->altemitte.y) |
| 11356 |
.arg(mole.vtriangles.at(ti).verts0.z-chgl->altemitte.z) |
| 11357 |
.arg(mole.vtriangles.at(ti).verts1.x-chgl->altemitte.x) |
| 11358 |
.arg(mole.vtriangles.at(ti).verts1.y-chgl->altemitte.y) |
| 11359 |
.arg(mole.vtriangles.at(ti).verts1.z-chgl->altemitte.z) |
| 11360 |
.arg(mole.AtomColor[mole.vtriangles.at(ti).acol].redF()) |
| 11361 |
.arg(mole.AtomColor[mole.vtriangles.at(ti).acol].greenF()) |
| 11362 |
.arg(mole.AtomColor[mole.vtriangles.at(ti).acol].blueF()) |
| 11363 |
); |
| 11364 |
} |
| 11365 |
voron.append(QString("}\nmesh{\n")); |
| 11366 |
for (int ti=0; ti<mole.vtriangles.size(); ti++){ |
| 11367 |
voron.append(QString("triangle{< %1, %2, %3>,< %4, %5, %6>,< %7, %8, %9>\n") |
| 11368 |
.arg(mole.vtriangles.at(ti).mid.x-chgl->altemitte.x) |
| 11369 |
.arg(mole.vtriangles.at(ti).mid.y-chgl->altemitte.y) |
| 11370 |
.arg(mole.vtriangles.at(ti).mid.z-chgl->altemitte.z) |
| 11371 |
.arg(mole.vtriangles.at(ti).verts0.x-chgl->altemitte.x) |
| 11372 |
.arg(mole.vtriangles.at(ti).verts0.y-chgl->altemitte.y) |
| 11373 |
.arg(mole.vtriangles.at(ti).verts0.z-chgl->altemitte.z) |
| 11374 |
.arg(mole.vtriangles.at(ti).verts1.x-chgl->altemitte.x) |
| 11375 |
.arg(mole.vtriangles.at(ti).verts1.y-chgl->altemitte.y) |
| 11376 |
.arg(mole.vtriangles.at(ti).verts1.z-chgl->altemitte.z) |
| 11377 |
); |
| 11378 |
voron.append(QString("texture { _%1_%2_ }}\n").arg(mole.pse(mole.vtriangles.at(ti).acol)).arg((mole.vtriangles.at(ti).intra)?"a":"b")); |
| 11379 |
} |
| 11380 |
voron.append(QString("} //voronoij\n")); |
| 11381 |
} |
| 11382 |
body.clear(); |
| 11383 |
for (int i=0,j=0; i<mole.legendAtoms.size();i++){ |
| 11384 |
if (mole.legendAtoms.at(i).hidden) continue; |
| 11385 |
if (mole.legendAtoms.at(i).an<0){ |
| 11386 |
body.append(QString("#if (BW)\nqpeak(<-ww/1.025,-hh/1.25+%1*hh/18,0>,QPeakRad*4*ViewAngle/29.0,0.6,0.6,0.6,%1)\n" |
| 11387 |
"#else\nqpeak(<-ww/1.025,-hh/1.08+%2*hh/18,0>,QPeakRad*4*ViewAngle/29.0,0.9,0.5,0.0,%1)\n#end\n") |
| 11388 |
.arg(mole.legendAtoms.at(i).an) |
| 11389 |
.arg(j) |
| 11390 |
);// |
| 11391 |
}else{ |
| 11392 |
if (chgl->mol->AtomStyle[mole.legendAtoms.at(i).an]&ATOM_STYLE_NOADP) { |
| 11393 |
body.append(QString(" object{\n")); |
| 11394 |
body.append(QString(" sphere{ Origin, 1 texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.legendAtoms.at(i).an))); |
| 11395 |
body.append(QString(" scale< H_Radius*Prob, H_Radius*Prob, H_Radius*Prob>*4*ViewAngle/29.0 \n")); |
| 11396 |
}else{ |
| 11397 |
V3 ev=V3(0,0,0); // Eigen Vectors |
| 11398 |
double *arr=mole.jacobi(mole.legendAtoms.at(i).uc,ev); |
| 11399 |
if ((ev.x>0)&&(ev.y>0)&&(ev.z>0)){ |
| 11400 |
body.append(QString("#declare U11 = %1 ;\n").arg(sqrt(ev.x),10,'f',6)); |
| 11401 |
body.append(QString("#declare U22 = %1 ;\n").arg(sqrt(ev.y),10,'f',6)); |
| 11402 |
body.append(QString("#declare U33 = %1 ;\n").arg(sqrt(ev.z),10,'f',6)); |
| 11403 |
body.append(QString("object{\n union{\n")); |
| 11404 |
body.append(QString(" sphere{Origin, 1 texture { finish { Shiny } pigment {color Color_%1 transmit %2} } }\n") |
| 11405 |
.arg(mole.pse(mole.legendAtoms.at(i).an)).arg((chgl->mol->AtomStyle[mole.legendAtoms.at(i).an]&ATOM_STYLE_SOLID)?"0.0":"0.8")); |
| 11406 |
|
| 11407 |
body.append(QString(" sphere{Origin, 1 scale<1,1,0.2> texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.legendAtoms.at(i).an))); |
| 11408 |
body.append(QString(" sphere{Origin, 1 scale<0.2,1,1> texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.legendAtoms.at(i).an))); |
| 11409 |
body.append(QString(" sphere{Origin, 1 scale<1,0.2,1> texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.legendAtoms.at(i).an))); |
| 11410 |
body.append(QString(" torus{ 1 .06 texture { finish { Shiny } pigment {color Equator_%1 } } }\n").arg(mole.pse(mole.legendAtoms.at(i).an))); |
| 11411 |
body.append(QString(" torus{ 1 .06 rotate< 90,0,0> texture { finish { Shiny } pigment {color Equator_%1 } } }\n").arg(mole.pse(mole.legendAtoms.at(i).an))); |
| 11412 |
body.append(QString(" torus{ 1 .06 rotate< 0,0,90> texture { finish { Shiny } pigment {color Equator_%1 } } }\n").arg(mole.pse(mole.legendAtoms.at(i).an))); |
| 11413 |
body.append(QString(" scale< U11*Prob, U22*Prob, U33*Prob>*4*ViewAngle/29.0\n }\n")); |
| 11414 |
body.append(QString(" Axis_Rotate_Trans( < %1 , %2 , %3 >, %4 ) \n") |
| 11415 |
.arg(arr[1],10,'f',6) |
| 11416 |
.arg(arr[2],10,'f',6) |
| 11417 |
.arg(arr[3],10,'f',6) |
| 11418 |
.arg(arr[0],10,'f',6)); |
| 11419 |
} |
| 11420 |
} |
| 11421 |
body.append(QString(" translate <-ww/1.025,-hh/1.08+%1*hh/18,0>\nno_shadow\n}\n\n").arg(j)); |
| 11422 |
} |
| 11423 |
body.append(QString("llabel(\"%1\",<-ww/1.06,-hh/1.06+%2*hh/18,0>,Black,0.35*4*ViewAngle/29.0)\n").arg(mole.pse(mole.legendAtoms.at(i).an)).arg(j)); |
| 11424 |
j++; |
| 11425 |
} |
| 11426 |
headerPOV.append(body); |
| 11427 |
|
| 11428 |
headerPOV.append(QString("#end //DrawLegend\n")); |
| 11429 |
headerPOV.append(QString("// ====================================\n")); |
| 11430 |
headerPOV.append(QString("// __Declarations of atoms coordinates \n")); |
| 11431 |
for (int i=0; i< mole.showatoms.size(); i++){ |
| 11432 |
if (mole.showatoms.at(i).hidden) continue; |
| 11433 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 11434 |
else { |
| 11435 |
s1=QString("AtomPos%1").arg(i); |
| 11436 |
headerPOV.append(QString("#declare %1 = < %2 , %3 , %4 >;//%5\n") |
| 11437 |
.arg(s1) |
| 11438 |
.arg(mole.showatoms.at(i).pos.x-chgl->altemitte.x,10,'f',6) //use the actual rotation center |
| 11439 |
.arg(mole.showatoms.at(i).pos.y-chgl->altemitte.y,10,'f',6) |
| 11440 |
.arg(mole.showatoms.at(i).pos.z-chgl->altemitte.z,10,'f',6) |
| 11441 |
.arg(mole.showatoms.at(i).Label)); |
| 11442 |
}} |
| 11443 |
headerPOV.append(QString("// ____________________________________ end of atom coordinates\n\n\n\n")); |
| 11444 |
|
| 11445 |
headerPOV.append(QString("// ====================================\n")); |
| 11446 |
headerPOV.append(QString("// __START union of objects\n")); |
| 11447 |
headerPOV.append(QString("union {\n\n")); |
| 11448 |
|
| 11449 |
headerPOV.append(QString("// ====================================\n")); |
| 11450 |
headerPOV.append(QString("// Spheres for nicely overlapping bonds\n")); |
| 11451 |
headerPOV.append(QString(" #if(DrawRoundCorners)\n")); |
| 11452 |
body.clear(); // we will use body as temporary buffer for hydrogen atoms spheres |
| 11453 |
body.append(QString("\n #if(DrawHydrogens)\n")); |
| 11454 |
|
| 11455 |
for (int i=0; i< mole.showatoms.size(); i++){ // read Uij into matrix form |
| 11456 |
if (mole.showatoms.at(i).an<0) continue;//only real atoms here |
| 11457 |
if (mole.showatoms.at(i).hidden) continue; |
| 11458 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 11459 |
s1=QString("AtomPos%1").arg(i); |
| 11460 |
if (mole.showatoms.at(i).an==0) |
| 11461 |
body.append(QString("sphere { %1 , HBond_Radius texture {Bond_Texture}}//%2\n").arg(s1) |
| 11462 |
.arg(mole.showatoms.at(i).Label)); |
| 11463 |
else |
| 11464 |
headerPOV.append(QString(" sphere { %1 , Bond_Radius texture {Bond_Texture}}//%2\n").arg(s1) |
| 11465 |
.arg(mole.showatoms.at(i).Label)); |
| 11466 |
} |
| 11467 |
headerPOV.append(body); |
| 11468 |
headerPOV.append(QString(" #end // End of atomic spheres for hydrogens\n")); |
| 11469 |
headerPOV.append(QString(" #end // End of atomic spheres\n")); |
| 11470 |
headerPOV.append(QString("// ____________________________________ end of corners\n\n\n\n")); |
| 11471 |
|
| 11472 |
headerPOV.append(QString("// ====================================\n")); |
| 11473 |
headerPOV.append(QString("// __Declarations of atoms and their Uij\n\n")); |
| 11474 |
|
| 11475 |
hiddenAtoms.append(QString("\n\n// ====================================\n")); |
| 11476 |
hiddenAtoms.append(QString("// Put in this IF-END loop atoms that shouldn't be drawn.\n")); |
| 11477 |
hiddenAtoms.append(QString("#if(!NoADP4Selected)\n")); |
| 11478 |
|
| 11479 |
hydrogenAtoms.append(QString("\n\n// ====================================\n")); |
| 11480 |
hydrogenAtoms.append(QString("// __Declarations of hydrogen atoms and their Uiso\n\n")); |
| 11481 |
hydrogenAtoms.append(QString("#if(DrawHydrogens)\n")); |
| 11482 |
hiddenHAtoms.append(QString("// __Declarations of hydrogen atoms and their Uiso\n")); |
| 11483 |
hiddenHAtoms.append(QString("\n# if(DrawHydrogens)\n")); |
| 11484 |
|
| 11485 |
for (int i=0; i< mole.showatoms.size(); i++){ // read Uij into matrix form |
| 11486 |
if (mole.showatoms.at(i).an<0) continue;//only real atoms here |
| 11487 |
if (mole.showatoms.at(i).hidden) continue; |
| 11488 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 11489 |
if (mole.showatoms.at(i).isIso) {//Wow this is stupid all iso atoms are Hydrogens? If Hydrogens are anisotropic (neutrons, SHADE etc.) they are not Hydrogens????) |
| 11490 |
s1=QString("AtomPos%1").arg(i); |
| 11491 |
body.clear(); // we will use body as temporary buffer for hydrogen atoms |
| 11492 |
body.append(QString(" #if (Hiso) #declare H_Radius = %1 ; #end\n").arg(sqrt(mole.showatoms.at(i).uf.m11),10,'f',6)); |
| 11493 |
body.append(QString(" object{\n")); |
| 11494 |
if ((chgl->highlightParts->isChecked())&&(mole.showatoms.at(i).part!=0)){ |
| 11495 |
if ((mole.showatoms.at(i).part<0)&&(mole.showatoms.at(i).symmGroup)) |
| 11496 |
body.append(QString(" sphere{ Origin, 1 texture { finish { Shiny } pigment {color Color_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11497 |
else |
| 11498 |
body.append(QString(" sphere{ Origin, 1 texture { finish { Shiny } pigment {color ptcol%1 } } }\n") |
| 11499 |
.arg((mole.showatoms.at(i).part>0)?QString("%1").arg(mole.showatoms.at(i).part): |
| 11500 |
(mole.showatoms.at(i).part<-3)?"mX":QString("m%1").arg(-mole.showatoms.at(i).part)) |
| 11501 |
); |
| 11502 |
} else{ |
| 11503 |
if ((mole.showatoms.at(i).part<0)&&(mole.showatoms.at(i).symmGroup)) |
| 11504 |
body.append(QString(" sphere{ Origin, 1 texture { finish { Shiny } pigment {color Color_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11505 |
else |
| 11506 |
body.append(QString(" sphere{ Origin, 1 texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11507 |
} |
| 11508 |
body.append(QString(" scale< H_Radius*Prob, H_Radius*Prob, H_Radius*Prob> \n")); |
| 11509 |
body.append(QString(" translate %1//%2\n }\n\n").arg(s1) |
| 11510 |
.arg(mole.showatoms.at(i).Label)); |
| 11511 |
foundInSelected=false; |
| 11512 |
for (int j = 0; j <chgl->mol->selectedatoms.size();j++)if (chgl->mol->selectedatoms.at(j).style==i) {foundInSelected=true;break;} |
| 11513 |
if (foundInSelected){hiddenHAtoms.append(body);} |
| 11514 |
else {hydrogenAtoms.append(body);} |
| 11515 |
} // end of Hs |
| 11516 |
else { |
| 11517 |
body.clear(); // we will use body as temporary buffer |
| 11518 |
V3 ev=V3(0,0,0); // Eigen Vectors |
| 11519 |
double *arr=mole.jacobi(mole.showatoms.at(i).uc,ev); |
| 11520 |
if ((ev.x>0)&&(ev.y>0)&&(ev.z>0)){ |
| 11521 |
|
| 11522 |
body.append(QString("#declare U11 = %1 ;\n").arg(sqrt(ev.x),10,'f',6)); |
| 11523 |
body.append(QString("#declare U22 = %1 ;\n").arg(sqrt(ev.y),10,'f',6)); |
| 11524 |
body.append(QString("#declare U33 = %1 ;\n").arg(sqrt(ev.z),10,'f',6)); |
| 11525 |
body.append(QString("object{\n union{\n")); |
| 11526 |
if ((chgl->highlightParts->isChecked())&&(mole.showatoms.at(i).part!=0)){ |
| 11527 |
if ((mole.showatoms.at(i).part<0)&&(mole.showatoms.at(i).symmGroup)){ |
| 11528 |
body.append(QString(" sphere{ Origin, 1.1 texture { finish { Shiny } pigment {color Color_%1 blue 1.0 transmit 0.7} } }\n") |
| 11529 |
.arg(mole.pse(mole.showatoms.at(i).an))); |
| 11530 |
}else{ |
| 11531 |
body.append(QString(" sphere{ Origin, 1.1 texture { finish { Shiny } pigment {color ptcol%1} } }\n") |
| 11532 |
.arg((mole.showatoms.at(i).part>0)?QString("%1").arg(mole.showatoms.at(i).part): |
| 11533 |
(mole.showatoms.at(i).part<-3)?"mX":QString("m%1").arg(-mole.showatoms.at(i).part)) |
| 11534 |
); |
| 11535 |
} |
| 11536 |
} |
| 11537 |
if ((mole.showatoms.at(i).part<0)&&(mole.showatoms.at(i).symmGroup)){ |
| 11538 |
body.append(QString(" sphere{ Origin, 1 texture { finish { Shiny } pigment {color Color_%1 blue 1.0 transmit 0.7} } }\n") |
| 11539 |
.arg(mole.pse(mole.showatoms.at(i).an)) |
| 11540 |
); |
| 11541 |
body.append(QString(" sphere{Origin, 1 scale<1,1,0.2> texture { finish { Shiny } pigment {color Color_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11542 |
body.append(QString(" sphere{Origin, 1 scale<0.2,1,1> texture { finish { Shiny } pigment {color Color_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11543 |
body.append(QString(" sphere{Origin, 1 scale<1,0.2,1> texture { finish { Shiny } pigment {color Color_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11544 |
body.append(QString(" torus{ 1 .06 texture { finish { Shiny } pigment {color Equator_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11545 |
body.append(QString(" torus{ 1 .06 rotate< 90,0,0> texture { finish { Shiny } pigment {color Equator_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11546 |
body.append(QString(" torus{ 1 .06 rotate< 0,0,90> texture { finish { Shiny } pigment {color Equator_%1 blue 1.0 transmit 0.7} } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11547 |
|
| 11548 |
}else{ |
| 11549 |
body.append(QString(" sphere{ Origin, 1 texture { finish { Shiny } pigment {color Color_%1 transmit %2} } }\n") |
| 11550 |
.arg(mole.pse(mole.showatoms.at(i).an)).arg((chgl->mol->AtomStyle[mole.showatoms.at(i).an]&ATOM_STYLE_SOLID)?"0.0":"0.3")); |
| 11551 |
body.append(QString(" sphere{Origin, 1 scale<1,1,0.2> texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11552 |
body.append(QString(" sphere{Origin, 1 scale<0.2,1,1> texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11553 |
body.append(QString(" sphere{Origin, 1 scale<1,0.2,1> texture { finish { Shiny } pigment {color Color_%1 } } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11554 |
body.append(QString(" torus{ 1 .06 texture { finish { Shiny } pigment {color Equator_%1 } } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11555 |
body.append(QString(" torus{ 1 .06 rotate< 90,0,0> texture { finish { Shiny } pigment {color Equator_%1 } } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11556 |
body.append(QString(" torus{ 1 .06 rotate< 0,0,90> texture { finish { Shiny } pigment {color Equator_%1 } } }\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11557 |
} |
| 11558 |
body.append(QString(" scale< U11*Prob, U22*Prob, U33*Prob>\n }\n")); |
| 11559 |
body.append(QString(" Axis_Rotate_Trans( < %1 , %2 , %3 >, %4 ) \n") |
| 11560 |
.arg(arr[1],10,'f',6) |
| 11561 |
.arg(arr[2],10,'f',6) |
| 11562 |
.arg(arr[3],10,'f',6) |
| 11563 |
.arg(arr[0],10,'f',6)); |
| 11564 |
} |
| 11565 |
else { |
| 11566 |
body.append(QString("object{\n union{\n")); |
| 11567 |
body.append(QString("DrawCube(CubeSize,Color_%1,Equator_%1)}\n").arg(mole.pse(mole.showatoms.at(i).an))); |
| 11568 |
} |
| 11569 |
s1=QString("AtomPos%1").arg(i); |
| 11570 |
body.append(QString(" translate %1//%2\n}\n\n").arg(s1) |
| 11571 |
.arg(mole.showatoms.at(i).Label)); |
| 11572 |
|
| 11573 |
foundInSelected=false; |
| 11574 |
for (int j = 0; j <chgl->mol->selectedatoms.size();j++)if (chgl->mol->selectedatoms.at(j).style==i) {foundInSelected=true;break;} |
| 11575 |
if (foundInSelected){hiddenAtoms.append(body);} |
| 11576 |
else {visableAtoms.append(body);} |
| 11577 |
} // end of non-H |
| 11578 |
} // end of lopp over all atoms for Uij computation |
| 11579 |
|
| 11580 |
hydrogenAtoms.append(QString(" #end // closing hydrogen atoms loop\n")); |
| 11581 |
hiddenHAtoms.append(QString(" #end // closing hidden hydrogen atoms loop\n")); |
| 11582 |
hiddenAtoms.append(hiddenHAtoms); |
| 11583 |
hiddenAtoms.append(QString("#end // ____________________________________ end of hidden atoms\n\n")); |
| 11584 |
|
| 11585 |
hidePOV.append(QString("// ====================================\n")); |
| 11586 |
hidePOV.append(QString("// Place in this IF-END loop atoms that shouldn't be drawn.\n")); |
| 11587 |
hidePOV.append(QString("#if(NoADP4Selected)\n\n")); |
| 11588 |
hidePOV.append(hiddenAtoms); |
| 11589 |
hidePOV.append(QString("#end\n")); |
| 11590 |
hidePOV.append(QString("// ____________________________________ end of hidden atoms\n\n\n\n")); |
| 11591 |
|
| 11592 |
qpeaks.append(QString("// ====================================\n")); |
| 11593 |
qpeaks.append(QString("// Q-Peaks show up here\n")); |
| 11594 |
qpeaks.append(QString("#if (DrawQPeaks)\n")); |
| 11595 |
for (int i=0; i< mole.showatoms.size(); i++){ // read Uij into matrix form |
| 11596 |
if (mole.showatoms.at(i).an>=0) continue;//only non real atoms here |
| 11597 |
if (mole.showatoms.at(i).hidden) continue; |
| 11598 |
s1=QString("AtomPos%1").arg(i); |
| 11599 |
QColor qcol=chgl->farbverlaufQC(chgl->mol->showatoms.at(i).peakHeight,chgl->mol->pmin,chgl->mol->pmax); |
| 11600 |
if (mole.showatoms.at(i).an==-42){ |
| 11601 |
if (mole.beloColorByDefden) qcol=chgl->farbverlaufQC(chgl->mol->showatoms.at(i).sof,mole.lmin,mole.lmax); |
| 11602 |
else qcol=mole.beloColor; |
| 11603 |
} |
| 11604 |
double grey=(chgl->mol->showatoms.at(i).peakHeight-chgl->mol->pmin)/(chgl->mol->pmax-chgl->mol->pmin); |
| 11605 |
qpeaks.append(QString("#if (BW)//%7\nqpeak(%1,QPeakRad,%5,%5,%5,%6)\n#else\nqpeak(%1,QPeakRad,%2,%3,%4,%6)\n#end\n") |
| 11606 |
.arg(s1) |
| 11607 |
.arg(qcol.redF()) |
| 11608 |
.arg(qcol.greenF()) |
| 11609 |
.arg(qcol.blueF()) |
| 11610 |
.arg(grey,5,'f',4) |
| 11611 |
.arg(mole.showatoms.at(i).an) |
| 11612 |
.arg(mole.showatoms.at(i).Label) |
| 11613 |
);// |
| 11614 |
} |
| 11615 |
qpeaks.append(QString("#if (DrawQPeaksBonds)\n")); |
| 11616 |
for (int i=0; i<chgl->mol->lbonds.size();i++){ |
| 11617 |
if (mole.lbonds.at(i).ato1->hidden) continue; |
| 11618 |
if (mole.lbonds.at(i).ato2->hidden) continue; |
| 11619 |
s1=QString("AtomPos%1").arg(mole.lbonds.at(i).a1); |
| 11620 |
s2=QString("AtomPos%1").arg(mole.lbonds.at(i).a2); |
| 11621 |
qpeaks.append(QString("qbond(%1,%2)//%3==%4\n").arg(s1).arg(s2).arg(mole.lbonds.at(i).ato1->Label).arg(mole.lbonds.at(i).ato2->Label)); |
| 11622 |
} |
| 11623 |
qpeaks.append(QString("#end\n")); |
| 11624 |
qpeaks.append(QString("#end\n\n")); |
| 11625 |
// BONDS |
| 11626 |
bondsPOV.append(QString("\n\n")); |
| 11627 |
bondsPOV.append(QString("// ====================================\n")); |
| 11628 |
bondsPOV.append(QString("// __Bonds\n")); |
| 11629 |
|
| 11630 |
body.clear(); // we will use body as temporary buffer for bonds to hydrogen atoms |
| 11631 |
body.append(QString("\n#if(DrawHydrogens)\n")); |
| 11632 |
|
| 11633 |
for (int i =0; i<mole.showbonds.size();i++){ |
| 11634 |
if (mole.showbonds.at(i).ato1->hidden) continue; |
| 11635 |
if (mole.showbonds.at(i).ato2->hidden) continue; |
| 11636 |
if ((mole.nopm1)&&(mole.showbonds.at(i).ato1->symmGroup)&&(mole.showbonds.at(i).ato1->part<0))continue; // ignore hidden parts (-1) |
| 11637 |
if ((mole.nopm1)&&(mole.showbonds.at(i).ato2->symmGroup)&&(mole.showbonds.at(i).ato2->part<0))continue; // ignore hidden parts (-1) |
| 11638 |
s1=QString("AtomPos%1").arg(mole.showbonds.at(i).a1); |
| 11639 |
s2=QString("AtomPos%1").arg(mole.showbonds.at(i).a2); |
| 11640 |
if ((chgl->mol->AtomStyle[chgl->mol->showbonds.at(i).ato1->an]&ATOM_STYLE_METAL)||(chgl->mol->AtomStyle[chgl->mol->showbonds.at(i).ato2->an]&ATOM_STYLE_METAL)){ |
| 11641 |
if ((mole.showbonds.at(i).ato1->an == 0)||(mole.showbonds.at(i).ato2->an == 0)) |
| 11642 |
body.append(QString(" DrawDashBond2( %1, %2, HBond_Radius,Dash_Length, Bond_Texture,Color_%3,Color_%4)//%5==%6\n").arg(s1).arg(s2) |
| 11643 |
.arg(mole.pse(mole.showbonds.at(i).ato2->an)) |
| 11644 |
.arg(mole.pse(mole.showbonds.at(i).ato1->an)).arg(mole.showbonds.at(i).ato1->Label).arg(mole.showbonds.at(i).ato2->Label)); |
| 11645 |
else |
| 11646 |
bondsPOV.append(QString("DrawDashBond2( %1, %2, Bond_Radius,Dash_Length, Bond_Texture,Color_%3,Color_%4)//%5==%6\n").arg(s1).arg(s2) |
| 11647 |
.arg(mole.pse(mole.showbonds.at(i).ato2->an)) |
| 11648 |
.arg(mole.pse(mole.showbonds.at(i).ato1->an)).arg(mole.showbonds.at(i).ato1->Label).arg(mole.showbonds.at(i).ato2->Label)); |
| 11649 |
}else{ |
| 11650 |
if ((chgl->highlightParts->isChecked())&&(mole.showbonds.at(i).ato1->part!=0)) |
| 11651 |
bondsPOV.append(QString("DrawBond( %1, %2, Bond_Radius, Bond_Texture,ptcol%3,ptcol%4,%7)//%5==%6\n") |
| 11652 |
.arg(s1) |
| 11653 |
.arg(s2) |
| 11654 |
.arg((mole.showbonds.at(i).ato1->part>0)?QString("%1").arg(mole.showbonds.at(i).ato1->part): |
| 11655 |
(mole.showbonds.at(i).ato1->part<-3)?"mX":QString("m%1").arg(-mole.showbonds.at(i).ato1->part)) |
| 11656 |
.arg((mole.showbonds.at(i).ato2->part>0)?QString("%1").arg(mole.showbonds.at(i).ato2->part): |
| 11657 |
(mole.showbonds.at(i).ato2->part<-3)?"mX":QString("m%1").arg(-mole.showbonds.at(i).ato2->part)) |
| 11658 |
.arg(mole.showbonds.at(i).ato1->Label).arg(mole.showbonds.at(i).ato2->Label) |
| 11659 |
.arg((mole.showbonds.at(i).ato1->part<0)&&(mole.showbonds.at(i).ato1->symmGroup))); |
| 11660 |
|
| 11661 |
else{ |
| 11662 |
if ((mole.showbonds.at(i).ato1->an == 0)||(mole.showbonds.at(i).ato2->an == 0)) |
| 11663 |
body.append(QString(" DrawBond( %1, %2, HBond_Radius, Bond_Texture,Color_%3,Color_%4,%7)//%5==%6\n").arg(s1).arg(s2).arg(mole.pse(mole.showbonds.at(i).ato1->an)).arg(mole.pse(mole.showbonds.at(i).ato2->an)) |
| 11664 |
.arg(mole.showbonds.at(i).ato1->Label).arg(mole.showbonds.at(i).ato2->Label) |
| 11665 |
.arg((mole.showbonds.at(i).ato1->part<0)&&(mole.showbonds.at(i).ato1->symmGroup)) |
| 11666 |
); |
| 11667 |
else |
| 11668 |
bondsPOV.append(QString("DrawBond( %1, %2, Bond_Radius, Bond_Texture,Color_%3,Color_%4,%7)//%5==%6\n").arg(s1).arg(s2).arg(mole.pse(mole.showbonds.at(i).ato1->an)).arg(mole.pse(mole.showbonds.at(i).ato2->an)) |
| 11669 |
.arg(mole.showbonds.at(i).ato1->Label).arg(mole.showbonds.at(i).ato2->Label) |
| 11670 |
.arg((mole.showbonds.at(i).ato1->part<0)&&(mole.showbonds.at(i).ato1->symmGroup))); |
| 11671 |
} |
| 11672 |
} |
| 11673 |
} |
| 11674 |
body.append(QString("\n#if(DrawH_Bonds)\n")); |
| 11675 |
//qDebug()<<chgl->mol->theH_Bonds.size(); |
| 11676 |
for (int i =0; i<chgl->mol->theH_Bonds.size();i++){ |
| 11677 |
if (mole.theH_Bonds.at(i).ato1->hidden) continue; |
| 11678 |
if (mole.theH_Bonds.at(i).ato2->hidden) continue; |
| 11679 |
if ((mole.nopm1)&&(mole.theH_Bonds.at(i).ato1->symmGroup)&&(mole.theH_Bonds.at(i).ato1->part<0))continue; // ignore hidden parts (-1) |
| 11680 |
if ((mole.nopm1)&&(mole.theH_Bonds.at(i).ato2->symmGroup)&&(mole.theH_Bonds.at(i).ato2->part<0))continue; // ignore hidden parts (-1) |
| 11681 |
s1=QString("AtomPos%1").arg(mole.theH_Bonds.at(i).a1); |
| 11682 |
s2=QString("AtomPos%1").arg(mole.theH_Bonds.at(i).a2); |
| 11683 |
body.append(QString(" DrawDashBond( %1, %2, HBond_Radius, Dash_Length*0.5, HBond_Texture)\n").arg(s1).arg(s2)); |
| 11684 |
|
| 11685 |
} |
| 11686 |
body.append(QString("#end // End of DrawH_Bonds\n")); |
| 11687 |
body.append(QString("#end // End of bonds to hydrogen atoms\n")); |
| 11688 |
bondsPOV.append(body); |
| 11689 |
bondsPOV.append(QString("//------\n")); |
| 11690 |
|
| 11691 |
bondsPOV.append(QString("\n//DrawDashBond( Ct02 , Hf1 , Dash_Radius, Dash_Length, texture { Bond_Texture } )\n")); |
| 11692 |
bondsPOV.append(QString("// ____________________________________ end of bonds\n\n\n\n")); |
| 11693 |
|
| 11694 |
ringsPOV.append(QString("// ====================================\n")); |
| 11695 |
ringsPOV.append(QString("#if (DrawAromaticRings)\n")); |
| 11696 |
ringsPOV.append(QString("/*\n")); |
| 11697 |
ringsPOV.append(QString(" DrawRing - Example of usage\n")); |
| 11698 |
ringsPOV.append(QString(" 1st declare new centroid; summation is over coordinates of all ring atoms\n")); |
| 11699 |
ringsPOV.append(QString(" Divisor should be the same as count of atoms\n")); |
| 11700 |
ringsPOV.append(QString(" The atoms C1 and N2, used in macro, should be neighbours in the ring.\n\n")); |
| 11701 |
ringsPOV.append(QString(" #declare CtNew1=(C1+N2+C3+C4+N5)/5;\n")); |
| 11702 |
ringsPOV.append(QString(" DrawRing(C1,N2,CtNew1)\n\n")); |
| 11703 |
ringsPOV.append(QString("*/\n")); |
| 11704 |
|
| 11705 |
// int nonMetal[10], countNonMetal; |
| 11706 |
QList<int> nonMetals; |
| 11707 |
for (int i=0; i< mole.showatoms.size(); i++){ // scan visble for Cnt |
| 11708 |
if (mole.showatoms.at(i).hidden) continue; |
| 11709 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 11710 |
if (mole.showatoms.at(i).an==-66) {//Cnt |
| 11711 |
nonMetals.clear(); |
| 11712 |
for (int j=0; j< mole.showatoms.size(); j++){ |
| 11713 |
if ((i==j) || (mole.showatoms.at(j).an<1)) continue; // ignore Q, Cnt and H |
| 11714 |
if (mole.AtomStyle[mole.showatoms.at(j).an]&ATOM_STYLE_METAL) continue; |
| 11715 |
if ((mole.nopm1)&&(mole.showatoms.at(j).symmGroup)&&(mole.showatoms.at(j).part<-0)) continue; // ignore hidden parts (-1) |
| 11716 |
double d = sqrt(Distance(mole.showatoms.at(i).pos,mole.showatoms.at(j).pos)); |
| 11717 |
double soll=(70+mole.Kovalenz_Radien[mole.showatoms.at(j).an])*0.012; |
| 11718 |
if (d<soll) nonMetals.append(j); |
| 11719 |
} |
| 11720 |
if (nonMetals.size()>1) { for (int j=0; j<nonMetals.size(); j++){ |
| 11721 |
for (int k=j+1; k<nonMetals.size(); k++){ |
| 11722 |
double d = sqrt(Distance(mole.showatoms.at(nonMetals.at(j)).pos,mole.showatoms.at(nonMetals.at(k)).pos)); |
| 11723 |
double soll=(mole.Kovalenz_Radien[mole.showatoms.at(nonMetals.at(j)).an]+mole.Kovalenz_Radien[mole.showatoms.at(nonMetals.at(k)).an])*0.012; |
| 11724 |
if (d<soll){ |
| 11725 |
s3=QString("AtomPos%1").arg(i); |
| 11726 |
s2=QString("AtomPos%1").arg(nonMetals.at(j)); |
| 11727 |
s1=QString("AtomPos%1").arg(nonMetals.at(k)); |
| 11728 |
ringsPOV.append(QString(" DrawRing(%1,%2,%3)\n").arg(s1,10).arg(s2,10).arg(s3,10)); |
| 11729 |
goto endLoop; |
| 11730 |
} |
| 11731 |
} |
| 11732 |
}} |
| 11733 |
endLoop:; |
| 11734 |
} |
| 11735 |
} |
| 11736 |
ringsPOV.append(QString("#end\n")); |
| 11737 |
ringsPOV.append(QString("// ____________________________________ end of rings\n\n\n\n")); |
| 11738 |
nonMetals.clear(); |
| 11739 |
labels.append("//Labels\n#if (DrawLabels)\n"); |
| 11740 |
for (int i=0; i<mole.showatoms.size(); i++){ |
| 11741 |
if (mole.showatoms.at(i).hidden) continue; |
| 11742 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 11743 |
if (mole.showatoms.at(i).an<0) continue; |
| 11744 |
s2=mole.showatoms.at(i).Label; |
| 11745 |
if (chgl->shortLabels->isChecked()) { |
| 11746 |
s2=s2.section("_",0,0); |
| 11747 |
s2=s2.section(QString::fromUtf8("»"),0,0); |
| 11748 |
} |
| 11749 |
s2=s2.replace("\\","\\\\"); |
| 11750 |
s2=s2.replace("\"","\\\""); |
| 11751 |
s1=QString("AtomPos%1").arg(i); |
| 11752 |
labels.append(QString("label(\"%1\",%2,Black,0.35)\n").arg(s2).arg(s1)); |
| 11753 |
} |
| 11754 |
labels.append("#end //DrawLabels\n\n"); |
| 11755 |
|
| 11756 |
|
| 11757 |
/*!draw a unit cell box |
| 11758 |
* |
| 11759 |
* */ |
| 11760 |
V3 uz0f,uz1f,uz2f,uz3f,uz4f,uz5f,uz6f,uz7f; |
| 11761 |
V3 uz0k,uz1k,uz2k,uz3k,uz4k,uz5k,uz6k,uz7k; |
| 11762 |
uz0f.x=0.0; uz0f.y=0.0; uz0f.z=0.0; |
| 11763 |
uz1f.x=1.0; uz1f.y=0.0; uz1f.z=0.0; |
| 11764 |
uz2f.x=0.0; uz2f.y=1.0; uz2f.z=0.0; |
| 11765 |
uz3f.x=0.0; uz3f.y=0.0; uz3f.z=1.0; |
| 11766 |
uz4f.x=1.0; uz4f.y=1.0; uz4f.z=0.0; |
| 11767 |
uz5f.x=1.0; uz5f.y=0.0; uz5f.z=1.0; |
| 11768 |
uz6f.x=0.0; uz6f.y=1.0; uz6f.z=1.0; |
| 11769 |
uz7f.x=1.0; uz7f.y=1.0; uz7f.z=1.0; |
| 11770 |
mole.frac2kart(uz0f,uz0k); |
| 11771 |
mole.frac2kart(uz1f,uz1k); |
| 11772 |
mole.frac2kart(uz2f,uz2k); |
| 11773 |
mole.frac2kart(uz3f,uz3k); |
| 11774 |
mole.frac2kart(uz4f,uz4k); |
| 11775 |
mole.frac2kart(uz5f,uz5k); |
| 11776 |
mole.frac2kart(uz6f,uz6k); |
| 11777 |
mole.frac2kart(uz7f,uz7k); |
| 11778 |
uz0k = uz0k - chgl->altemitte; |
| 11779 |
uz1k = uz1k - chgl->altemitte; |
| 11780 |
uz2k = uz2k - chgl->altemitte; |
| 11781 |
uz3k = uz3k - chgl->altemitte; |
| 11782 |
uz4k = uz4k - chgl->altemitte; |
| 11783 |
uz5k = uz5k - chgl->altemitte; |
| 11784 |
uz6k = uz6k - chgl->altemitte; |
| 11785 |
uz7k = uz7k - chgl->altemitte; |
| 11786 |
unitCell.append(QString("#if (DrawUnitCell)\n")); |
| 11787 |
unitCell.append(QString("union{\n")); |
| 11788 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color Red}}}\n") |
| 11789 |
.arg(uz0k.x) |
| 11790 |
.arg(uz0k.y) |
| 11791 |
.arg(uz0k.z) |
| 11792 |
.arg(uz1k.x) |
| 11793 |
.arg(uz1k.y) |
| 11794 |
.arg(uz1k.z)); |
| 11795 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color Green}}}\n") |
| 11796 |
.arg(uz0k.x) |
| 11797 |
.arg(uz0k.y) |
| 11798 |
.arg(uz0k.z) |
| 11799 |
.arg(uz2k.x) |
| 11800 |
.arg(uz2k.y) |
| 11801 |
.arg(uz2k.z)); |
| 11802 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color Blue}}}\n") |
| 11803 |
.arg(uz0k.x) |
| 11804 |
.arg(uz0k.y) |
| 11805 |
.arg(uz0k.z) |
| 11806 |
.arg(uz3k.x) |
| 11807 |
.arg(uz3k.y) |
| 11808 |
.arg(uz3k.z)); |
| 11809 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11810 |
.arg(uz4k.x) |
| 11811 |
.arg(uz4k.y) |
| 11812 |
.arg(uz4k.z) |
| 11813 |
.arg(uz1k.x) |
| 11814 |
.arg(uz1k.y) |
| 11815 |
.arg(uz1k.z)); |
| 11816 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11817 |
.arg(uz5k.x) |
| 11818 |
.arg(uz5k.y) |
| 11819 |
.arg(uz5k.z) |
| 11820 |
.arg(uz1k.x) |
| 11821 |
.arg(uz1k.y) |
| 11822 |
.arg(uz1k.z)); |
| 11823 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11824 |
.arg(uz2k.x) |
| 11825 |
.arg(uz2k.y) |
| 11826 |
.arg(uz2k.z) |
| 11827 |
.arg(uz4k.x) |
| 11828 |
.arg(uz4k.y) |
| 11829 |
.arg(uz4k.z)); |
| 11830 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11831 |
.arg(uz2k.x) |
| 11832 |
.arg(uz2k.y) |
| 11833 |
.arg(uz2k.z) |
| 11834 |
.arg(uz6k.x) |
| 11835 |
.arg(uz6k.y) |
| 11836 |
.arg(uz6k.z)); |
| 11837 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11838 |
.arg(uz3k.x) |
| 11839 |
.arg(uz3k.y) |
| 11840 |
.arg(uz3k.z) |
| 11841 |
.arg(uz5k.x) |
| 11842 |
.arg(uz5k.y) |
| 11843 |
.arg(uz5k.z)); |
| 11844 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11845 |
.arg(uz3k.x) |
| 11846 |
.arg(uz3k.y) |
| 11847 |
.arg(uz3k.z) |
| 11848 |
.arg(uz6k.x) |
| 11849 |
.arg(uz6k.y) |
| 11850 |
.arg(uz6k.z)); |
| 11851 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11852 |
.arg(uz4k.x) |
| 11853 |
.arg(uz4k.y) |
| 11854 |
.arg(uz4k.z) |
| 11855 |
.arg(uz7k.x) |
| 11856 |
.arg(uz7k.y) |
| 11857 |
.arg(uz7k.z)); |
| 11858 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11859 |
.arg(uz5k.x) |
| 11860 |
.arg(uz5k.y) |
| 11861 |
.arg(uz5k.z) |
| 11862 |
.arg(uz7k.x) |
| 11863 |
.arg(uz7k.y) |
| 11864 |
.arg(uz7k.z)); |
| 11865 |
unitCell.append(QString("cylinder{<%1,%2,%3>,<%4,%5,%6>,CellWidth texture{pigment{color LightSteelBlue}}}\n") |
| 11866 |
.arg(uz6k.x) |
| 11867 |
.arg(uz6k.y) |
| 11868 |
.arg(uz6k.z) |
| 11869 |
.arg(uz7k.x) |
| 11870 |
.arg(uz7k.y) |
| 11871 |
.arg(uz7k.z)); |
| 11872 |
unitCell.append(QString("}\n#end //DrawUnitCell\n\n")); |
| 11873 |
footerPOV.append(QString("transform {\n")); |
| 11874 |
footerPOV.append(QString("scale<3.5*ViewAngle/29,3.5*ViewAngle/29,3.5*ViewAngle/29>\n")); |
| 11875 |
footerPOV.append(QString("scale<SCALE,SCALE,SCALE>\n")); |
| 11876 |
footerPOV.append(QString(" matrix <\n")); |
| 11877 |
footerPOV.append(QString(" %1, %2, %3, \n").arg(mv[0],9,'f',6).arg(mv[1],9,'f',6).arg(mv[2],9,'f',6)); |
| 11878 |
footerPOV.append(QString(" %1, %2, %3, \n").arg(mv[4],9,'f',6).arg(mv[5],9,'f',6).arg(mv[6],9,'f',6)); |
| 11879 |
footerPOV.append(QString(" %1, %2, %3, \n").arg(mv[8],9,'f',6).arg(mv[9],9,'f',6).arg(mv[10],9,'f',6)); |
| 11880 |
footerPOV.append(QString(" %1, %2, %3\n").arg(0.0,9,'f',6).arg(0.0,9,'f',6).arg(0.0,9,'f',6)); |
| 11881 |
footerPOV.append(QString(" >\n")); |
| 11882 |
footerPOV.append(QString("// You can adapt geometry by applying \n")); |
| 11883 |
footerPOV.append(QString("// translation and rotations (in deg).\n")); |
| 11884 |
footerPOV.append(QString("// It's easier to use separate rotation for each axis.\n")); |
| 11885 |
footerPOV.append(QString(" translate < %1, %2, 0.0000 >\n").arg(mv[12]/10,7,'f',4).arg(mv[13]/10,7,'f',4)); |
| 11886 |
footerPOV.append(QString(" rotate < 1.0000, 0.0000, 0.0000 > // Y\n")); |
| 11887 |
footerPOV.append(QString(" rotate < 0.0000, 1.0000, 0.0000 > // |_______X\n")); |
| 11888 |
footerPOV.append(QString(" rotate < 0.0000, 0.0000, 1.0000 > // /\n")); |
| 11889 |
footerPOV.append(QString(" // Z\n")); |
| 11890 |
footerPOV.append(QString(" }\n")); |
| 11891 |
footerPOV.append(QString("#if (NoShadows)\nno_shadow\n#end\n} // __END union of objects\n\n")); |
| 11892 |
printf("writing POV\n"); |
| 11893 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 11894 |
if (success){ |
| 11895 |
f.write(headerPOV.toUtf8()); |
| 11896 |
f.write(visableAtoms.toUtf8()); |
| 11897 |
f.write(hydrogenAtoms.toUtf8()); |
| 11898 |
f.write(hiddenAtoms.toUtf8()); |
| 11899 |
f.write(qpeaks.toUtf8()); |
| 11900 |
f.write(bondsPOV.toUtf8()); |
| 11901 |
f.write(ringsPOV.toUtf8()); |
| 11902 |
f.write(unitCell.toUtf8()); |
| 11903 |
f.write(densityMaps.toUtf8()); |
| 11904 |
f.write(voron.toUtf8()); |
| 11905 |
f.write(labels.toUtf8()); |
| 11906 |
f.write(footerPOV.toUtf8()); |
| 11907 |
f.close(); |
| 11908 |
QFile ini(iniName); |
| 11909 |
ini.open(QIODevice::WriteOnly|QIODevice::Text); |
| 11910 |
body.clear(); |
| 11911 |
body.append(QString("Input_File_Name='%1';\nWidth=%2;\nHeight=%3;\nAntialias=on;\nAntialias_Threshold=0.3;\nOutput_File_Type=N;\nOutput_Alpha=on;\nOutput_File_Name='%4';\n\n") |
| 11912 |
.arg(povName) |
| 11913 |
.arg(int(chgl->width()*scalePic+0.5)) |
| 11914 |
.arg(int(chgl->height()*scalePic+0.5)) |
| 11915 |
.arg(pngName) |
| 11916 |
); |
| 11917 |
ini.write(body.toUtf8()); |
| 11918 |
ini.close(); |
| 11919 |
QString PovRayExe = QString(); |
| 11920 |
QSettings *povset = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME,mole.mynewnameis ); |
| 11921 |
povset->beginGroup("PovRay"); |
| 11922 |
PovRayExe = povset->value("PovRayExe","").toString(); |
| 11923 |
povset->endGroup(); |
| 11924 |
if ((PovRayExe.isEmpty())||(!QFileInfo(PovRayExe).isExecutable())) { |
| 11925 |
PovRayExe.clear(); |
| 11926 |
} |
| 11927 |
QString fn2; |
| 11928 |
if (PovRayExe.isEmpty()){ |
| 11929 |
fn2=QFileDialog::getOpenFileName(this, tr("PovRay EXEcutable"), "povray","",nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog ); |
| 11930 |
if (fn2.isEmpty()) return; |
| 11931 |
} |
| 11932 |
if ((!fn2.isEmpty())&&(QFileInfo(fn2).isExecutable())) { |
| 11933 |
povset->beginGroup("PovRay"); |
| 11934 |
povset->setValue("PovRayExe", fn2); |
| 11935 |
PovRayExe = fn2; |
| 11936 |
povset->endGroup(); |
| 11937 |
}//executable |
| 11938 |
//run povray |
| 11939 |
QString dn=dirName.section('/',0,-2); |
| 11940 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 11941 |
QStringList al=QString(QString("/EDIT*%1*/EDIT*%2*/RENDER*%2").arg(fn).arg(iniName)).split("*");//i think * should not be alowed in path names |
| 11942 |
//qDebug()<<al; |
| 11943 |
#else |
| 11944 |
QStringList al=QString(QString("+I%1*%2").arg(fn).arg(iniName)).split("*"); |
| 11945 |
|
| 11946 |
#endif |
| 11947 |
extraProc = new QProcess(this); |
| 11948 |
#if (defined Q_WS_WIN || defined Q_OS_WIN) |
| 11949 |
#if (QT_VERSION >= 0x050700) |
| 11950 |
extraProc->setProgram(PovRayExe); |
| 11951 |
extraProc->setArguments(al); |
| 11952 |
extraProc->setWorkingDirectory(dn); |
| 11953 |
extraProc->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) {args->flags &= ~CREATE_NO_WINDOW;}); |
| 11954 |
extraProc->startDetached(); |
| 11955 |
#else |
| 11956 |
extraProc->startDetached(PovRayExe,al,dn); |
| 11957 |
#endif |
| 11958 |
#else |
| 11959 |
//not windows we need to parse the output of povray |
| 11960 |
//qDebug()<<PovRayExe<<al<<dn; |
| 11961 |
extraIndex = -21; |
| 11962 |
extraProc->setWorkingDirectory(dn); // updateXLput() |
| 11963 |
connect(extraProc,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateExtraOutput())); |
| 11964 |
connect(extraProc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateExtraOutput())); |
| 11965 |
connect(extraProc,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateExtraOutput())); |
| 11966 |
#if (QT_VERSION >= 0x040600) |
| 11967 |
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); |
| 11968 |
extraProc->setProcessEnvironment(env);//Thanks to Dr. Pavlo Solntsev!! |
| 11969 |
#else |
| 11970 |
QStringList env = QProcess::systemEnvironment(); |
| 11971 |
extraProc->setEnvironment(env); |
| 11972 |
#endif |
| 11973 |
//extraProc->startDetached(,al,dn); |
| 11974 |
extraProc->start(PovRayExe,al); |
| 11975 |
extraOutPut->setReadOnly(false); |
| 11976 |
extraOutPut->setText(QString("Running POVRAY ...\n")); |
| 11977 |
extraOutput->show(); |
| 11978 |
updateExtraOutput(); |
| 11979 |
#endif |
| 11980 |
|
| 11981 |
}//success |
| 11982 |
|
| 11983 |
} |
| 11984 |
|
| 11985 |
void Window::savePovInc(QString povName){ |
| 11986 |
// Generates additional incremenmt file with color and other parameters |
| 11987 |
|
| 11988 |
// QString iniName = "atoms.inc"; |
| 11989 |
// QString fn=QFileDialog::getSaveFileName(this, tr("Export POV-Ray inc"), iniName, tr("POV-Ray inc (*.inc)")); |
| 11990 |
|
| 11991 |
QString incName = povName.section('.',0,-2); |
| 11992 |
incName.append(".inc"); |
| 11993 |
|
| 11994 |
//QString fn=QFileDialog::getSaveFileName(this, tr("Export POV-Ray inc"), iniName, tr("POV-Ray inc (*.inc)")); |
| 11995 |
//if (fn.isEmpty()) return; |
| 11996 |
|
| 11997 |
QFile f(incName); |
| 11998 |
QString body; |
| 11999 |
body.append("#declare Triacontaeder=\n" |
| 12000 |
"object {\n" |
| 12001 |
"#local A=1.0;\n" |
| 12002 |
"#local B=0.0;\n" |
| 12003 |
"#local C=(sqrt(5.0)+1.0)/2.0;//1.618034\n" |
| 12004 |
"#local D=C-1.0;//0.618034\n" |
| 12005 |
"mesh2 {\n" |
| 12006 |
" vertex_vectors {\n" |
| 12007 |
" 32,\n" |
| 12008 |
"< B, -C, A>, \n" |
| 12009 |
"<-A, B, C>,< A, B, C>,< B, D, C>,\n" |
| 12010 |
"< B, -D, C>,< A, A, A>,< A, -A, A>,\n" |
| 12011 |
"< C, B, D>,< C, B, -D>,< C, A, B>,\n" |
| 12012 |
"< C, -A, B>,< -C, B, D>,< -C, A, B>,\n" |
| 12013 |
"<-C, B, -D>,< -C, -A, B>,< A, A, -A>,\n" |
| 12014 |
"< D, C, B>,< -A, A, A>,< -D, C, B>,\n" |
| 12015 |
"<-A, A, -A>,< B, C, -A>,< B, C, A>,\n" |
| 12016 |
"<-A, -A, -A>,< -D, -C, B>,< D, -C, B>,\n" |
| 12017 |
"< A, -A, -A>,< B, -C, -A>,< B, D, -C>,\n" |
| 12018 |
"< A, B, -C>,< -A, -A, A>,< B, -D, -C>,\n" |
| 12019 |
"<-A, B, -C>\n" |
| 12020 |
" }\n" |
| 12021 |
" face_indices {\n" |
| 12022 |
" 60,\n" |
| 12023 |
" < 2, 3, 4>, < 2, 5, 3>, < 2, 4, 6>,\n" |
| 12024 |
" < 2, 7, 5>, < 2, 6, 7>, < 7, 8, 9>,\n" |
| 12025 |
" < 7, 10, 8>, < 11, 12, 13>, < 11, 13, 14>,\n" |
| 12026 |
" < 9, 15, 16>, < 9, 8, 15>, < 3, 1, 4>,\n" |
| 12027 |
" < 3, 17, 1>, < 18, 19, 12>, < 18, 20, 19>,\n" |
| 12028 |
" < 12, 19, 13>, < 3, 21, 17>, < 14, 22, 23>,\n" |
| 12029 |
" < 14, 13, 22>, < 24, 25, 10>, < 24, 26, 25>,\n" |
| 12030 |
" < 10, 25, 8>, < 15, 27, 20>, < 15, 28, 27>,\n" |
| 12031 |
" < 20, 27, 19>, < 1, 29, 4>, < 22, 30, 26>,\n" |
| 12032 |
" < 22, 31, 30>, < 1, 17, 11>, < 26, 30, 25>,\n" |
| 12033 |
" < 1, 11, 29>, < 25, 30, 28>, < 28, 30, 27>,\n" |
| 12034 |
" < 27, 30, 31>, < 4, 0, 6>, < 5, 9, 16>,\n" |
| 12035 |
" < 5, 16, 21>, < 21, 16, 18>, < 21, 18, 17>,\n" |
| 12036 |
" < 29, 14, 23>, < 29, 23, 0>, < 0, 23, 24>,\n" |
| 12037 |
" < 0, 24, 6>, < 16, 20, 18>, < 23, 26, 24>,\n" |
| 12038 |
" < 16, 15, 20>, < 3, 5, 21>, < 23, 22, 26>,\n" |
| 12039 |
" < 8, 28, 15>, < 8, 25, 28>, < 13, 19, 31>,\n" |
| 12040 |
" < 13, 31, 22>, < 19, 27, 31>, < 4, 29, 0>,\n" |
| 12041 |
" < 5, 7, 9>, < 17, 12, 11>, < 17, 18, 12>,\n" |
| 12042 |
" < 29, 11, 14>, < 6, 10, 7>, < 6, 24, 10>\n" |
| 12043 |
" }\n" |
| 12044 |
"}//mesh\n" |
| 12045 |
"};\n\n"); |
| 12046 |
body.append(QString("#macro DrawBond(at1,at2,rad,textur,t1,t2,ghost)\n")); |
| 12047 |
body.append(QString("#if (ghost)\n")); |
| 12048 |
body.append(QString("#local bc = (at1 + at2) * 0.5;\ncylinder {at1 bc rad texture { pigment{t1 blue 1.0 transmit 0.7} } }\ncylinder {at2 bc rad texture { pigment{t2 blue 1.0 transmit 0.7} } }\n")); |
| 12049 |
body.append(QString("#else\n")); |
| 12050 |
body.append(QString("#if (UniColorBonds)\n")); |
| 12051 |
body.append(QString(" cylinder {at1 at2 rad texture { textur } }\n")); |
| 12052 |
body.append(QString("#else\n")); |
| 12053 |
body.append(QString("#local bc = (at1 + at2) * 0.5;\ncylinder {at1 bc rad texture { pigment{t1} } }\ncylinder {at2 bc rad texture { pigment{t2} } }\n")); |
| 12054 |
body.append(QString("#end\n")); |
| 12055 |
body.append(QString("#end\n")); |
| 12056 |
body.append(QString("#end\n\n")); |
| 12057 |
body.append(QString("#macro qbond(at1,at2)\n")); |
| 12058 |
body.append(QString(" cylinder {at1 at2 0.005 texture { pigment{ color Color_Cnt} } }\n")); |
| 12059 |
body.append(QString("##end\n\n")); |
| 12060 |
body.append(QString("#macro qpeak(pos, r, cr, cg, cb, an)\n")); |
| 12061 |
body.append(QString("object{\n")); |
| 12062 |
body.append(QString("#local rf =1;\n")); |
| 12063 |
body.append(QString("#switch (an)\n#case(-1)\nIcosahedron\nqpeakTexture(cr, cg, cb)\n#break\n#case(-42)\n" |
| 12064 |
"Triacontaeder\nqpeakTexture(cr, cg, cb)\n#local rf =%1;\n" |
| 12065 |
"#break\n#case(-66)\nDodecahedron\ntexture {pigment{ color Color_Cnt}}\n#local rf =1.25;\n\n#end\n").arg(0.5*mole.beloRad/mole.qPeakRad,0,'f',3)); |
| 12066 |
body.append(QString("scale <1, 1, 1> * r *rf \n")); |
| 12067 |
body.append(QString("translate pos\n")); |
| 12068 |
body.append(QString("}\n")); |
| 12069 |
body.append(QString("#end\n\n")); |
| 12070 |
body.append(QString("#macro DrawDashBond(at1,ct1,RadiusDash,LengthDash,TextureDash)\n")); |
| 12071 |
body.append(QString(" #local L=VDist(at1,ct1);\n")); |
| 12072 |
body.append(QString(" #local IL = L / LengthDash;\n")); |
| 12073 |
body.append(QString(" #local strip = (ct1 - at1)/IL;\n")); |
| 12074 |
body.append(QString(" #local i=0;\n")); |
| 12075 |
body.append(QString(" #local tempXYZ=ct1;\n")); |
| 12076 |
body.append(QString(" #while (i<IL )\n")); |
| 12077 |
body.append(QString(" #local tempXYZ2=tempXYZ-strip;\n")); |
| 12078 |
body.append(QString(" cylinder { tempXYZ tempXYZ2 RadiusDash texture { TextureDash } }\n")); |
| 12079 |
body.append(QString(" #local tempXYZ=tempXYZ2-strip;\n")); |
| 12080 |
body.append(QString(" #local i=i+2;\n")); |
| 12081 |
body.append(QString(" #end\n")); |
| 12082 |
body.append(QString("#end\n\n")); |
| 12083 |
|
| 12084 |
body.append(QString("#macro DrawDashBond2(at1,ct1,RadiusDash,LengthDash,T0,T1,T2)\n")); |
| 12085 |
body.append(QString(" #local L=VDist(at1,ct1);\n")); |
| 12086 |
body.append(QString(" #local IL = L / LengthDash;\n")); |
| 12087 |
body.append(QString(" #local strip = (ct1 - at1)/IL;\n")); |
| 12088 |
body.append(QString(" #local i=0;\n")); |
| 12089 |
body.append(QString(" #local tempXYZ=ct1;\n")); |
| 12090 |
body.append(QString(" #while (i<IL )\n")); |
| 12091 |
body.append(QString(" #local tempXYZ2=tempXYZ-strip;\n")); |
| 12092 |
body.append(QString(" #if (UniColorBonds)\n" |
| 12093 |
" cylinder { tempXYZ tempXYZ2 RadiusDash texture { T0 } }\n" |
| 12094 |
" #else\n" |
| 12095 |
" #if (i<IL/2)\n" |
| 12096 |
" cylinder { tempXYZ tempXYZ2 RadiusDash texture { pigment{T1} } }\n" |
| 12097 |
" #else\n" |
| 12098 |
" cylinder { tempXYZ tempXYZ2 RadiusDash texture { pigment{T2} } }\n" |
| 12099 |
" #end //IL/2\n" |
| 12100 |
" #end //unicolor\n")); |
| 12101 |
body.append(QString(" #local tempXYZ=tempXYZ2-strip;\n")); |
| 12102 |
body.append(QString(" #local i=i+2;\n")); |
| 12103 |
body.append(QString(" #end\n")); |
| 12104 |
body.append(QString("#end\n\n")); |
| 12105 |
body.append(QString("#macro DrawArrow(at1,at2,rad,textur)\n")); |
| 12106 |
body.append(QString(" #local SpaceBeforeAt2 = 0.2; // arrow should end before ellipsoide\n")); |
| 12107 |
body.append(QString(" #local ArrowConeLength = rad*4;\n")); |
| 12108 |
body.append(QString(" #local ArrowConeRadius = rad*2;\n")); |
| 12109 |
body.append(QString(" #local ArrowVector = (at2 - at1);\n")); |
| 12110 |
body.append(QString(" #local ShaftMeetsHead = at2 - vnormalize (ArrowVector) * (ArrowConeLength+SpaceBeforeAt2);\n")); |
| 12111 |
body.append(QString(" #local ArrowPoint = at2 - vnormalize (ArrowVector) * SpaceBeforeAt2;\n")); |
| 12112 |
body.append(QString(" cylinder {at1 ShaftMeetsHead radiu texture { textur } }\n")); |
| 12113 |
body.append(QString(" cone {ShaftMeetsHead, ArrowConeRadius, ArrowPoint, 0 texture { textur } }\n")); |
| 12114 |
body.append(QString("#end\n\n")); |
| 12115 |
body.append(QString("#macro DrawArrowC(at1,at2,rad,colou)\n")); |
| 12116 |
body.append(QString(" #local SpaceBeforeAt2 = 0.2; // arrow should end before ellipsoide\n")); |
| 12117 |
body.append(QString(" #local ArrowConeLength = rad*4;\n")); |
| 12118 |
body.append(QString(" #local ArrowConeRadius = rad*2;\n")); |
| 12119 |
body.append(QString(" #local ArrowVector = (at2 - at1);\n")); |
| 12120 |
body.append(QString(" #local ShaftMeetsHead = at2 - vnormalize (ArrowVector) * (ArrowConeLength+SpaceBeforeAt2);\n")); |
| 12121 |
body.append(QString(" #local ArrowPoint = at2 - vnormalize (ArrowVector) * SpaceBeforeAt2;\n")); |
| 12122 |
body.append(QString(" cylinder {at1 ShaftMeetsHead rad texture { pigment {color colou} finish { Shiny } } }\n")); |
| 12123 |
body.append(QString(" cone {ShaftMeetsHead, ArrowConeRadius, ArrowPoint, 0 texture { pigment {color colou} finish { Shiny } } }\n")); |
| 12124 |
body.append(QString("#end\n\n")); |
| 12125 |
body.append(QString("#macro DrawRing(at1,at2,Ct)\n")); |
| 12126 |
body.append(QString("#declare w = vcross((at1-Ct),(at2-Ct));\n")); |
| 12127 |
body.append(QString("#declare RadiusBig = vlength((at1+at2)/2 - Ct);\n")); |
| 12128 |
body.append(QString("object {\n")); |
| 12129 |
body.append(QString(" torus\n")); |
| 12130 |
body.append(QString(" { RadiusBig*.75, Dash_Radius\n")); |
| 12131 |
body.append(QString(" texture { Bond_Texture }\n")); |
| 12132 |
body.append(QString(" }\n")); |
| 12133 |
body.append(QString(" Reorient_Trans(<0, 1, 0>,w)\n")); |
| 12134 |
body.append(QString(" translate Ct\n")); |
| 12135 |
body.append(QString(" }\n")); |
| 12136 |
body.append(QString("#end\n\n")); |
| 12137 |
body.append(QString("#macro DrawCube(cL,colorCube,colorEdge)\n")); |
| 12138 |
body.append(QString(" #local edgeR=cL/10;\n")); |
| 12139 |
body.append(QString(" box{ <-cL,-cL,-cL>,<cL,cL,cL> texture { finish { Shiny } pigment {color colorCube } } }\n")); |
| 12140 |
body.append(QString(" cylinder{ <-cL,-cL,-cL> < cL,-cL,-cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12141 |
body.append(QString(" cylinder{ <-cL,-cL,-cL> <-cL, cL,-cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12142 |
body.append(QString(" cylinder{ <-cL,-cL,-cL> <-cL,-cL, cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12143 |
body.append(QString(" cylinder{ < cL, cL, cL> < cL, cL,-cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12144 |
body.append(QString(" cylinder{ < cL, cL, cL> <-cL, cL, cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12145 |
body.append(QString(" cylinder{ < cL, cL, cL> < cL,-cL, cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12146 |
body.append(QString(" cylinder{ <-cL, cL, cL> <-cL, cL,-cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12147 |
body.append(QString(" cylinder{ <-cL, cL, cL> <-cL,-cL, cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12148 |
body.append(QString(" cylinder{ < cL,-cL, cL> < cL,-cL,-cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12149 |
body.append(QString(" cylinder{ < cL,-cL, cL> <-cL,-cL, cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12150 |
body.append(QString(" cylinder{ < cL, cL,-cL> < cL,-cL,-cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12151 |
body.append(QString(" cylinder{ < cL, cL,-cL> <-cL, cL,-cL> edgeR texture { finish { Shiny } pigment {color colorEdge } } }\n")); |
| 12152 |
body.append(QString("#end\n\n")); |
| 12153 |
body.append(QString("#declare Molekel_GrayLt = color red 0.70 green 0.70 blue 0.70;\n")); |
| 12154 |
body.append(QString("#declare Molekel_Red = color red 0.70 green 0.00 blue 0.00;\n")); |
| 12155 |
body.append(QString("#declare Molekel_Green = color red 0.00 green 0.40 blue 0.00;\n")); |
| 12156 |
body.append(QString("#declare Molekel_Blue = color red 0.00 green 0.00 blue 0.60;\n")); |
| 12157 |
body.append(QString("#declare Molekel_Yellow = color red 0.80 green 0.80 blue 0.00;\n")); |
| 12158 |
body.append(QString("#declare Molekel_Violet = color red 0.60 green 0.00 blue 0.60;\n")); |
| 12159 |
body.append(QString("#declare Molekel_GrayDk = color red 0.25 green 0.25 blue 0.25;\n")); |
| 12160 |
body.append(QString("#declare Molekel_BrownDk = color red 0.30 green 0.20 blue 0.10;\n")); |
| 12161 |
body.append(QString("#declare Molekel_BrownLt = color red 0.45 green 0.40 blue 0.25;\n")); |
| 12162 |
body.append(QString("#declare Lightblue = color red 0.56 green 0.56 blue 1.00;\n")); |
| 12163 |
body.append(QString("#declare DeepPink = color red 1.00 green 0.08 blue 0.58;\n\n")); |
| 12164 |
body.append(QString("#macro qpeakTexture(r, g, b)\n")); |
| 12165 |
body.append(QString(" texture{\n")); |
| 12166 |
body.append(QString(" pigment{\n")); |
| 12167 |
body.append(QString(" color <r, g, b>\n")); |
| 12168 |
body.append(QString(" filter 0.25\n")); |
| 12169 |
body.append(QString(" transmit 0.25}\n")); |
| 12170 |
body.append(QString(" finish{\n")); |
| 12171 |
body.append(QString(" specular 0.6\n")); |
| 12172 |
body.append(QString(" phong 0.2\n")); |
| 12173 |
body.append(QString(" phong_size 80}\n}\n")); |
| 12174 |
body.append(QString(" interior_texture{\n")); |
| 12175 |
body.append(QString(" pigment{\n")); |
| 12176 |
body.append(QString(" color <r, g, b>\n")); |
| 12177 |
body.append(QString(" filter 0.666\n")); |
| 12178 |
body.append(QString(" transmit 0.475\n")); |
| 12179 |
body.append(QString(" }\n")); |
| 12180 |
body.append(QString(" finish{\n")); |
| 12181 |
body.append(QString(" specular 0\n")); |
| 12182 |
body.append(QString(" }\n")); |
| 12183 |
body.append(QString(" }\n")); |
| 12184 |
body.append(QString("#end\n\n")); |
| 12185 |
body.append(QString("#if (BW)\n")); |
| 12186 |
body.append(QString("#declare diffPosCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12187 |
.arg(0.8) |
| 12188 |
.arg(0.8) |
| 12189 |
.arg(0.8) |
| 12190 |
.arg(1.0-chgl->lintrans)); |
| 12191 |
body.append(QString("#declare diffMinCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12192 |
.arg(0.2) |
| 12193 |
.arg(0.2) |
| 12194 |
.arg(0.2) |
| 12195 |
.arg(1.0-chgl->lintrans)); |
| 12196 |
body.append(QString("#declare FobsPosCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12197 |
.arg(0.4) |
| 12198 |
.arg(0.4) |
| 12199 |
.arg(0.4) |
| 12200 |
.arg(1.0-chgl->lintrans)); |
| 12201 |
body.append(QString("#declare FobsMinCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12202 |
.arg(0.6) |
| 12203 |
.arg(0.6) |
| 12204 |
.arg(0.6) |
| 12205 |
.arg(1.0-chgl->lintrans)); |
| 12206 |
body.append(QString("#else\n")); |
| 12207 |
body.append(QString("#declare diffPosCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12208 |
.arg(chgl->dipc.redF()) |
| 12209 |
.arg(chgl->dipc.greenF()) |
| 12210 |
.arg(chgl->dipc.blueF()) |
| 12211 |
.arg(1.0-chgl->lintrans)); |
| 12212 |
body.append(QString("#declare diffMinCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12213 |
.arg(chgl->dimc.redF()) |
| 12214 |
.arg(chgl->dimc.greenF()) |
| 12215 |
.arg(chgl->dimc.blueF()) |
| 12216 |
.arg(1.0-chgl->lintrans)); |
| 12217 |
body.append(QString("#declare FobsPosCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12218 |
.arg(chgl->fopc.redF()) |
| 12219 |
.arg(chgl->fopc.greenF()) |
| 12220 |
.arg(chgl->fopc.blueF()) |
| 12221 |
.arg(1.0-chgl->lintrans)); |
| 12222 |
body.append(QString("#declare FobsMinCol = texture{ pigment{ color rgbt<%1,%2,%3,%4>}finish { diffuse 1.0 ambient 0.5 specular 0.3 }};\n") |
| 12223 |
.arg(chgl->fomc.redF()) |
| 12224 |
.arg(chgl->fomc.greenF()) |
| 12225 |
.arg(chgl->fomc.blueF()) |
| 12226 |
.arg(1.0-chgl->lintrans)); |
| 12227 |
body.append(QString("#end\n")); |
| 12228 |
body.append(QString("#declare Bond_Texture = texture {\n")); |
| 12229 |
body.append(QString("#if (BW)\npigment {color rgb<%1,%1,%1>}\n#else\n").arg(chgl->mol->bondColor.valueF())); |
| 12230 |
body.append(QString("pigment {color rgb<%1, %2, %3>}\n#end\n").arg(chgl->mol->bondColor.redF()).arg(chgl->mol->bondColor.greenF()).arg(chgl->mol->bondColor.blueF())); |
| 12231 |
body.append(QString("finish { diffuse 1.0 ambient 0.5 specular 1.0 } }\n\n")); |
| 12232 |
body.append(QString("#declare HBond_Texture = texture {\n")); |
| 12233 |
body.append(QString("pigment {\n#if (BW)\ncolor rgb<0.7, 0.7, 0.7>\n#else\ncolor rgb<1, 1, 0>\n#end\n}\n")); |
| 12234 |
body.append(QString("finish { diffuse 1.0 ambient 0.5 specular 1.0 } }\n\n")); |
| 12235 |
QColor pcolor; |
| 12236 |
|
| 12237 |
body.append(QString("#declare Bond_Radius = %1;\n").arg(mole.bondStrength)); |
| 12238 |
body.append(QString("#declare H_Radius = Bond_Radius*1.3;\n")); |
| 12239 |
body.append(QString("#declare Dash_Radius = 0.6 * Bond_Radius;\n")); |
| 12240 |
body.append(QString("#declare Dash_Length = 0.14;\n")); |
| 12241 |
body.append(QString("#declare HBond_Radius = 0.6 * Bond_Radius;\n\n")); |
| 12242 |
body.append(QString("#macro label(lab,pos,col,scal)\n")); |
| 12243 |
body.append(QString("text{ttf atomfont lab 0.01, 0.0 texture{pigment{color col}finish{ambient 1.0}}\n")); |
| 12244 |
body.append(QString("scale scal\ntransform InvMat\ntranslate pos\ntranslate EyeDir\nno_shadow\n}\n#end\n\n")); |
| 12245 |
body.append(QString("#macro llabel(lab,pos,col,scal)\n")); |
| 12246 |
body.append(QString("text{ttf atomfont lab 0.01, 0.0 texture{pigment{color col}finish{ambient 1.0}}\n")); |
| 12247 |
body.append(QString("scale scal\ntranslate pos\nno_shadow\n}\n#end\n\n")); |
| 12248 |
body.append(QString("#if(BW) // _________________________________ set here colors for B&W modus\n")); |
| 12249 |
//body.append(QString("#declare Color_Ct = color rgb<%1,%1,%1>;\n")); |
| 12250 |
//body.append(QString("#declare Equator_Ct = color Gray05;\n")); |
| 12251 |
for (int pt=1; pt<100; pt++){ |
| 12252 |
|
| 12253 |
|
| 12254 |
pcolor=PartColor::color(pt); |
| 12255 |
pcolor.setAlpha(140); |
| 12256 |
body.append(QString("#declare ptcol%1 = color rgbt<%2, %3, %4, %5>;\n") |
| 12257 |
.arg(pt) |
| 12258 |
.arg(pcolor.valueF()) |
| 12259 |
.arg(pcolor.valueF()) |
| 12260 |
.arg(pcolor.valueF()) |
| 12261 |
.arg(1.0-pcolor.alphaF()) |
| 12262 |
); |
| 12263 |
|
| 12264 |
pcolor=PartColor::color(-pt); |
| 12265 |
pcolor.setAlpha(140); |
| 12266 |
body.append(QString("#declare ptcolm%5 = color rgbt<%1, %2, %3, %4>;\n") |
| 12267 |
.arg(pcolor.valueF()) |
| 12268 |
.arg(pcolor.valueF()) |
| 12269 |
.arg(pcolor.valueF()) |
| 12270 |
.arg(1.0-pcolor.alphaF()) |
| 12271 |
.arg(pt)); |
| 12272 |
} |
| 12273 |
pcolor=Qt::magenta; |
| 12274 |
pcolor.setAlpha(140); |
| 12275 |
body.append(QString("#declare ptcolmX = color rgbt<%1, %2, %3, %4>;\n") |
| 12276 |
.arg(pcolor.valueF()) |
| 12277 |
.arg(pcolor.valueF()) |
| 12278 |
.arg(pcolor.valueF()) |
| 12279 |
.arg(1.0-pcolor.alphaF())); |
| 12280 |
pcolor=QColor("fuchsia"); |
| 12281 |
pcolor.setAlpha(200); |
| 12282 |
body.append(QString("#declare ptcol666 = color rgbt<%1, %2, %3, %4>;\n") |
| 12283 |
.arg(pcolor.valueF()) |
| 12284 |
.arg(pcolor.valueF()) |
| 12285 |
.arg(pcolor.valueF()) |
| 12286 |
.arg(1.0-pcolor.alphaF()) |
| 12287 |
); |
| 12288 |
for (int i=0; i<103; i++){ |
| 12289 |
body.append(QString("#declare Color_%2 = color rgb<%1,%1,%1>;\n").arg(chgl->mol->AtomColor[i].valueF()).arg(chgl->mol->pse(i))); |
| 12290 |
body.append(QString("#declare Equator_%2 = color rgb<%1,%1,%1>;;\n").arg((chgl->mol->AtomStyle[i]&ATOM_STYLE_RINGS) |
| 12291 |
?((chgl->mol->AtomStyle[i]&ATOM_STYLE_WHITERING)? 0.95 : 0.05) |
| 12292 |
:chgl->mol->AtomColor[i].valueF()).arg(chgl->mol->pse(i)));//ATOM_STYLE_WHITERING//ATOM_STYLE_RINGS |
| 12293 |
} |
| 12294 |
body.append(QString("#declare Color_Q = color rgbt<0.5,0.5,0.5,0.5>;\n")); |
| 12295 |
body.append(QString("#declare Color_Cnt = color rgbt<0.2,0.2,0.2,0.5>;\n")); |
| 12296 |
body.append(QString("#else // _________________________________ set here colors for Color modus\n")); |
| 12297 |
for (int pt=1; pt<100; pt++){ |
| 12298 |
|
| 12299 |
pcolor=PartColor::color(pt); |
| 12300 |
pcolor.setAlpha(140); |
| 12301 |
body.append(QString("#declare ptcol%1 = color rgbt<%2, %3, %4, %5>;\n") |
| 12302 |
.arg(pt) |
| 12303 |
.arg(pcolor.redF()) |
| 12304 |
.arg(pcolor.greenF()) |
| 12305 |
.arg(pcolor.blueF()) |
| 12306 |
.arg(1.0-pcolor.alphaF()) |
| 12307 |
); |
| 12308 |
|
| 12309 |
pcolor=PartColor::color(-pt); |
| 12310 |
pcolor.setAlpha(140); |
| 12311 |
body.append(QString("#declare ptcolm%5 = color rgbt<%1, %2, %3, %4>;\n") |
| 12312 |
.arg(pcolor.redF()) |
| 12313 |
.arg(pcolor.greenF()) |
| 12314 |
.arg(pcolor.blueF()) |
| 12315 |
.arg(1.0-pcolor.alphaF()) |
| 12316 |
.arg(pt) |
| 12317 |
); |
| 12318 |
} |
| 12319 |
pcolor=Qt::magenta;pcolor.setAlpha(140); |
| 12320 |
body.append(QString("#declare ptcolmX = color rgbt<%1, %2, %3, %4>;\n") |
| 12321 |
.arg(pcolor.redF()) |
| 12322 |
.arg(pcolor.greenF()) |
| 12323 |
.arg(pcolor.blueF()) |
| 12324 |
.arg(1.0-pcolor.alphaF()) |
| 12325 |
); |
| 12326 |
pcolor=QColor("fuchsia"); |
| 12327 |
pcolor.setAlpha(200); |
| 12328 |
body.append(QString("#declare ptcol666 = color rgbt<%1, %2, %3, %4>;\n") |
| 12329 |
.arg(pcolor.redF()) |
| 12330 |
.arg(pcolor.greenF()) |
| 12331 |
.arg(pcolor.blueF()) |
| 12332 |
.arg(1.0-pcolor.alphaF()) |
| 12333 |
); |
| 12334 |
for (int i=0; i<103; i++){ |
| 12335 |
body.append(QString("#declare Color_%1 = color rgb<%2,%3,%4>;\n").arg(chgl->mol->pse(i)) |
| 12336 |
.arg(chgl->mol->AtomColor[i].redF()) |
| 12337 |
.arg(chgl->mol->AtomColor[i].greenF()) |
| 12338 |
.arg(chgl->mol->AtomColor[i].blueF())); |
| 12339 |
body.append(QString("#declare Equator_%2 = color rgb<%1,%1,%1>;;\n").arg((chgl->mol->AtomStyle[i]&ATOM_STYLE_RINGS) |
| 12340 |
?((chgl->mol->AtomStyle[i]&ATOM_STYLE_WHITERING)? 0.95 : 0.05) |
| 12341 |
:chgl->mol->AtomColor[i].valueF()).arg(chgl->mol->pse(i)));//ATOM_STYLE_WHITERING//ATOM_STYLE_RINGS |
| 12342 |
} |
| 12343 |
body.append(QString("#declare Color_Q = color rgbt<1.0,0.5,0.0,0.5>;\n")); |
| 12344 |
body.append(QString("#declare Color_Cnt = color Brown;\n")); |
| 12345 |
//body.append(QString("#declare Color_Ct = color Gray95;\n")); |
| 12346 |
//body.append(QString("#declare Equator_Ct = color Gray05;\n")); |
| 12347 |
body.append(QString("#end // _________________________________ end of Color modus\n")); |
| 12348 |
|
| 12349 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 12350 |
if (success){ |
| 12351 |
f.write(body.toUtf8()); |
| 12352 |
f.close(); |
| 12353 |
} |
| 12354 |
} |
| 12355 |
|
| 12356 |
void Window::saveScene(){ |
| 12357 |
//glGetDoublev(GL_MODELVIEW_MATRIX,chgl->MM); |
| 12358 |
|
| 12359 |
QList<QByteArray> supo = QImageWriter::supportedImageFormats (); |
| 12360 |
QString formats; |
| 12361 |
saveName = dirName; |
| 12362 |
saveName.replace(dirName.size()-4,4,".png"); |
| 12363 |
QString selectedFilter="png-file (*.png)"; |
| 12364 |
for (int i=0; i<supo.size(); i++){ |
| 12365 |
if ((!QString(supo.at(i)).contains("ps",Qt::CaseInsensitive)) && |
| 12366 |
(!QString(supo.at(i)).contains(QRegularExpression("[A-Z]")))) |
| 12367 |
formats+=QString("%1-file (*.%1)%2").arg(QString(supo.at(i))).arg(((i+1)<supo.size())?";;":""); |
| 12368 |
} |
| 12369 |
int |
| 12370 |
a = int(chgl->width()*scalePic+0.5), |
| 12371 |
b = int(chgl->height()*scalePic+0.5), |
| 12372 |
c = int(chgl->myFont.pointSize ()*scalePic+0.5), |
| 12373 |
//d = chgl->width(), |
| 12374 |
//e = chgl->height(), |
| 12375 |
f = chgl->myFont.pointSize (); |
| 12376 |
QString fileName = QFileDialog::getSaveFileName(this,QString("Save a screen shot with %1 x %2 pixels").arg(a).arg(b), saveName,formats,&selectedFilter); |
| 12377 |
if (!fileName.isEmpty()){ |
| 12378 |
QString endung=selectedFilter.section('*',1,1).section(')',0,0); |
| 12379 |
if (!fileName.endsWith(endung)) fileName.append(endung); |
| 12380 |
//chgl->noWaitLabel=true; |
| 12381 |
chgl->exporting=true; |
| 12382 |
chgl->myFont.setPointSize(c); |
| 12383 |
mole.saveProg=mole.g_Program; |
| 12384 |
QPixmap map; |
| 12385 |
|
| 12386 |
//if (scalePic!=1.0) map= chgl->renderPixmap(a,b); |
| 12387 |
if ((scalePic==1.0)||map.isNull ()){ |
| 12388 |
if (QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) { |
| 12389 |
QImage mapi=chgl->grabFramebuffer(); |
| 12390 |
//printf("hasOpenGLFramebufferObjects\n"); |
| 12391 |
mapi.save(fileName); |
| 12392 |
}else{ |
| 12393 |
#if (QT_VERSION >=0x050000) |
| 12394 |
QPixmap pixmap = screen->grabWindow( chgl->winId() ); |
| 12395 |
#else |
| 12396 |
QPixmap pixmap = QPixmap::grabWindow( chgl->winId() ); |
| 12397 |
#endif |
| 12398 |
pixmap.save(fileName); |
| 12399 |
} |
| 12400 |
}else map.save(fileName); |
| 12401 |
mole.g_Program=mole.saveProg; |
| 12402 |
if(!separateLabelFile->isChecked()) { |
| 12403 |
QPixmap fmap = QPixmap(fileName); |
| 12404 |
QPainter *paint = new QPainter(&fmap); |
| 12405 |
paint->setPen(QPen(chgl->labelColor)); |
| 12406 |
paint->setFont(chgl->myFont); |
| 12407 |
for (int n=0; n<chgl->LabelZ.size(); n++){ |
| 12408 |
if ((!(mole.AtomStyle[chgl->LabelZ.at(n).an]&ATOM_STYLE_NOLABEL))) |
| 12409 |
paint->drawText(chgl->LabelZ.at(n).x,chgl->LabelZ.at(n).y,chgl->LabelZ.at(n).l); |
| 12410 |
} |
| 12411 |
paint->end(); |
| 12412 |
fmap.save(fileName); |
| 12413 |
} |
| 12414 |
else{ |
| 12415 |
QPixmap fmap = QPixmap(a,b); |
| 12416 |
fmap.fill(QColor(128,128,128,0)); |
| 12417 |
QPainter *paint = new QPainter(&fmap); |
| 12418 |
paint->setPen(QPen(chgl->labelColor)); |
| 12419 |
paint->setFont(chgl->myFont); |
| 12420 |
for (int n=0; n<chgl->LabelZ.size(); n++){ |
| 12421 |
if ((!(mole.AtomStyle[chgl->LabelZ.at(n).an]&ATOM_STYLE_NOLABEL))) |
| 12422 |
paint->drawText(chgl->LabelZ.at(n).x,chgl->LabelZ.at(n).y,chgl->LabelZ.at(n).l); |
| 12423 |
} |
| 12424 |
paint->end(); |
| 12425 |
QString fn2=fileName; |
| 12426 |
fn2.insert(fileName.lastIndexOf("."),"_labels"); |
| 12427 |
fmap.save(fn2); |
| 12428 |
} |
| 12429 |
saveName=fileName; |
| 12430 |
chgl->exporting=false; |
| 12431 |
} |
| 12432 |
chgl->myFont.setPointSize(f); |
| 12433 |
//chgl->ww=d; |
| 12434 |
//chgl->wh=e; |
| 12435 |
//chgl->noWaitLabel=false; |
| 12436 |
} |
| 12437 |
|
| 12438 |
void Window::infoKanalNews(const QString& s){ |
| 12439 |
QString alt = infoKanal->toHtml(); |
| 12440 |
// printf("\n\n\n%s\n\n\n",(const char *)alt.toLocal8Bit()); |
| 12441 |
alt.remove(QRegularExpression("ERROR [^!]*!")); |
| 12442 |
alt.remove(QRegularExpression("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:large; color:#ff0000;\"><br /></span></p>", |
| 12443 |
QRegularExpression::CaseInsensitiveOption));//,QRegularExpression::FixedString |
| 12444 |
alt.remove(QRegularExpression("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:large; color:#ff0000;\"></span></p>" |
| 12445 |
,QRegularExpression::CaseInsensitiveOption)); |
| 12446 |
alt.append(s); |
| 12447 |
infoKanal->setHtml(alt); |
| 12448 |
QTextCursor c = infoKanal->textCursor(); |
| 12449 |
c.movePosition(QTextCursor::End); |
| 12450 |
infoKanal->setTextCursor(c); |
| 12451 |
infoKanal->ensureCursorVisible(); |
| 12452 |
if (chgl->toggleDockWidgets->isChecked()) return; |
| 12453 |
if ( enterRenameMode->isChecked()) return; |
| 12454 |
dock->show(); |
| 12455 |
dock->raise(); |
| 12456 |
} |
| 12457 |
|
| 12458 |
void Window::shx_editor(QString filename){ |
| 12459 |
if (otherOpenFiles){ |
| 12460 |
editor->clear(); |
| 12461 |
editor->document()->disconnect(); |
| 12462 |
actionUndo->disconnect(); |
| 12463 |
actionRedo->disconnect(); |
| 12464 |
actionCut->disconnect(); |
| 12465 |
actionCopy->disconnect(); |
| 12466 |
actionPaste->disconnect(); |
| 12467 |
} |
| 12468 |
altursize=0; |
| 12469 |
QFile shxf(filename); |
| 12470 |
if (shxf.open(QIODevice::ReadOnly|QIODevice::Text)){ |
| 12471 |
actionCut->setEnabled(false); |
| 12472 |
actionCopy->setEnabled(false); |
| 12473 |
QString s=shxf.readAll().replace('\0','~'); |
| 12474 |
QRegularExpression nonsp = QRegularExpression("[ \t]+\n"); |
| 12475 |
//printf("%d\n",__LINE__); |
| 12476 |
s=s.replace(nonsp, " \n");// printf("remove non used spaces\n"); |
| 12477 |
|
| 12478 |
//printf("%d %d\n",__LINE__,s.size()); |
| 12479 |
editor->setPlainText(s); |
| 12480 |
//printf("%d\n",__LINE__); |
| 12481 |
actionSave->setEnabled(false); |
| 12482 |
actionHFix->setDisabled(false); |
| 12483 |
setWindowModified(editor->document()->isModified()); |
| 12484 |
editor->highlighter->setDocument(editor->document()); |
| 12485 |
//printf("%d\n",__LINE__); |
| 12486 |
connectEdior(); |
| 12487 |
shxf.close(); |
| 12488 |
shxEditorDock->setWindowTitle(title); |
| 12489 |
shxEditorDock->show(); |
| 12490 |
shxEditorDock->raise(); |
| 12491 |
actionSearch->setEnabled(true); |
| 12492 |
actionNext->setEnabled(true); |
| 12493 |
actionPrev->setEnabled(true); |
| 12494 |
otherOpenFiles=true; |
| 12495 |
editor->fv=fvar; |
| 12496 |
QTextCursor c1=editor->textCursor(); |
| 12497 |
c1.movePosition(QTextCursor::End,QTextCursor::MoveAnchor); |
| 12498 |
int maxPos=c1.position(); |
| 12499 |
c1.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); |
| 12500 |
int pos1=0; |
| 12501 |
einstellung->beginGroup("Cursor"); |
| 12502 |
if (einstellung->contains("lastCursorHash")) |
| 12503 |
myHash=einstellung->value("lastCursorHash").toHash(); |
| 12504 |
//int uiui=0; |
| 12505 |
QHash<QString,QVariant>::iterator i = myHash.begin(); |
| 12506 |
while ((i != myHash.end()) && (myHash.size()>20)) { |
| 12507 |
i = myHash.erase(i); |
| 12508 |
//printf("%d %d\n",i,myHash.size()); |
| 12509 |
} |
| 12510 |
//qDebug()<<myHash; |
| 12511 |
pos1=myHash.value(dirName).toInt(); |
| 12512 |
einstellung->endGroup(); |
| 12513 |
if ((myHash.contains(dirName))&&(pos1<=maxPos)&&(pos1>=0)) |
| 12514 |
c1.setPosition(pos1,QTextCursor::MoveAnchor); |
| 12515 |
if (!c1.isNull()) editor->setTextCursor(c1); |
| 12516 |
editor->centerCursor(); |
| 12517 |
if (focusSet) editor->setFocus(Qt::OtherFocusReason); |
| 12518 |
if (!title.contains("!!Empty!!"))infoKanalNews(fvarinfo); |
| 12519 |
} |
| 12520 |
//printf("shx_edit\n"); |
| 12521 |
//printf("%d\n",__LINE__); |
| 12522 |
if (title.contains("!!Empty!!")) infoKanalNews("<font size=+2 color=red>No atoms in file!</font>"); |
| 12523 |
} |
| 12524 |
|
| 12525 |
bool Window::fileSave(bool spell, bool loadafter){ |
| 12526 |
if (spell) { |
| 12527 |
spellCheck(); |
| 12528 |
} |
| 12529 |
if (FehlerTeufel) { |
| 12530 |
QMessageBox::warning(0,"Syntax-errors", "Syntax-errors were found in the file please correct them before saving! (Saving more frequently might reduce errors caused by this GUI)",QMessageBox::Ok,QMessageBox::Ok); |
| 12531 |
return false; |
| 12532 |
} |
| 12533 |
QFile f(dirName); |
| 12534 |
|
| 12535 |
if ((chgl->rotze!=-1)&&(chgl->rotze<mole.asymm.size())) { |
| 12536 |
popel = mole.asymm.at(chgl->rotze).orginalLine.left(80).trimmed(); |
| 12537 |
//printf("rot center should stay %d\n", chgl->rotze); |
| 12538 |
} else { |
| 12539 |
popel = ""; |
| 12540 |
//printf("%d %d!\n", chgl->rotze, mole.asymm.size()); |
| 12541 |
chgl->rotze=-1; |
| 12542 |
} |
| 12543 |
|
| 12544 |
f.open(QIODevice::ReadOnly|QIODevice::Text); |
| 12545 |
QString alterScheis=f.readAll(); |
| 12546 |
QFileInfo fi(f); |
| 12547 |
f.close(); |
| 12548 |
QTextCursor c=editor->textCursor(); |
| 12549 |
if (!c.isNull()){ |
| 12550 |
myHash[dirName]=c.position(); |
| 12551 |
einstellung->beginGroup("Cursor"); |
| 12552 |
einstellung->setValue("lastCursorHash", myHash ); |
| 12553 |
einstellung->endGroup(); |
| 12554 |
} |
| 12555 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 12556 |
if (success){ |
| 12557 |
f.write(editor->toPlainText().toLatin1()); |
| 12558 |
f.close(); |
| 12559 |
QString dn=dirName.section('/',0,-2), |
| 12560 |
argument=dirName.section('/',-1); |
| 12561 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 12562 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 12563 |
QString saveHistName=QString("%1/%2saves/SAVEHIST").arg(dn).arg(PROGRAM_NAME); |
| 12564 |
QFile sahi(saveHistName); |
| 12565 |
sahi.open(QIODevice::Append|QIODevice::Text); |
| 12566 |
sahi.write(QString("Entry|@|%1|@|%2|@|\n").arg(fi.lastModified().toString(Qt::ISODate)).arg(argument).toLatin1()); |
| 12567 |
sahi.write(alterScheis.toLatin1()); |
| 12568 |
sahi.close(); |
| 12569 |
editor->document()->setModified(false); |
| 12570 |
if (loadafter) { |
| 12571 |
loadFile(dirName); |
| 12572 |
} |
| 12573 |
} |
| 12574 |
else |
| 12575 |
infoKanalNews(QString("<font color=\"red\">%1 could not be opened for writing!</font>").arg(f.fileName())); |
| 12576 |
return success; |
| 12577 |
} |
| 12578 |
|
| 12579 |
bool Window::fileSaveAs(){ |
| 12580 |
spellCheck(); |
| 12581 |
if (FehlerTeufel) { |
| 12582 |
QMessageBox::warning(0,"Syntax-errors", "Syntax-errors were found in the file please correct them before saving! (Saving more frequently might reduce errors caused by this GUI)",QMessageBox::Ok,QMessageBox::Ok); |
| 12583 |
return false; |
| 12584 |
} |
| 12585 |
QString fn=QFileDialog::getSaveFileName(this, tr("Save As ..."), dirName, tr("SHELX-files (*.res *.ins)")); |
| 12586 |
if (fn.isEmpty()) return false; |
| 12587 |
QFile f(fn); |
| 12588 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 12589 |
if (success){ |
| 12590 |
f.write(editor->toPlainText().toLatin1()); |
| 12591 |
f.close(); |
| 12592 |
editor->document()->setModified(false); |
| 12593 |
loadFile(dirName=fn); |
| 12594 |
} |
| 12595 |
return success; |
| 12596 |
} |
| 12597 |
|
| 12598 |
void Window::fileSave4hklf5(){ |
| 12599 |
spellCheck(); |
| 12600 |
if (FehlerTeufel) { |
| 12601 |
QMessageBox::warning(0,"Syntax-errors", "Syntax-errors were found in the file please correct them before saving! (Saving more frequently might reduce errors caused by this GUI)",QMessageBox::Ok,QMessageBox::Ok); |
| 12602 |
return; |
| 12603 |
} |
| 12604 |
printf("fileSave4hklf5\n"); |
| 12605 |
makeItHKLF5(); |
| 12606 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 12607 |
QString fn=""; |
| 12608 |
if (action) |
| 12609 |
fn=action->data().toString(); |
| 12610 |
else return; |
| 12611 |
if (fn.isEmpty()) return; |
| 12612 |
QFile f(fn); |
| 12613 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 12614 |
if (success){ |
| 12615 |
f.write(editor->toPlainText().toLatin1()); |
| 12616 |
f.close(); |
| 12617 |
editor->document()->setModified(false); |
| 12618 |
loadFile(dirName=fn); |
| 12619 |
} |
| 12620 |
} |
| 12621 |
|
| 12622 |
void Window::unique(){ |
| 12623 |
if (mole.asymm.isEmpty()) return; |
| 12624 |
mole.enviSDM(2.5); |
| 12625 |
if (mole.maxmols()==0)sdm(); |
| 12626 |
QSet<int> molecules; |
| 12627 |
QList<int> flags; |
| 12628 |
for (int i=0; i<mole.asymm.size(); i++) if (molecules.contains(mole.asymm.at(i).molindex)){ |
| 12629 |
flags.append(-1); |
| 12630 |
}else { |
| 12631 |
molecules.insert(mole.asymm.at(i).molindex); |
| 12632 |
flags.append(1); |
| 12633 |
} |
| 12634 |
int finished=1; |
| 12635 |
do{ |
| 12636 |
finished=1; |
| 12637 |
for (int i=0; i<mole.envi_sdm.size(); i++){ |
| 12638 |
if ((flags.at(mole.envi_sdm.at(i).a1)*flags.at(mole.envi_sdm.at(i).a2)==-1)&& |
| 12639 |
( mole.asymm.at(mole.envi_sdm.at(i).a1).molindex==mole.asymm.at(mole.envi_sdm.at(i).a2).molindex )) { |
| 12640 |
if ((mole.asymm[mole.envi_sdm.at(i).a1].an<0)||(mole.asymm[mole.envi_sdm.at(i).a2].an<0))continue; |
| 12641 |
if (flags.at(mole.envi_sdm.at(i).a1)==1)continue; |
| 12642 |
if ((mole.envi_sdm.at(i).sn==0)&&(mole.envi_sdm.at(i).floorD==V3(0,0,0))) { |
| 12643 |
flags[mole.envi_sdm.at(i).a1]=1; |
| 12644 |
// flags[mole.envi_sdm.at(i).a2]=1; |
| 12645 |
finished=0; |
| 12646 |
break; |
| 12647 |
} |
| 12648 |
mole.asymm[mole.envi_sdm.at(i).a1].frac = |
| 12649 |
mole.cell.symmops.at(mole.envi_sdm.at(i).sn) * |
| 12650 |
mole.asymm[mole.envi_sdm.at(i).a1].frac + |
| 12651 |
mole.cell.trans.at(mole.envi_sdm.at(i).sn) - |
| 12652 |
mole.envi_sdm.at(i).floorD; |
| 12653 |
flags[mole.envi_sdm.at(i).a1]=1; |
| 12654 |
// flags[mole.envi_sdm.at(i).a2]=1; |
| 12655 |
mole.frac2kart(mole.asymm[mole.envi_sdm.at(i).a1].frac, mole.asymm[mole.envi_sdm.at(i).a1].pos); |
| 12656 |
finished=0; |
| 12657 |
|
| 12658 |
mole.enviSDM(2.5); |
| 12659 |
break; |
| 12660 |
} |
| 12661 |
} |
| 12662 |
}while (!finished); |
| 12663 |
mole.showatoms.clear(); |
| 12664 |
mole.showbonds.clear(); |
| 12665 |
chgl->mol->showatoms.clear(); |
| 12666 |
chgl->mol->showbonds.clear(); |
| 12667 |
chgl->mol->selectedatoms.clear(); |
| 12668 |
for (int o=0; o<mole.asymm.size();o++){ |
| 12669 |
mole.showatoms.append(mole.asymm[o]); |
| 12670 |
} |
| 12671 |
mole.sdmcompleter(); |
| 12672 |
mole.showbonds = |
| 12673 |
mole.connecting(mole.showatoms); |
| 12674 |
chgl->setMolecule(&mole); |
| 12675 |
loadMolInTest(); |
| 12676 |
|
| 12677 |
chgl->mol->selectedatoms.clear(); |
| 12678 |
|
| 12679 |
|
| 12680 |
QTextDocument *document = editor->document(); |
| 12681 |
QTextCursor cursor = editor->textCursor(); |
| 12682 |
cursor.beginEditBlock (); |
| 12683 |
|
| 12684 |
for (int i=0; i<mole.asymm.size();i++){ |
| 12685 |
cursor.movePosition(QTextCursor::Start); |
| 12686 |
QString label=mole.asymm.at(i).orginalLine.left(80).trimmed(); |
| 12687 |
cursor = document->find(label ,cursor); |
| 12688 |
|
| 12689 |
if (cursor.isNull()){ |
| 12690 |
cursor = editor->textCursor(); |
| 12691 |
cursor.movePosition(QTextCursor::Start); |
| 12692 |
label.chop(10); |
| 12693 |
cursor = document->find(label,cursor); |
| 12694 |
if (cursor.isNull()) { |
| 12695 |
cursor = editor->textCursor(); |
| 12696 |
} |
| 12697 |
} |
| 12698 |
QString vorherig,neues; |
| 12699 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 12700 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 12701 |
while (cursor.selectedText().endsWith("=")) { |
| 12702 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 12703 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 12704 |
} |
| 12705 |
neues = vorherig= cursor.selectedText(); |
| 12706 |
QStringList sl = vorherig.split(leer); |
| 12707 |
sl.removeOne("="); |
| 12708 |
if (sl.size()>=7) |
| 12709 |
neues=QString("%1 %2 %3 %4 %5 %6 %7 ") |
| 12710 |
.arg(mole.asymm.at(i).Label.section('_',0,0),-4) |
| 12711 |
.arg(qMax(1,editor->sfac.indexOf(mole.asymm.at(i).an)+1)) |
| 12712 |
.arg(mole.asymm.at(i).frac.x,10,'f',6) |
| 12713 |
.arg(mole.asymm.at(i).frac.y,10,'f',6) |
| 12714 |
.arg(mole.asymm.at(i).frac.z,10,'f',6) |
| 12715 |
.arg(mole.asymm.at(i).sof_org,9,'f',5) |
| 12716 |
.arg((mole.asymm.at(i).isIso)?mole.asymm.at(i).ufiso_org:QString("%1").arg(mole.asymm.at(i).uf.m11,9,'f',5)); |
| 12717 |
mole.asymm[i].orginalLine=neues; |
| 12718 |
if (mole.asymm.at(i).an<0) { |
| 12719 |
neues.append(QString("%1 ") |
| 12720 |
.arg(mole.asymm.at(i).peakHeight,9,'f',2)); |
| 12721 |
} else |
| 12722 |
if (!mole.asymm.at(i).isIso){ |
| 12723 |
neues.append(QString("%1 =\n %2 %3 %4 %5") |
| 12724 |
.arg(mole.asymm.at(i).uf.m22,9,'f',5) |
| 12725 |
.arg(mole.asymm.at(i).uf.m33,9,'f',5) |
| 12726 |
.arg(mole.asymm.at(i).uf.m23,9,'f',5) |
| 12727 |
.arg(mole.asymm.at(i).uf.m13,9,'f',5) |
| 12728 |
.arg(mole.asymm.at(i).uf.m12,9,'f',5)); |
| 12729 |
} |
| 12730 |
cursor.deleteChar(); |
| 12731 |
cursor.insertText(neues); |
| 12732 |
|
| 12733 |
}//i |
| 12734 |
cursor.endEditBlock (); |
| 12735 |
molecules.clear(); |
| 12736 |
flags.clear(); |
| 12737 |
mole.envi_sdm.clear(); |
| 12738 |
bool growYes=chgl->fuse->isVisible (); |
| 12739 |
chgl->mol->fuse(); |
| 12740 |
if (growYes) chgl->mol->grow(); |
| 12741 |
|
| 12742 |
loadMolInTest(); |
| 12743 |
// printf("%d\n",__LINE__); |
| 12744 |
|
| 12745 |
} |
| 12746 |
|
| 12747 |
void Window::editorIsVisible(bool vis){editor->uCanSeeMe=vis;}//isVisible is also true if widget is stacked behind an other |
| 12748 |
|
| 12749 |
void Window::outputIsVisible(bool vis){xlPutor->uCanSeeMe=vis;} |
| 12750 |
|
| 12751 |
void Window::hideToolz(bool b){ |
| 12752 |
|
| 12753 |
editToolBar->setVisible(!b); |
| 12754 |
refineToolBar->setVisible(!b); |
| 12755 |
bottomToolBar->setVisible(!b); |
| 12756 |
fito->setVisible(!b); |
| 12757 |
vito->setVisible(!b); |
| 12758 |
update(); |
| 12759 |
} |
| 12760 |
|
| 12761 |
void Window::updateLC(){ |
| 12762 |
QTextCursor tc = editor->textCursor(); |
| 12763 |
int l,c; |
| 12764 |
l=tc.blockNumber()+1; |
| 12765 |
c=tc.columnNumber()+1; |
| 12766 |
lineColumn->setText(QString("Line: <b>%1</b> | Col: <b>%2</b>").arg(l,5).arg(c,5)); |
| 12767 |
editor->update(); |
| 12768 |
lineColumn->update(); |
| 12769 |
} |
| 12770 |
|
| 12771 |
void Window::showEvent(QShowEvent *e){ |
| 12772 |
//printf("show?\n"); |
| 12773 |
if (QString(PROGRAM_NAME).compare("shelXle")){ |
| 12774 |
//printf("!Hide me now! %s\n%s\n%s\n",(isVisible())?"visible":"invisible",PROGRAM_NAME,"shelXle"); |
| 12775 |
e->accept(); |
| 12776 |
} |
| 12777 |
} |
| 12778 |
|
| 12779 |
|
| 12780 |
void Window::hideEvent(QHideEvent *){ |
| 12781 |
//printf("hide?\n"); |
| 12782 |
//printf("Hide me now! %s %s\n",(isVisible())?"visible":"invisible",PROGRAM_NAME); |
| 12783 |
} |
| 12784 |
|
| 12785 |
void Window::paintEvent(QPaintEvent * e){ |
| 12786 |
//static int ap=0; |
| 12787 |
if (QString(PROGRAM_NAME).compare("shelXle")){ |
| 12788 |
//printf("may be no paint\n"); |
| 12789 |
setVisible(false); |
| 12790 |
e->accept(); |
| 12791 |
hide(); |
| 12792 |
} |
| 12793 |
/*if (chgl->stereo_mode==1){ |
| 12794 |
int p=geometry().y()+chgl->y(); |
| 12795 |
// chgl->minus=(p%2)?-1:1; |
| 12796 |
chgl->minus=(p%2)?1:-1; |
| 12797 |
if (p!=ap) chgl->update(); |
| 12798 |
ap=p; |
| 12799 |
} // */ |
| 12800 |
//printf("paint\n"); |
| 12801 |
} |
| 12802 |
|
| 12803 |
|
| 12804 |
void Window::closeSR(bool vis){ |
| 12805 |
//* |
| 12806 |
if (vis) return; |
| 12807 |
QDockWidget *splitDoc = findChild<QDockWidget*>("splitRotate"); |
| 12808 |
if (splitDoc != nullptr) { |
| 12809 |
//printf("closeCR ?\n"); |
| 12810 |
mole.selectedatoms.clear(); |
| 12811 |
chgl->updateBondActions(); |
| 12812 |
chgl->changePivot1(-1); |
| 12813 |
chgl->changePivot2(-1); |
| 12814 |
chgl->pivot1cb->clear(); |
| 12815 |
chgl->pivot2cb->clear(); |
| 12816 |
//qDebug()<<splitDoc->children(); |
| 12817 |
QWidget *w = splitDoc->findChild<QWidget*>("splitRotateWidget"); |
| 12818 |
splitDoc->close(); |
| 12819 |
splitDoc->deleteLater(); |
| 12820 |
QObjectList ol=w->children(); |
| 12821 |
for (int i=0;i<ol.size();i++) { |
| 12822 |
ol[i]->deleteLater(); |
| 12823 |
} |
| 12824 |
//printf("now?\n"); |
| 12825 |
chgl->manualAx=nullptr; |
| 12826 |
chgl->freeRot=nullptr; |
| 12827 |
chgl->angle1=nullptr; |
| 12828 |
chgl->angle2=nullptr; |
| 12829 |
chgl->whyNotSplit->clear(); |
| 12830 |
chgl->whyNotSplit = nullptr; |
| 12831 |
chgl->pivot2cb=nullptr; |
| 12832 |
chgl->pivot1cb=nullptr; |
| 12833 |
chgl->axx=nullptr; |
| 12834 |
chgl->axy=nullptr; |
| 12835 |
chgl->axz=nullptr; |
| 12836 |
chgl->orgx=nullptr; |
| 12837 |
chgl->orgy=nullptr; |
| 12838 |
chgl->orgz=nullptr; |
| 12839 |
//printf("closeCR !\n"); |
| 12840 |
} |
| 12841 |
// */ |
| 12842 |
|
| 12843 |
} |
| 12844 |
|
| 12845 |
void Window::splitRotate(){ |
| 12846 |
//* |
| 12847 |
QDockWidget *splitDoc = findChild<QDockWidget*>("splitRotate"); |
| 12848 |
if (splitDoc == nullptr) { |
| 12849 |
//if (chgl->canSplitRotate()) {chgl->updateBondActions(); chgl->splitRotate();} |
| 12850 |
splitDoc = new QDockWidget("Split rotate molecule branch", this); |
| 12851 |
QWidget *w = new QWidget(splitDoc); |
| 12852 |
w->setObjectName("splitRotateWidget"); |
| 12853 |
splitDoc->setObjectName("splitRotate"); |
| 12854 |
splitDoc->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetClosable); |
| 12855 |
QGridLayout *glo= new QGridLayout(w); |
| 12856 |
chgl->whyNotSplit = new QLabel(w); |
| 12857 |
chgl->angle1 = new QSpinBox(w); |
| 12858 |
chgl->angle2 = new QSpinBox(w); |
| 12859 |
chgl->angle1->setRange(0,360); |
| 12860 |
chgl->angle2->setRange(0,360); |
| 12861 |
chgl->angle1->setValue(30); |
| 12862 |
chgl->angle2->setValue(0); |
| 12863 |
chgl->angle1->setEnabled(chgl->canSplitRotate()); |
| 12864 |
chgl->angle2->setEnabled(chgl->canSplitRotate()); |
| 12865 |
QDial *ang1dial =new QDial(w); |
| 12866 |
QDial *ang2dial =new QDial(w); |
| 12867 |
ang1dial->setWrapping(true); |
| 12868 |
ang2dial->setWrapping(true); |
| 12869 |
ang1dial->setRange(0,360); |
| 12870 |
ang2dial->setRange(0,360); |
| 12871 |
ang1dial->setNotchesVisible(true); |
| 12872 |
ang2dial->setNotchesVisible(true); |
| 12873 |
ang1dial->setValue(30); |
| 12874 |
ang2dial->setValue(0); |
| 12875 |
ang1dial->setMinimumSize(110,110); |
| 12876 |
ang2dial->setMinimumSize(110,110); |
| 12877 |
ang1dial->setMaximumSize(110,110); |
| 12878 |
ang2dial->setMaximumSize(110,110); |
| 12879 |
ang1dial->setEnabled(chgl->canSplitRotate()); |
| 12880 |
ang2dial->setEnabled(chgl->canSplitRotate()); |
| 12881 |
|
| 12882 |
connect(ang1dial,SIGNAL(valueChanged(int)),chgl->angle1,SLOT(setValue(int))); |
| 12883 |
connect(ang2dial,SIGNAL(valueChanged(int)),chgl->angle2,SLOT(setValue(int))); |
| 12884 |
|
| 12885 |
connect(chgl->angle1,SIGNAL(valueChanged(int)),ang1dial,SLOT(setValue(int))); |
| 12886 |
connect(chgl->angle2,SIGNAL(valueChanged(int)),ang2dial,SLOT(setValue(int))); |
| 12887 |
connect(chgl,SIGNAL(splitable(bool)),chgl->angle1,SLOT(setEnabled(bool))); |
| 12888 |
connect(chgl,SIGNAL(splitable(bool)),chgl->angle2,SLOT(setEnabled(bool))); |
| 12889 |
connect(chgl,SIGNAL(splitable(bool)),ang1dial,SLOT(setEnabled(bool))); |
| 12890 |
connect(chgl,SIGNAL(splitable(bool)),ang2dial,SLOT(setEnabled(bool))); |
| 12891 |
connect(chgl,SIGNAL(splitable(bool)),this,SLOT(update())); |
| 12892 |
connect(chgl->angle1,SIGNAL(valueChanged(int)),chgl,SLOT(splitRotate())); |
| 12893 |
connect(chgl->angle2,SIGNAL(valueChanged(int)),chgl,SLOT(splitRotate())); |
| 12894 |
connect(chgl,SIGNAL(splitable(bool)),chgl,SLOT(splitRotate())); |
| 12895 |
chgl->pivot1cb = new QComboBox(w); |
| 12896 |
chgl->pivot2cb = new QComboBox(w); |
| 12897 |
for (int i=0; i<mole.asymm.size();i++){ |
| 12898 |
chgl->pivot1cb->insertItem(i,mole.asymm.at(i).Label); |
| 12899 |
chgl->pivot2cb->insertItem(i,mole.asymm.at(i).Label); |
| 12900 |
} |
| 12901 |
connect(chgl,SIGNAL(pivot1Changed(int)),chgl->pivot1cb,SLOT(setCurrentIndex (int))); |
| 12902 |
connect(chgl,SIGNAL(pivot2Changed(int)),chgl->pivot2cb,SLOT(setCurrentIndex (int))); |
| 12903 |
|
| 12904 |
//connect(chgl,SIGNAL(splitable(bool)),pivot1,SLOT(setEnabled(bool))); |
| 12905 |
//connect(chgl,SIGNAL(splitable(bool)),pivot2,SLOT(setEnabled(bool))); |
| 12906 |
connect(chgl->pivot1cb,SIGNAL(currentIndexChanged(int)) ,chgl,SLOT(changePivot1(int))); |
| 12907 |
connect(chgl->pivot2cb,SIGNAL(currentIndexChanged(int)) ,chgl,SLOT(changePivot2(int))); |
| 12908 |
|
| 12909 |
|
| 12910 |
chgl->axx=new QDoubleSpinBox(w); |
| 12911 |
chgl->axy=new QDoubleSpinBox(w); |
| 12912 |
chgl->axz=new QDoubleSpinBox(w); |
| 12913 |
chgl->orgx=new QDoubleSpinBox(w); |
| 12914 |
chgl->orgy=new QDoubleSpinBox(w); |
| 12915 |
chgl->orgz=new QDoubleSpinBox(w); |
| 12916 |
chgl->manualAx= new QCheckBox("Rotate rotation axis [ALT]+[LeftMouse]",w); |
| 12917 |
chgl->freeRot = new QCheckBox("Free move and rotate selected\natomes for part1\n[CTRL]+[ALT]+[LeftMouse] rotates and\n" |
| 12918 |
"[CTRL]+[ALT]+[MiddleMouse] moves.",w); |
| 12919 |
|
| 12920 |
|
| 12921 |
chgl->axx->setValue(1); |
| 12922 |
chgl->axy->setValue(0); |
| 12923 |
chgl->axz->setValue(0); |
| 12924 |
chgl->axx->setRange(-1.0,1.0); |
| 12925 |
chgl->axy->setRange(-1.0,1.0); |
| 12926 |
chgl->axz->setRange(-1.0,1.0); |
| 12927 |
chgl->axx->setSingleStep(0.01); |
| 12928 |
chgl->axy->setSingleStep(0.01); |
| 12929 |
chgl->axz->setSingleStep(0.01); |
| 12930 |
chgl->axx->setDecimals(6); |
| 12931 |
chgl->axy->setDecimals(6); |
| 12932 |
chgl->axz->setDecimals(6); |
| 12933 |
chgl->axx->setEnabled(false); |
| 12934 |
chgl->axy->setEnabled(false); |
| 12935 |
chgl->axz->setEnabled(false); |
| 12936 |
|
| 12937 |
|
| 12938 |
chgl->orgx->setValue(0); |
| 12939 |
chgl->orgy->setValue(0); |
| 12940 |
chgl->orgz->setValue(0); |
| 12941 |
chgl->orgx->setRange(-3*chgl->mol->cell.a,3*chgl->mol->cell.a); |
| 12942 |
chgl->orgy->setRange(-3*chgl->mol->cell.b,3*chgl->mol->cell.b); |
| 12943 |
chgl->orgz->setRange(-3*chgl->mol->cell.c,3*chgl->mol->cell.c); |
| 12944 |
chgl->orgx->setSingleStep(0.01); |
| 12945 |
chgl->orgy->setSingleStep(0.01); |
| 12946 |
chgl->orgz->setSingleStep(0.01); |
| 12947 |
chgl->orgx->setDecimals(6); |
| 12948 |
chgl->orgy->setDecimals(6); |
| 12949 |
chgl->orgz->setDecimals(6); |
| 12950 |
chgl->orgx->setEnabled(false); |
| 12951 |
chgl->orgy->setEnabled(false); |
| 12952 |
chgl->orgz->setEnabled(false); |
| 12953 |
|
| 12954 |
|
| 12955 |
sr_same = new QCheckBox("Use SAME restraint",w); |
| 12956 |
sr_simu = new QCheckBox("Use SIMU restraint",w); |
| 12957 |
sr_rigu = new QCheckBox("Use RIGU restraint",w); |
| 12958 |
sr_alter_name = new QCheckBox("Alter names of 2nd part");//give alternataive name to 2nd part atoms |
| 12959 |
sr_alter_name->setToolTip("This will add a ' to the atom names of the second part."); |
| 12960 |
sr_ExyzAadp_ifclose = new QCheckBox("EXYZ and EADP for too close atoms"); // apply EXYZ and EADP if atoms are very close |
| 12961 |
|
| 12962 |
sr_same->setChecked(true); |
| 12963 |
sr_simu->setChecked(true); |
| 12964 |
sr_rigu->setChecked(true); |
| 12965 |
sr_alter_name->setChecked(false); |
| 12966 |
sr_ExyzAadp_ifclose->setChecked(true); |
| 12967 |
|
| 12968 |
connect(chgl->manualAx,SIGNAL(stateChanged(int)),chgl,SLOT(splitRotate())); |
| 12969 |
connect(chgl->freeRot,SIGNAL(stateChanged(int)),chgl,SLOT(splitRotate())); |
| 12970 |
connect(chgl->axx,SIGNAL(valueChanged(double)),chgl,SLOT(splitRotate())); |
| 12971 |
connect(chgl->axy,SIGNAL(valueChanged(double)),chgl,SLOT(splitRotate())); |
| 12972 |
connect(chgl->axz,SIGNAL(valueChanged(double)),chgl,SLOT(splitRotate())); |
| 12973 |
|
| 12974 |
lpart= new QSpinBox(w); |
| 12975 |
rpart= new QSpinBox(w); |
| 12976 |
//printf("spinSelectPart->minimum()-2 = %d,spinSelectPart->maximum()+2 %d\n",spinSelectPart->minimum()-2,spinSelectPart->maximum()+2); |
| 12977 |
lpart->setRange(spinSelectPart->minimum()-2,spinSelectPart->maximum()+2); |
| 12978 |
rpart->setRange(spinSelectPart->minimum()-2,spinSelectPart->maximum()+2); |
| 12979 |
lpart->setValue(spinSelectPart->maximum()+1); |
| 12980 |
rpart->setValue(spinSelectPart->maximum()+2); |
| 12981 |
QPushButton *split = new QPushButton("Split molecule now",w); |
| 12982 |
connect(chgl, SIGNAL(splitable(bool)), split, SLOT(setEnabled(bool))); |
| 12983 |
QPushButton *cancel=new QPushButton("Cancel",w); |
| 12984 |
connect(cancel,SIGNAL(pressed ()),this,SLOT(notsplit())); |
| 12985 |
connect(split,SIGNAL(pressed ()),this,SLOT(split())); |
| 12986 |
glo->addWidget(chgl->whyNotSplit ,0,0,1,10,Qt::AlignBottom); |
| 12987 |
|
| 12988 |
glo->addWidget(new QLabel("rotation angle of left branch",w) ,1,0,1,2,Qt::AlignRight|Qt::AlignBottom); |
| 12989 |
glo->addWidget(new QLabel("rotation angle of right branch",w) ,1,2,1,2,Qt::AlignRight|Qt::AlignBottom); |
| 12990 |
|
| 12991 |
glo->addWidget(chgl->angle1 ,2,0,1,1); |
| 12992 |
glo->addWidget(ang1dial ,2,1,1,1); |
| 12993 |
glo->addWidget(chgl->angle2 ,2,2,1,1); |
| 12994 |
glo->addWidget(ang2dial ,2,3,1,1); |
| 12995 |
|
| 12996 |
glo->addWidget(new QLabel("axis of rotation origin (pivot)",w),3,0,1,1); |
| 12997 |
glo->addWidget(chgl->pivot1cb ,3,1,1,1); |
| 12998 |
glo->addWidget(new QLabel("axis of rotation ",w) ,3,2,1,1); |
| 12999 |
glo->addWidget(chgl->pivot2cb ,3,3,1,1); |
| 13000 |
|
| 13001 |
glo->addWidget(chgl->manualAx, 4,0,1,1); |
| 13002 |
glo->addWidget(chgl->axx, 4,1,1,1); |
| 13003 |
glo->addWidget(chgl->axy, 4,2,1,1); |
| 13004 |
glo->addWidget(chgl->axz, 4,3,1,1); |
| 13005 |
|
| 13006 |
glo->addWidget(chgl->freeRot, 5,0,1,1); |
| 13007 |
glo->addWidget(chgl->orgx, 5,1,1,1); |
| 13008 |
glo->addWidget(chgl->orgy, 5,2,1,1); |
| 13009 |
glo->addWidget(chgl->orgz, 5,3,1,1); |
| 13010 |
|
| 13011 |
glo->addWidget(new QLabel("left PART",w), 7,0,1,1); |
| 13012 |
glo->addWidget(lpart, 7,1,1,1); |
| 13013 |
glo->addWidget(new QLabel("right PART",w), 7,2,1,1); |
| 13014 |
glo->addWidget(rpart, 7,3,1,1); |
| 13015 |
|
| 13016 |
glo->addWidget(sr_same, 8,0,1,1); |
| 13017 |
glo->addWidget(sr_simu, 8,1,1,1); |
| 13018 |
glo->addWidget(sr_rigu, 8,2,1,1); |
| 13019 |
glo->addWidget(sr_alter_name, 9,0,1,1); |
| 13020 |
glo->addWidget(sr_ExyzAadp_ifclose, 9,1,1,1); |
| 13021 |
|
| 13022 |
glo->addWidget(cancel, 11,2,1,1); |
| 13023 |
glo->addWidget(split, 11,3,1,1); |
| 13024 |
//glo->addWidget(new QLabel("<h3>This feature is not final yet!!</h3> ",w),10,0,1,10); |
| 13025 |
splitDoc->setWidget(w); |
| 13026 |
if (!chgl->canSplitRotate()){ |
| 13027 |
chgl->whyNotSplit->setText("<h2>select some atoms (asymmetric unit only)</h2>"); |
| 13028 |
} |
| 13029 |
if (!QString(PROGRAM_NAME).compare("shelXle")){ |
| 13030 |
tabifyDockWidget(shxEditorDock,splitDoc); |
| 13031 |
//printf("%s %d\n",PROGRAM_NAME,QString(PROGRAM_NAME).compare("shelXle")); |
| 13032 |
} |
| 13033 |
else { |
| 13034 |
splitDoc->setFloating(true); |
| 13035 |
//printf("%s %d %d\n",PROGRAM_NAME,splitDoc->isFloating(),splitDoc->isVisible()); |
| 13036 |
} |
| 13037 |
splitDoc->show(); |
| 13038 |
splitDoc->raise(); |
| 13039 |
connect(splitDoc,SIGNAL(visibilityChanged(bool)),this,SLOT(closeSR(bool))); |
| 13040 |
if (chgl->canSplitRotate()) {chgl->updateBondActions(); chgl->splitRotate();} |
| 13041 |
} else { |
| 13042 |
chgl->pivot1cb->clear(); |
| 13043 |
chgl->pivot2cb->clear(); |
| 13044 |
for (int i=0; i<mole.asymm.size();i++){ |
| 13045 |
chgl->pivot1cb->insertItem(i,mole.asymm.at(i).Label); |
| 13046 |
chgl->pivot2cb->insertItem(i,mole.asymm.at(i).Label); |
| 13047 |
} |
| 13048 |
splitDoc->show(); |
| 13049 |
splitDoc->raise(); |
| 13050 |
} |
| 13051 |
//addDockWidget(dockWidgetArea(shxEditorDock),splitDoc); |
| 13052 |
// */ |
| 13053 |
} |
| 13054 |
|
| 13055 |
|
| 13056 |
void Window::split(){ |
| 13057 |
//printf("Spalter!\n"); |
| 13058 |
//* |
| 13059 |
QDockWidget *splitDoc = findChild<QDockWidget*>("splitRotate"); |
| 13060 |
|
| 13061 |
|
| 13062 |
if (sr_alter_name->isChecked()){ |
| 13063 |
QStringList alab; |
| 13064 |
QString alters("'\",#"); |
| 13065 |
for (int i = 0; i < mole.asymm.size(); i++){ |
| 13066 |
alab.append(mole.asymm.at(i).Label.section('_',0,0)); |
| 13067 |
} |
| 13068 |
for (int i = 0; i<mole.splitRightAtoms.size(); i++){ |
| 13069 |
QString nlab = mole.splitRightAtoms.at(i).Label.section('_',0,0); |
| 13070 |
if (nlab.size()>3) nlab=nlab.left(3); |
| 13071 |
int j = 0; |
| 13072 |
while (alab.contains(nlab+alters.at(j))) j++; |
| 13073 |
mole.splitRightAtoms[i].Label = nlab+alters.at(j); |
| 13074 |
} |
| 13075 |
} |
| 13076 |
QString constrain(""); |
| 13077 |
if (sr_ExyzAadp_ifclose->isChecked()){ |
| 13078 |
for (int i = 0; i < mole.splitLeftAtoms.size(); i++){ |
| 13079 |
for (int j = i; j < mole.splitRightAtoms.size(); j++){ |
| 13080 |
double d = Distance(mole.splitLeftAtoms.at(i).pos, mole.splitRightAtoms.at(j).pos);// this the squred length |
| 13081 |
if (d<0.015) { |
| 13082 |
if (sr_alter_name->isChecked()) |
| 13083 |
constrain.append(QString("%1 %2 ") |
| 13084 |
.arg(mole.splitLeftAtoms.at(i).Label.section('_',0,0)) |
| 13085 |
.arg(mole.splitRightAtoms.at(j).Label.section('_',0,0))); |
| 13086 |
else |
| 13087 |
constrain.append(QString("%1^%3 %2^%4 ") |
| 13088 |
.arg(mole.splitLeftAtoms.at(i).Label.section('_',0,0)) |
| 13089 |
.arg(mole.splitRightAtoms.at(j).Label.section('_',0,0)) |
| 13090 |
.arg(lpart->value()+9,0,36)//base36 |
| 13091 |
.arg(rpart->value()+9,0,36)//base36 |
| 13092 |
); |
| 13093 |
} |
| 13094 |
} |
| 13095 |
} |
| 13096 |
} |
| 13097 |
QTextDocument *document = editor->document(); |
| 13098 |
QTextCursor cursor = editor->textCursor(); |
| 13099 |
cursor.beginEditBlock (); |
| 13100 |
// !!!Neue Freie Variable anlegen!!! |
| 13101 |
cursor.movePosition(QTextCursor::End); |
| 13102 |
cursor = document->find(QRegularExpression("^FVAR"),cursor,QTextDocument::FindBackward); |
| 13103 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 13104 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 13105 |
while (cursor.selectedText().endsWith("=")) { |
| 13106 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 13107 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 13108 |
} |
| 13109 |
QString fvstr = cursor.selectedText().trimmed(); |
| 13110 |
fvstr.append(" 0.666 "); |
| 13111 |
fvar.append(0.667); |
| 13112 |
cursor.deleteChar(); |
| 13113 |
cursor.insertText(fvstr); |
| 13114 |
updateTieFreeVar(); |
| 13115 |
int fnj=fmax(fvar.size(),2); |
| 13116 |
int hatafix=0; |
| 13117 |
for (int i=0; i<mole.splitLeftAtoms.size(); i++){ |
| 13118 |
hatafix=fmax(hatafix,mole.splitLeftAtoms[i].afix); |
| 13119 |
//the two parts should not differ on this featrure so it is enough to look for it in one branch |
| 13120 |
} |
| 13121 |
if (hatafix==0){// if there is a afix instrution then keep the order of atoms at it is. |
| 13122 |
editor->sortAtoms( mole.splitLeftAtoms); |
| 13123 |
editor->sortAtoms( mole.splitRightAtoms); |
| 13124 |
} |
| 13125 |
cursor.movePosition(QTextCursor::End); |
| 13126 |
cursor = document->find(QRegularExpression("^HKLF"),cursor,QTextDocument::FindBackward); |
| 13127 |
//cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); |
| 13128 |
//printf("LINE %d %d %d\n",__LINE__,mole.splitLeftAtoms.size(),mole.splitRightAtoms.size()); |
| 13129 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::KeepAnchor); |
| 13130 |
cursor.clearSelection(); |
| 13131 |
QString stri; |
| 13132 |
QString rigustr=QString("RIGU%1 ").arg((mole.splitLeftAtoms.first().resiNr!=0)?QString("_%1").arg(mole.splitLeftAtoms.first().resiNr):""); |
| 13133 |
for (int i=0; i<mole.splitRightAtoms.size(); i++){ |
| 13134 |
rigustr.append(QString("%1 ").arg(mole.splitRightAtoms[i].Label.section('_',0,0))); |
| 13135 |
} |
| 13136 |
if (sr_alter_name->isChecked()) { |
| 13137 |
for (int i=0; i<mole.splitLeftAtoms.size(); i++){ |
| 13138 |
rigustr.append(QString("%1 ").arg(mole.splitLeftAtoms[i].Label.section('_',0,0))); |
| 13139 |
} |
| 13140 |
} |
| 13141 |
rigustr.append('\n'); |
| 13142 |
rigustr=DSRGui::textWrap(rigustr); |
| 13143 |
|
| 13144 |
|
| 13145 |
QString simustr=QString("SIMU%1 0.01 0.08 0.25 ").arg((mole.splitLeftAtoms.first().resiNr!=0)?QString("_%1").arg(mole.splitLeftAtoms.first().resiNr):""); |
| 13146 |
for (int i=0; i<mole.splitRightAtoms.size(); i++){ |
| 13147 |
simustr.append(QString("%1 ").arg(mole.splitRightAtoms[i].Label.section('_',0,0))); |
| 13148 |
} |
| 13149 |
if (sr_alter_name->isChecked()) { |
| 13150 |
for (int i=0; i<mole.splitLeftAtoms.size(); i++){ |
| 13151 |
simustr.append(QString("%1 ").arg(mole.splitLeftAtoms[i].Label.section('_',0,0))); |
| 13152 |
} |
| 13153 |
} |
| 13154 |
simustr.append('\n'); |
| 13155 |
simustr=DSRGui::textWrap(simustr); |
| 13156 |
simustr.append("\n"); |
| 13157 |
rigustr.append("\n"); |
| 13158 |
QString equalstring(""); |
| 13159 |
if (!constrain.isEmpty()){ |
| 13160 |
equalstring.append(DSRGui::textWrap(QString("EXYZ %1").arg(constrain))); |
| 13161 |
equalstring.append("\n"); |
| 13162 |
equalstring.append(DSRGui::textWrap(QString("EADP %1").arg(constrain))); |
| 13163 |
equalstring.append("\n"); |
| 13164 |
} |
| 13165 |
stri.append(QString("AFIX 0! Make sure that AFIX instructions before this line are closed.\n%3%1%2") |
| 13166 |
.arg((sr_rigu->isChecked())?rigustr:"") |
| 13167 |
.arg((sr_simu->isChecked())?simustr:"") |
| 13168 |
.arg(equalstring)); |
| 13169 |
int aaf=0; |
| 13170 |
if (mole.splitLeftAtoms.first().resiNr!=0) |
| 13171 |
stri.append(QString("RESI %1 %2\n").arg(mole.splitLeftAtoms.first().resiNr).arg(mole.splitLeftAtoms.first().ResiClass)); |
| 13172 |
stri.append(QString("PART %1\n").arg(lpart->value())); |
| 13173 |
//printf("LINE %d\n",__LINE__); |
| 13174 |
for (int i=0; i<mole.splitLeftAtoms.size(); i++){ |
| 13175 |
//printf("i=%d\n",i); |
| 13176 |
mole.splitLeftAtoms[i].isIso=true; |
| 13177 |
double uEQ=mole.ueq(mole.splitLeftAtoms.at(i).uf); |
| 13178 |
mole.splitLeftAtoms[i].uf.m11= |
| 13179 |
mole.splitLeftAtoms[i].uf.m22= |
| 13180 |
mole.splitLeftAtoms[i].uf.m33= |
| 13181 |
mole.splitLeftAtoms[i].uc.m11= |
| 13182 |
mole.splitLeftAtoms[i].uc.m22= |
| 13183 |
mole.splitLeftAtoms[i].uc.m33=uEQ; |
| 13184 |
mole.splitLeftAtoms[i].isIso=true; |
| 13185 |
mole.splitLeftAtoms[i].uf.m12 = mole.splitLeftAtoms[i].uf.m21 = uEQ * mole.cell.cosrg; |
| 13186 |
mole.splitLeftAtoms[i].uf.m13 = mole.splitLeftAtoms[i].uf.m31 = uEQ * mole.cell.cosrb; |
| 13187 |
mole.splitLeftAtoms[i].uf.m23 = mole.splitLeftAtoms[i].uf.m32 = uEQ * mole.cell.cosra; |
| 13188 |
mole.splitLeftAtoms[i].uc.m21= |
| 13189 |
mole.splitLeftAtoms[i].uc.m12= |
| 13190 |
mole.splitLeftAtoms[i].uc.m13= |
| 13191 |
mole.splitLeftAtoms[i].uc.m31= |
| 13192 |
mole.splitLeftAtoms[i].uc.m32= |
| 13193 |
mole.splitLeftAtoms[i].uc.m23=0.0; |
| 13194 |
mole.splitLeftAtoms[i].part=lpart->value(); |
| 13195 |
mole.kart2frac(mole.splitLeftAtoms.at(i).pos,mole.splitLeftAtoms[i].frac); |
| 13196 |
|
| 13197 |
QString nsof=QString(" %1").arg(-1*(fabs(fmod(mole.splitLeftAtoms[i].sof_org,10))+(10*fnj)),7,'f',5); |
| 13198 |
mole.splitLeftAtoms[i].orginalLine= QString("%5 %1 %2 %3 %4 %6 %7\n") |
| 13199 |
.arg(editor->sfac.indexOf(mole.splitLeftAtoms[i].an)+1) |
| 13200 |
.arg(mole.splitLeftAtoms[i].frac.x,10,'f',6) |
| 13201 |
.arg(mole.splitLeftAtoms[i].frac.y,10,'f',6) |
| 13202 |
.arg(mole.splitLeftAtoms[i].frac.z,10,'f',6) |
| 13203 |
.arg(mole.splitLeftAtoms[i].Label.section('_',0,0),-5) |
| 13204 |
.arg(nsof).arg(uEQ); |
| 13205 |
stri.append(QString("%1%2").arg((aaf!=mole.splitLeftAtoms[i].afix)?QString("AFIX %1\n").arg(mole.splitLeftAtoms[i].afix):"") |
| 13206 |
.arg(mole.splitLeftAtoms[i].orginalLine)); |
| 13207 |
aaf=mole.splitLeftAtoms[i].afix; |
| 13208 |
mole.asymm.append(mole.splitLeftAtoms[i]); |
| 13209 |
//printf("ok?\n"); |
| 13210 |
} |
| 13211 |
if (aaf) stri.append("AFIX 0\n"); |
| 13212 |
aaf=0; |
| 13213 |
QString same=QString("SAME%1 ").arg((mole.splitLeftAtoms.first().resiNr!=0)?QString("_%1").arg(mole.splitLeftAtoms.first().resiNr):""); |
| 13214 |
for (int i=0; i<mole.splitLeftAtoms.size(); i++){ |
| 13215 |
same.append(QString("%1 ").arg(mole.splitLeftAtoms[i].Label.section('_',0,0))); |
| 13216 |
} |
| 13217 |
same.append('\n'); |
| 13218 |
if (sr_same->isChecked()) stri.append(DSRGui::textWrap(same)); |
| 13219 |
|
| 13220 |
stri.append(QString("PART %1\n").arg(rpart->value())); |
| 13221 |
for (int i=0; i<mole.splitRightAtoms.size(); i++){ |
| 13222 |
mole.splitRightAtoms[i].isIso=true; |
| 13223 |
double uEQ=mole.ueq(mole.splitRightAtoms.at(i).uf); |
| 13224 |
mole.splitRightAtoms[i].uf.m11= |
| 13225 |
mole.splitRightAtoms[i].uf.m22= |
| 13226 |
mole.splitRightAtoms[i].uf.m33= |
| 13227 |
mole.splitRightAtoms[i].uc.m11= |
| 13228 |
mole.splitRightAtoms[i].uc.m22= |
| 13229 |
mole.splitRightAtoms[i].uc.m33=uEQ; |
| 13230 |
mole.splitRightAtoms[i].isIso=true; |
| 13231 |
mole.splitRightAtoms[i].uf.m12 = mole.splitRightAtoms[i].uf.m21 = uEQ * mole.cell.cosrg; |
| 13232 |
mole.splitRightAtoms[i].uf.m13 = mole.splitRightAtoms[i].uf.m31 = uEQ * mole.cell.cosrb; |
| 13233 |
mole.splitRightAtoms[i].uf.m23 = mole.splitRightAtoms[i].uf.m32 = uEQ * mole.cell.cosra; |
| 13234 |
mole.splitRightAtoms[i].uc.m21= |
| 13235 |
mole.splitRightAtoms[i].uc.m12= |
| 13236 |
mole.splitRightAtoms[i].uc.m13= |
| 13237 |
mole.splitRightAtoms[i].uc.m31= |
| 13238 |
mole.splitRightAtoms[i].uc.m32= |
| 13239 |
mole.splitRightAtoms[i].uc.m23=0.0; |
| 13240 |
mole.splitRightAtoms[i].part=rpart->value(); |
| 13241 |
QString nsof=QString(" %1").arg(1*(fabs(fmod(mole.splitRightAtoms[i].sof_org,10))+(10*fnj)),7,'f',5); |
| 13242 |
mole.kart2frac(mole.splitRightAtoms.at(i).pos,mole.splitRightAtoms[i].frac); |
| 13243 |
mole.splitRightAtoms[i].orginalLine= QString("%5 %1 %2 %3 %4 %6 %7\n") |
| 13244 |
.arg(editor->sfac.indexOf(mole.splitRightAtoms[i].an)+1) |
| 13245 |
.arg(mole.splitRightAtoms[i].frac.x,10,'f',6) |
| 13246 |
.arg(mole.splitRightAtoms[i].frac.y,10,'f',6) |
| 13247 |
.arg(mole.splitRightAtoms[i].frac.z,10,'f',6) |
| 13248 |
.arg(mole.splitRightAtoms[i].Label.section('_',0,0),-5) |
| 13249 |
.arg(nsof).arg(uEQ); |
| 13250 |
stri.append(QString("%1%2").arg((aaf!=mole.splitRightAtoms[i].afix)?QString("AFIX %1").arg(mole.splitRightAtoms[i].afix):"") |
| 13251 |
.arg(mole.splitRightAtoms[i].orginalLine)); |
| 13252 |
|
| 13253 |
aaf=mole.splitRightAtoms[i].afix; |
| 13254 |
|
| 13255 |
//printf("%s !right\n",mole.splitRightAtoms[i].orginalLine.toStdString().c_str()); |
| 13256 |
mole.asymm.append(mole.splitRightAtoms[i]); |
| 13257 |
|
| 13258 |
} |
| 13259 |
if (aaf) stri.append("AFIX 0\n"); |
| 13260 |
//printf("!!\n%s!!",stri.toStdString().c_str()); |
| 13261 |
cursor.insertText(stri); |
| 13262 |
|
| 13263 |
//printf("xx@\n"); |
| 13264 |
deleteSelectedAtoms();//remove existing full occupied atoms |
| 13265 |
cursor.endEditBlock (); |
| 13266 |
splitDoc->hide();// will deselect atoms |
| 13267 |
shxEditorDock->raise(); |
| 13268 |
chgl->highlightParts->setVisible(true); |
| 13269 |
chgl->highlightParts->setChecked(true); |
| 13270 |
//*/ |
| 13271 |
} |
| 13272 |
|
| 13273 |
void Window::notsplit(){ |
| 13274 |
//* |
| 13275 |
QDockWidget *splitDoc = findChild<QDockWidget*>("splitRotate"); |
| 13276 |
splitDoc->hide(); |
| 13277 |
chgl->mol->selectedatoms.clear(); |
| 13278 |
chgl->updateBondActions(); |
| 13279 |
chgl->update(); |
| 13280 |
shxEditorDock->raise(); |
| 13281 |
// */ |
| 13282 |
} |
| 13283 |
|
| 13284 |
void Window::styleDialog(){ |
| 13285 |
EacDlg *eac = new EacDlg(chgl->mol); |
| 13286 |
double mi=mole.pmin; |
| 13287 |
double ma=mole.pmax; |
| 13288 |
eac->exec(); |
| 13289 |
mole.pmin=mi; |
| 13290 |
mole.pmax=ma; |
| 13291 |
chgl->shortLabels->setChecked(eac->areLabelsShort()); |
| 13292 |
lodsp->setValue(chgl->mol->LOD); |
| 13293 |
chgl->myFont=eac->ogl->myFont; |
| 13294 |
chgl->makeLabels(); |
| 13295 |
//chgl->setupTexture(); |
| 13296 |
|
| 13297 |
einstellung->beginGroup("Colors"); |
| 13298 |
chgl->backGroundColor=einstellung->value("BackGroundColor",QColor("lightskyblue")).value<QColor>(); |
| 13299 |
chgl->labelColor=einstellung->value("LabelColor").value<QColor>(); |
| 13300 |
chgl->labelBGColor = einstellung->value("LabelBGColor", QColor(0,0,0,0)).value<QColor>(); |
| 13301 |
chgl->focusedLabelBGColor = einstellung->value("focusedLabelBGColor", QColor(0,0,0,10)).value<QColor>(); |
| 13302 |
chgl->focusedLabelColor = einstellung->value("focusedLabelColor", QColor(255,255,0,255)).value<QColor>(); |
| 13303 |
chgl->selectedLabelBGColor = einstellung->value("selectedLabelBGColor", QColor(0,0,0,51)).value<QColor>(); |
| 13304 |
chgl->selectedLabelColor = einstellung->value("selectedLabelColor", QColor(135, 206, 235 ,255)).value<QColor>(); |
| 13305 |
einstellung->endGroup(); |
| 13306 |
mole.showbonds = mole.connecting(mole.showatoms);//das ist notwendig weil es in eac ebenfalls aufgerufen wird und dort lbonds ueberschreibt. |
| 13307 |
|
| 13308 |
loadMolInTest(); |
| 13309 |
//chgl->setFocus(Qt::OtherFocusReason); |
| 13310 |
chgl->show(); |
| 13311 |
chgl->raise(); |
| 13312 |
chgl->update(); |
| 13313 |
delete eac; |
| 13314 |
} |
| 13315 |
|
| 13316 |
void Window::effuenf(){ |
| 13317 |
|
| 13318 |
//chgl->setFocus(Qt::OtherFocusReason); |
| 13319 |
chgl->show(); |
| 13320 |
chgl->raise(); |
| 13321 |
chgl->update(); |
| 13322 |
} |
| 13323 |
|
| 13324 |
void Window::selectInStructure(const QString &info){ |
| 13325 |
chgl->mol->selectedatoms.clear(); |
| 13326 |
for (int i=0; i<chgl->mol->showatoms.size(); i++){ |
| 13327 |
if (chgl->mol->showatoms.at(i).orginalLine.size()<30) continue; |
| 13328 |
if (info.contains(chgl->mol->showatoms.at(i).orginalLine,Qt::CaseInsensitive)){ |
| 13329 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[i]); |
| 13330 |
chgl->mol->selectedatoms.last().style=i; |
| 13331 |
} |
| 13332 |
} |
| 13333 |
chgl->updateBondActions(); |
| 13334 |
chgl->update(); |
| 13335 |
update(); |
| 13336 |
chgl->update(); |
| 13337 |
} |
| 13338 |
|
| 13339 |
void Window::findInStructure(const QString &info){ |
| 13340 |
int index=-1; |
| 13341 |
for (int i=0; i<chgl->mol->showatoms.size(); i++){ |
| 13342 |
if (chgl->mol->showatoms.at(i).orginalLine.contains(info,Qt::CaseInsensitive)) {index=i;break;} |
| 13343 |
if (info.contains(chgl->mol->showatoms.at(i).orginalLine,Qt::CaseInsensitive)) {index=i;break;} |
| 13344 |
} |
| 13345 |
if (index!=-1){ |
| 13346 |
chgl->rotze=index; |
| 13347 |
chgl->rCenter->show(); |
| 13348 |
chgl->mol->selectedatoms.clear(); |
| 13349 |
chgl->mol->selectedatoms.append(chgl->mol->showatoms[index]); |
| 13350 |
chgl->mol->selectedatoms.last().style=index; |
| 13351 |
chgl->updateBondActions(); |
| 13352 |
chgl->makeSelectedAtoms(); |
| 13353 |
chgl->update(); |
| 13354 |
update(); |
| 13355 |
chgl->update(); |
| 13356 |
} |
| 13357 |
} |
| 13358 |
|
| 13359 |
void Window::openIncludeFile(const QString &info){ |
| 13360 |
QString dn=dirName.section('/',0,-2); |
| 13361 |
IncludeEditor *ie = new IncludeEditor(info,dn,this); |
| 13362 |
ie->exec(); |
| 13363 |
} |
| 13364 |
|
| 13365 |
void Window::jumpToAtom(int index){ |
| 13366 |
if ((chgl->inRenameMode)&&(enterRenameMode->isChecked())) { |
| 13367 |
renameThisAtom(index); |
| 13368 |
return; |
| 13369 |
} |
| 13370 |
if (chgl->inRenameMode) { |
| 13371 |
printf("%d\n",__LINE__); |
| 13372 |
renamUpdate(false); |
| 13373 |
} |
| 13374 |
QString label = mole.showatoms.at(index).orginalLine.left(80).trimmed(); |
| 13375 |
// qDebug()<<index<<mole.showatoms.at(index).Label<<label; |
| 13376 |
QTextDocument *document = editor->document(); |
| 13377 |
QTextCursor cursor = editor->textCursor(); |
| 13378 |
cursor.movePosition(QTextCursor::Start); |
| 13379 |
cursor = document->find(label,cursor); |
| 13380 |
if (cursor.isNull()){ |
| 13381 |
cursor = editor->textCursor(); |
| 13382 |
cursor.movePosition(QTextCursor::Start); |
| 13383 |
label.chop(10); |
| 13384 |
cursor = document->find(label,cursor); |
| 13385 |
if (cursor.isNull()) cursor = editor->textCursor(); |
| 13386 |
cursor.movePosition(QTextCursor::Start); |
| 13387 |
label = mole.showatoms.at(index).orginalLine.left(80).simplified(); |
| 13388 |
cursor = document->find(label,cursor); |
| 13389 |
if (cursor.isNull()) cursor = editor->textCursor(); |
| 13390 |
} |
| 13391 |
cursor.movePosition(QTextCursor::StartOfLine); |
| 13392 |
editor->setTextCursor(cursor); |
| 13393 |
editor->doSetTextCursor(cursor,false); |
| 13394 |
editor->centerCursor(); |
| 13395 |
cursor.clearSelection(); |
| 13396 |
editor->setTextCursor(cursor); |
| 13397 |
editor->setFocus(); |
| 13398 |
//printf("W===========Jump 2 Atom!\n"); |
| 13399 |
if (chgl->toggleDockWidgets->isChecked()) return; |
| 13400 |
shxEditorDock->show(); |
| 13401 |
} |
| 13402 |
|
| 13403 |
void Window::rufmode(){ |
| 13404 |
|
| 13405 |
einstellung->beginGroup("Labeling"); |
| 13406 |
einstellung->setValue("AutoUnused",rufModeBox->isChecked()); |
| 13407 |
einstellung->endGroup(); |
| 13408 |
bool inuse=isLabelInUse(); |
| 13409 |
if ((inuse)&&(rufModeBox->isChecked())&&((labelIndex==-1)||(indexIncr->isChecked()))){ |
| 13410 |
if (sufixBox->currentIndex()<0) sufixBox->setCurrentIndex(0); |
| 13411 |
while (isLabelInUse()){ |
| 13412 |
// qDebug()<<"zz"<<labelIndex; |
| 13413 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13414 |
updateLabel(); |
| 13415 |
} |
| 13416 |
inuse=isLabelInUse(); |
| 13417 |
}else |
| 13418 |
if ((rufModeBox->isChecked())){ |
| 13419 |
if (nowaste) labelIndex=1; |
| 13420 |
while (isLabelInUse()) { |
| 13421 |
labelIndex++; |
| 13422 |
if (labelIndex>999) { |
| 13423 |
labelIndex=00; |
| 13424 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13425 |
updateLabel(); |
| 13426 |
} |
| 13427 |
} |
| 13428 |
inuse=isLabelInUse(); |
| 13429 |
indexSpin->setValue(labelIndex); |
| 13430 |
} |
| 13431 |
updateLabel(); |
| 13432 |
} |
| 13433 |
|
| 13434 |
|
| 13435 |
void Window::changeElemetofLabel(const QString &pse){ |
| 13436 |
labelPSE=pse; |
| 13437 |
bool inuse=isLabelInUse(); |
| 13438 |
if ((inuse)&&(rufModeBox->isChecked())&&((labelIndex==-1)||(indexIncr->isChecked()))){ |
| 13439 |
if (sufixBox->currentIndex()<0) sufixBox->setCurrentIndex(0); |
| 13440 |
while (isLabelInUse()){ |
| 13441 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13442 |
updateLabel(); |
| 13443 |
} |
| 13444 |
inuse=isLabelInUse(); |
| 13445 |
}else |
| 13446 |
if ((rufModeBox->isChecked())){ |
| 13447 |
if (!nextLabel.contains("any"))labelIndex=1; |
| 13448 |
while (isLabelInUse()) { |
| 13449 |
labelIndex++; |
| 13450 |
if (labelIndex>999) { |
| 13451 |
labelIndex=00; |
| 13452 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13453 |
updateLabel(); |
| 13454 |
} |
| 13455 |
} |
| 13456 |
inuse=isLabelInUse(); |
| 13457 |
indexSpin->setValue(labelIndex); |
| 13458 |
} |
| 13459 |
if ((nextLabel.contains("any"))){ |
| 13460 |
QString altLabel=""; |
| 13461 |
for (int i=1; i<109; i++){ |
| 13462 |
if (pserbt[i]->isVisible()) { |
| 13463 |
if (labelIndex<0) altLabel+=QString("%1%2").arg(pserbt[i]->text()).arg(labelSuffix); |
| 13464 |
else altLabel+=QString("%1%2%3").arg(pserbt[i]->text()).arg(labelIndex).arg(labelSuffix); |
| 13465 |
altLabel.append(", "); |
| 13466 |
} |
| 13467 |
} |
| 13468 |
altLabel.remove(commaspace); |
| 13469 |
int lakoma = altLabel.lastIndexOf(", "); |
| 13470 |
if (lakoma>1) altLabel.replace(lakoma,2," or "); |
| 13471 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>") |
| 13472 |
.arg(altLabel) |
| 13473 |
.arg("blue")); |
| 13474 |
} else { |
| 13475 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>%3") |
| 13476 |
.arg(nextLabel) |
| 13477 |
.arg((inuse)?"red":"green") |
| 13478 |
.arg((inuse)?"<font size=\"-19\"><br>Label is already in use. You may change ResidueNr or Part.</font>":"")); |
| 13479 |
} |
| 13480 |
update(); |
| 13481 |
} |
| 13482 |
|
| 13483 |
void Window::changeIndexofLabel(int i){ |
| 13484 |
labelIndex=i; |
| 13485 |
bool inuse=isLabelInUse(); |
| 13486 |
if ((inuse)&&(rufModeBox->isChecked())&&((labelIndex==-1)||(indexIncr->isChecked()))){ |
| 13487 |
if (sufixBox->currentIndex()<0) sufixBox->setCurrentIndex(0); |
| 13488 |
while (isLabelInUse()){ |
| 13489 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13490 |
updateLabel(); |
| 13491 |
} |
| 13492 |
inuse=isLabelInUse(); |
| 13493 |
}else |
| 13494 |
if ((rufModeBox->isChecked())){ |
| 13495 |
if (!nextLabel.contains("any"))labelIndex=1; |
| 13496 |
while (isLabelInUse()) { |
| 13497 |
labelIndex++; |
| 13498 |
if (labelIndex>999) { |
| 13499 |
labelIndex=00; |
| 13500 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13501 |
updateLabel(); |
| 13502 |
} |
| 13503 |
} |
| 13504 |
inuse=isLabelInUse(); |
| 13505 |
indexSpin->setValue(labelIndex); |
| 13506 |
} |
| 13507 |
|
| 13508 |
|
| 13509 |
if ((nextLabel.contains("any"))){ |
| 13510 |
QString altLabel=""; |
| 13511 |
for (int i=1; i<109; i++){ |
| 13512 |
if (pserbt[i]->isVisible()) { |
| 13513 |
if (labelIndex<0) altLabel+=QString("%1%2").arg(pserbt[i]->text()).arg(labelSuffix); |
| 13514 |
else altLabel+=QString("%1%2%3").arg(pserbt[i]->text()).arg(labelIndex).arg(labelSuffix); |
| 13515 |
altLabel.append(", "); |
| 13516 |
} |
| 13517 |
} |
| 13518 |
altLabel.remove(commaspace); |
| 13519 |
int lakoma = altLabel.lastIndexOf(", "); |
| 13520 |
if (lakoma>1) altLabel.replace(lakoma,2," or "); |
| 13521 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>") |
| 13522 |
.arg(altLabel) |
| 13523 |
.arg("blue")); |
| 13524 |
} else { |
| 13525 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>%3") |
| 13526 |
.arg(nextLabel) |
| 13527 |
.arg((inuse)?"red":"green") |
| 13528 |
.arg((inuse)?"<font size=\"-19\"><br>Label is already in use. You may change ResidueNr or Part.</font>":"")); |
| 13529 |
} |
| 13530 |
update(); |
| 13531 |
} |
| 13532 |
|
| 13533 |
void Window::changeSuffixofLabel(int i){ |
| 13534 |
QString fix = labelSuffix=sufixBox->itemText(i); |
| 13535 |
bool inuse = isLabelInUse(); |
| 13536 |
if ((inuse)&&(rufModeBox->isChecked())&&((labelIndex==-1)||(indexIncr->isChecked()))){ |
| 13537 |
if (sufixBox->currentIndex()<0) sufixBox->setCurrentIndex(0); |
| 13538 |
while (isLabelInUse()){ |
| 13539 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13540 |
updateLabel(); |
| 13541 |
} |
| 13542 |
inuse=isLabelInUse(); |
| 13543 |
}else if((inuse)&&(rufModeBox->isChecked())&&(labelIndex!=-1)){ |
| 13544 |
updateLabel(); |
| 13545 |
inuse=isLabelInUse(); |
| 13546 |
} |
| 13547 |
if ((nextLabel.contains("any"))){ |
| 13548 |
QString altLabel=""; |
| 13549 |
for (int i=1; i<109; i++){ |
| 13550 |
if (pserbt[i]->isVisible()) { |
| 13551 |
if (labelIndex<0) altLabel+=QString("%1%2").arg(pserbt[i]->text()).arg(labelSuffix); |
| 13552 |
else altLabel+=QString("%1%2%3").arg(pserbt[i]->text()).arg(labelIndex).arg(labelSuffix); |
| 13553 |
altLabel.append(", "); |
| 13554 |
} |
| 13555 |
} |
| 13556 |
altLabel.remove(commaspace); |
| 13557 |
int lakoma = altLabel.lastIndexOf(", "); |
| 13558 |
if (lakoma>1) altLabel.replace(lakoma,2," or "); |
| 13559 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>") |
| 13560 |
.arg(altLabel) |
| 13561 |
.arg("blue")); |
| 13562 |
} else { |
| 13563 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>%3") |
| 13564 |
.arg(nextLabel) |
| 13565 |
.arg((inuse)?"red":"green") |
| 13566 |
.arg((inuse)?"<font size=\"-19\"><br>Label is already in use. You may change ResidueNr or Part.</font>":"")); |
| 13567 |
} |
| 13568 |
update(); |
| 13569 |
} |
| 13570 |
|
| 13571 |
void Window::updateLabel(){ |
| 13572 |
indexSpin->setValue(labelIndex); |
| 13573 |
// if ((rufModeBox->isChecked())&&(!nextLabel.contains("any"))) labelIndex=1; |
| 13574 |
bool inuse=isLabelInUse(); |
| 13575 |
if ((inuse)&&(rufModeBox->isChecked())){ |
| 13576 |
while (isLabelInUse()) { |
| 13577 |
labelIndex++; |
| 13578 |
if (labelIndex>999) { |
| 13579 |
labelIndex=00; |
| 13580 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 13581 |
updateLabel(); |
| 13582 |
} |
| 13583 |
} |
| 13584 |
inuse=isLabelInUse(); |
| 13585 |
indexSpin->setValue(labelIndex); |
| 13586 |
} |
| 13587 |
if ((nextLabel.contains("any"))){ |
| 13588 |
QString altLabel=""; |
| 13589 |
for (int i=1; i<109; i++){ |
| 13590 |
if (pserbt[i]->isVisible()) { |
| 13591 |
if (labelIndex<0) altLabel+=QString("%1%2").arg(pserbt[i]->text()).arg(labelSuffix); |
| 13592 |
else altLabel+=QString("%1%2%3").arg(pserbt[i]->text()).arg(labelIndex).arg(labelSuffix); |
| 13593 |
altLabel.append(", "); |
| 13594 |
} |
| 13595 |
} |
| 13596 |
altLabel.remove(commaspace); |
| 13597 |
int lakoma = altLabel.lastIndexOf(", "); |
| 13598 |
if (lakoma>1) altLabel.replace(lakoma,2," or "); |
| 13599 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>") |
| 13600 |
.arg(altLabel) |
| 13601 |
.arg("blue")); |
| 13602 |
} else { |
| 13603 |
nextNameL->setText(QString("Next Label is:<br> <font size=\"+1\" color=\"%2\">%1</font>%3") |
| 13604 |
.arg(nextLabel) |
| 13605 |
.arg((inuse)?"red":"green") |
| 13606 |
.arg((inuse)?"<font size=\"-19\"><br>Label is already in use. You may change ResidueNr or Part.</font>":"")); |
| 13607 |
|
| 13608 |
} |
| 13609 |
//bool x=false; |
| 13610 |
|
| 13611 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 13612 |
if (mole.asymm.at(i).Label!=mole.showatoms.at(i).Label){ |
| 13613 |
//printf("!!%s %s\n",mole.asymm.at(i).Label.toStdString().c_str(),mole.showatoms.at(i).Label.toStdString().c_str()); |
| 13614 |
mole.showatoms[i].Label=mole.asymm.at(i).Label; |
| 13615 |
// x=true; |
| 13616 |
} |
| 13617 |
} |
| 13618 |
/* if (x){ |
| 13619 |
chgl->updateLabelTextures(); |
| 13620 |
//printf("update!!1elf\n"); |
| 13621 |
}*/ |
| 13622 |
update(); |
| 13623 |
|
| 13624 |
|
| 13625 |
} |
| 13626 |
|
| 13627 |
int Window::duplicates(){ |
| 13628 |
int was=0; |
| 13629 |
mole.duplicateAtoms.clear(); |
| 13630 |
if (search4duplicates->isChecked()){ |
| 13631 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 13632 |
if (mole.asymm.at(i).an<0) continue;//Q peaks don't have to be uniq! |
| 13633 |
for (int j =i+1; j<mole.asymm.size(); j++){ |
| 13634 |
if (mole.asymm.at(j).an<0) continue;//Q peaks don't have to be uniq! |
| 13635 |
if ((mole.asymm.at(i).part==mole.asymm.at(j).part)&& |
| 13636 |
(mole.asymm.at(i).resiNr==mole.asymm.at(j).resiNr)&& |
| 13637 |
(mole.asymm.at(i).Label==mole.asymm.at(j).Label)){ |
| 13638 |
/* printf("i%d j %d p%d=%d rn%d=%d %s\n",i,j, |
| 13639 |
mole.asymm.at(i).part,mole.asymm.at(j).part, |
| 13640 |
mole.asymm.at(i).resiNr,mole.asymm.at(j).resiNr, |
| 13641 |
mole.asymm.at(j).Label.toStdString().c_str()); |
| 13642 |
*/ mole.duplicateAtoms.append(mole.asymm.at(i)); |
| 13643 |
mole.duplicateAtoms.last().part=666; |
| 13644 |
mole.duplicateAtoms.last().style=i; |
| 13645 |
mole.duplicateAtoms.append(mole.asymm.at(j)); |
| 13646 |
mole.duplicateAtoms.last().part=666; |
| 13647 |
mole.duplicateAtoms.last().style=j; |
| 13648 |
was|=(mole.asymm.at(i).an==0)?1:2; |
| 13649 |
|
| 13650 |
} |
| 13651 |
} |
| 13652 |
} |
| 13653 |
} |
| 13654 |
|
| 13655 |
editor->highlighter->highlightDupl(mole.duplicateAtoms); |
| 13656 |
chgl->makeSelectedAtoms(); |
| 13657 |
chgl->update(); |
| 13658 |
return was; |
| 13659 |
} |
| 13660 |
|
| 13661 |
bool Window::isLabelInUse(){ |
| 13662 |
QStringList alab; |
| 13663 |
for (int i =0; i<mole.asymm.size(); i++){ |
| 13664 |
alab.append(mole.asymm.at(i).Label); |
| 13665 |
} |
| 13666 |
QString nn; |
| 13667 |
//wenn rufMode dann labelIndex auf 1 setzen und hochzaehlen bis (alab.contains(nn,Qt::CaseInsensitive)) false |
| 13668 |
// sollte (labelIndex<0) sein dann suffix auf A und hochzaehlen |
| 13669 |
if (labelIndex<0) nextLabel=QString("%1%2").arg(labelPSE).arg(labelSuffix); |
| 13670 |
else nextLabel=QString("%1%2%3").arg(labelPSE).arg(labelIndex).arg(labelSuffix); |
| 13671 |
if (!nextLabel.startsWith("any")) nextLabel=nextLabel.left(4); |
| 13672 |
if ((partSpin->value()!=0)||(resiNrSpin->value()!=0)){ |
| 13673 |
nn=QString("%1_%3%4") |
| 13674 |
.arg(nextLabel) |
| 13675 |
.arg((resiNrSpin->value())?QString::number(resiNrSpin->value()):"") |
| 13676 |
.arg((partSpin->value())?QString::number((partSpin->value()<0)? |
| 13677 |
36+partSpin->value(): |
| 13678 |
partSpin->value()+9,36):""); |
| 13679 |
|
| 13680 |
}else |
| 13681 |
nn=nextLabel; |
| 13682 |
return (alab.contains(nn,Qt::CaseInsensitive)); |
| 13683 |
} |
| 13684 |
|
| 13685 |
void Window::renameThisAtom(){ |
| 13686 |
//printf("renameThisAtom() (cast version)\n"); |
| 13687 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 13688 |
int index=0; |
| 13689 |
if (action) |
| 13690 |
index=action->data().toInt(); |
| 13691 |
else return; |
| 13692 |
if (index>mole.asymm.size()) return; |
| 13693 |
if (mole.asymm.at(index).Label.contains(numbers)) { |
| 13694 |
int p=mole.asymm.at(index).an; |
| 13695 |
labelPSE=mole.pse(p); |
| 13696 |
|
| 13697 |
labelIndex=mole.asymm.at(index).Label.section(nonumbers,0,0,QString::SectionSkipEmpty).toInt(); |
| 13698 |
labelSuffix=mole.asymm.at(index).Label.section(numbers,1,1); |
| 13699 |
labelSuffix.remove(vorneweg); |
| 13700 |
} |
| 13701 |
else{ |
| 13702 |
int p=mole.asymm.at(index).an; |
| 13703 |
labelPSE=mole.pse(p); |
| 13704 |
labelIndex=-1; |
| 13705 |
labelSuffix=mole.asymm.at(index).Label; |
| 13706 |
labelSuffix.remove(0,labelPSE.size()); |
| 13707 |
labelSuffix.remove(vorneweg); |
| 13708 |
} |
| 13709 |
|
| 13710 |
partSpin->setValue(mole.asymm.at(index).part); |
| 13711 |
resiNrSpin->setValue(mole.asymm.at(index).resiNr); |
| 13712 |
resiResiClass->setText(mole.asymm.at(index).ResiClass); |
| 13713 |
pserbt[mole.asymm.at(index).an+1]->setChecked(true); |
| 13714 |
|
| 13715 |
printf("%d\n",__LINE__); |
| 13716 |
renamUpdate(true); |
| 13717 |
updateLabel(); |
| 13718 |
|
| 13719 |
} |
| 13720 |
|
| 13721 |
void Window::rename2ThisAtom(int index){ |
| 13722 |
//printf("rename2ThisAtom\n"); |
| 13723 |
if (index>mole.asymm.size()) return; |
| 13724 |
int p=mole.asymm.at(index).an; |
| 13725 |
bool rmo= rufModeBox->isChecked(), iix=indexIncr->isChecked(); |
| 13726 |
rufModeBox->setChecked(false); |
| 13727 |
sufixBox->setCurrentIndex(0); |
| 13728 |
labelPSE=mole.pse(p); |
| 13729 |
//sufixBox->setCurrentIndex(1); |
| 13730 |
if (mole.asymm.at(index).Label.contains(numbers)) { |
| 13731 |
labelIndex=mole.asymm.at(index).Label.section(nonumbers,0,0,QString::SectionSkipEmpty).toInt(); |
| 13732 |
labelSuffix=mole.asymm.at(index).Label.section(numbers,1,1); |
| 13733 |
labelSuffix.remove(vorneweg); |
| 13734 |
} |
| 13735 |
else{ |
| 13736 |
labelIndex=-1; |
| 13737 |
labelSuffix=mole.asymm.at(index).Label; |
| 13738 |
labelSuffix.remove(0,labelPSE.size()); |
| 13739 |
labelSuffix.remove(vorneweg); |
| 13740 |
} |
| 13741 |
labelPSE="H"; |
| 13742 |
partSpin->setValue(mole.asymm.at(index).part); |
| 13743 |
resiNrSpin->setValue(mole.asymm.at(index).resiNr); |
| 13744 |
resiResiClass->setText(mole.asymm.at(index).ResiClass); |
| 13745 |
pserbt[1]->setChecked(true);//H |
| 13746 |
updateLabel(); |
| 13747 |
indexIncr->setChecked(true); |
| 13748 |
rufModeBox->setChecked(true); |
| 13749 |
printf("%d\n",__LINE__); |
| 13750 |
renamUpdate(false); |
| 13751 |
updateLabel(); |
| 13752 |
rufModeBox->setChecked(rmo); |
| 13753 |
indexIncr->setChecked(iix); |
| 13754 |
} |
| 13755 |
|
| 13756 |
|
| 13757 |
void Window::renameRNchanged(int ii){ |
| 13758 |
QMap<int,QString> resNrClass; |
| 13759 |
for (int i=0; i<editor->resiFinder->count(); i++){ |
| 13760 |
QString resil=editor->resiFinder->itemText(i).toUpper(); |
| 13761 |
resil.remove(QRegularExpression("^RESI"));//remove resi at the beginning resi could be also a (STUPID) resi class |
| 13762 |
QString resinr=resil; |
| 13763 |
resil.remove(QRegularExpression("\\b\\d+\\b"));//remove the number which separated (e.g. not like CCF3) |
| 13764 |
resinr.remove(resil.trimmed());//the rest should be the number |
| 13765 |
int rn=resinr.trimmed().toInt(); |
| 13766 |
resNrClass[rn]=resil.trimmed(); |
| 13767 |
} |
| 13768 |
|
| 13769 |
if ((rufModeBox->isChecked())&&(!nextLabel.contains("any"))) labelIndex=1; |
| 13770 |
if (!ii) { |
| 13771 |
resiResiClass->setEnabled(false); |
| 13772 |
resiResiClass->setText(""); |
| 13773 |
resiResiClassCB->setEnabled(false); |
| 13774 |
} |
| 13775 |
else { |
| 13776 |
resiResiClassCB->setEnabled(!resNrClass.contains(ii)); |
| 13777 |
resiResiClass->setDisabled(resNrClass.contains(ii)); |
| 13778 |
resiResiClass->setText(resNrClass[ii]); |
| 13779 |
} |
| 13780 |
updateLabel(); |
| 13781 |
|
| 13782 |
} |
| 13783 |
|
| 13784 |
|
| 13785 |
void Window::incResiNr(){ |
| 13786 |
int rnmax=-1; |
| 13787 |
for (int i=0; i<editor->resiFinder->count(); i++){ |
| 13788 |
QString resil=editor->resiFinder->itemText(i).toUpper(); |
| 13789 |
resil.remove(QRegularExpression("^RESI"));//remove resi at the beginning resi could be also a (STUPID) resi class |
| 13790 |
QString resinr=resil; |
| 13791 |
resil.remove(QRegularExpression("\\b\\d+\\b"));//remove the number which separated (e.g. not like CCF3) |
| 13792 |
resinr.remove(resil.trimmed());//the rest should be the number |
| 13793 |
int rn=resinr.trimmed().toInt(); |
| 13794 |
rnmax=(rn>rnmax)?rn:rnmax; |
| 13795 |
} |
| 13796 |
int rnr = resiNrSpin->value()+1; |
| 13797 |
rnr = (rnr>rnmax+1)?rnmax+1:rnr; |
| 13798 |
resiNrSpin->setValue(rnr); |
| 13799 |
updateLabel(); |
| 13800 |
|
| 13801 |
} |
| 13802 |
|
| 13803 |
void Window::decResiNr(){ |
| 13804 |
int rnr = resiNrSpin->value()-1; |
| 13805 |
rnr = (rnr<0)? 0: rnr; |
| 13806 |
resiNrSpin->setValue(rnr); |
| 13807 |
updateLabel(); |
| 13808 |
|
| 13809 |
} |
| 13810 |
|
| 13811 |
void Window::redoRename(){ |
| 13812 |
if (gehtMichAn2.size()&&(0!=gehtMichAn2.takeLast())){//redoDeleteAtoms |
| 13813 |
deletedAtom.clear(); |
| 13814 |
for (int i=0; i<restoredAtom.size();i++)deletedAtom.append(restoredAtom.at(i)); |
| 13815 |
for (int i=0; i<restoredAtom.size();i++){ |
| 13816 |
mole.asymm.removeAt(mole.asymm.indexOf(restoredAtom.at(i))); |
| 13817 |
} |
| 13818 |
restoredAtom.clear(); |
| 13819 |
chgl->disSelection(); |
| 13820 |
if (chgl->fuse->isVisible())chgl->mol->grow(); |
| 13821 |
else chgl->mol->fuse(); |
| 13822 |
loadMolInTest(true); |
| 13823 |
|
| 13824 |
switch (duplicates()){ |
| 13825 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 13826 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13827 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13828 |
} |
| 13829 |
|
| 13830 |
chgl->update(); |
| 13831 |
gehtMichAn.takeLast(); |
| 13832 |
return; |
| 13833 |
} |
| 13834 |
if (gehtMichAn.size()&&(0==gehtMichAn.takeLast()))return; |
| 13835 |
MyAtom renamed; |
| 13836 |
int renamindex; |
| 13837 |
if (redoAtom.isEmpty()) return; |
| 13838 |
renamindex = redoAtomIndex.takeLast(); |
| 13839 |
if (renamindex==-1){ |
| 13840 |
do { |
| 13841 |
renamed = redoAtom.takeLast(); |
| 13842 |
undoAtom.append(renamed); |
| 13843 |
mole.asymm.append(renamed); |
| 13844 |
undoAtomIndex.append(renamindex); |
| 13845 |
} while ((redoAtomIndex.size())&&(-1==(renamindex = redoAtomIndex.takeLast()))); |
| 13846 |
}else { |
| 13847 |
|
| 13848 |
renamed = redoAtom.takeLast(); |
| 13849 |
undoAtom.append(mole.asymm[renamindex]); |
| 13850 |
undoAtomIndex.append(renamindex); |
| 13851 |
|
| 13852 |
mole.asymm[renamindex]=renamed; |
| 13853 |
} |
| 13854 |
updateLabel(); |
| 13855 |
chgl->disSelection(); |
| 13856 |
if (chgl->fuse->isVisible())chgl->mol->grow(); |
| 13857 |
else chgl->mol->fuse(); |
| 13858 |
loadMolInTest(true); |
| 13859 |
|
| 13860 |
switch (duplicates()){ |
| 13861 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 13862 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13863 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13864 |
} |
| 13865 |
chgl->update(); |
| 13866 |
} |
| 13867 |
|
| 13868 |
void Window::wasDelete(){ |
| 13869 |
static int changeDel=0; |
| 13870 |
if (changeDel!=(deletedAtom.size()+restoredAtom.size())) gehtMichAn2.append(1); |
| 13871 |
else gehtMichAn2.append(0); |
| 13872 |
changeDel=deletedAtom.size()+restoredAtom.size(); |
| 13873 |
} |
| 13874 |
|
| 13875 |
void Window::wasRename(){ |
| 13876 |
if (altursize!=(redoAtom.size()+undoAtom.size()))gehtMichAn.append(1); |
| 13877 |
else gehtMichAn.append(0); |
| 13878 |
altursize=(redoAtom.size()+undoAtom.size()); |
| 13879 |
} |
| 13880 |
|
| 13881 |
void Window::undoRename(){ |
| 13882 |
int angang=0; |
| 13883 |
if (gehtMichAn2.size()&&(0!=(angang=gehtMichAn2.takeLast()))){//undoDeleteAtoms |
| 13884 |
restoredAtom.clear(); |
| 13885 |
for (int i=0; i<deletedAtom.size();i++)restoredAtom.append(deletedAtom.at(i)); |
| 13886 |
for (int i=0; i<deletedAtom.size();i++){ |
| 13887 |
mole.asymm.append(deletedAtom.at(i)); |
| 13888 |
} |
| 13889 |
deletedAtom.clear(); |
| 13890 |
chgl->disSelection(); |
| 13891 |
if (chgl->fuse->isVisible())chgl->mol->grow(); |
| 13892 |
else chgl->mol->fuse(); |
| 13893 |
loadMolInTest(true); |
| 13894 |
|
| 13895 |
switch (duplicates()){ |
| 13896 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 13897 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13898 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13899 |
} |
| 13900 |
chgl->update(); |
| 13901 |
gehtMichAn.takeLast(); |
| 13902 |
gehtMichAn2.append(1); |
| 13903 |
return; |
| 13904 |
} |
| 13905 |
angang=0; |
| 13906 |
if (gehtMichAn.size()&&(0==(angang=gehtMichAn.takeLast()))){ |
| 13907 |
return; |
| 13908 |
} |
| 13909 |
if (angang>1){ |
| 13910 |
|
| 13911 |
for (int i = 2; i<angang; i++ ){ |
| 13912 |
redoAtom.append(mole.asymm.takeLast()); |
| 13913 |
redoAtomIndex.append(-1); |
| 13914 |
|
| 13915 |
} |
| 13916 |
|
| 13917 |
updateLabel(); |
| 13918 |
chgl->disSelection(); |
| 13919 |
if (chgl->fuse->isVisible())chgl->mol->grow(); |
| 13920 |
else chgl->mol->fuse(); |
| 13921 |
loadMolInTest(true); |
| 13922 |
|
| 13923 |
switch (duplicates()){ |
| 13924 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 13925 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13926 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13927 |
} |
| 13928 |
chgl->update(); |
| 13929 |
|
| 13930 |
return; |
| 13931 |
} |
| 13932 |
MyAtom renamed; |
| 13933 |
int renamindex; |
| 13934 |
if (undoAtom.isEmpty()) return; |
| 13935 |
renamed = undoAtom.takeLast(); |
| 13936 |
renamindex = undoAtomIndex.takeLast(); |
| 13937 |
if (renamindex<0)redoAtom.append(renamed); |
| 13938 |
else redoAtom.append(mole.asymm[renamindex]); |
| 13939 |
redoAtomIndex.append(renamindex); |
| 13940 |
|
| 13941 |
mole.asymm[renamindex]=renamed; |
| 13942 |
updateLabel(); |
| 13943 |
chgl->disSelection(); |
| 13944 |
if (chgl->fuse->isVisible())chgl->mol->grow(); |
| 13945 |
else chgl->mol->fuse(); |
| 13946 |
loadMolInTest(true); |
| 13947 |
|
| 13948 |
switch (duplicates()){ |
| 13949 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 13950 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13951 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 13952 |
} |
| 13953 |
chgl->update(); |
| 13954 |
} |
| 13955 |
|
| 13956 |
|
| 13957 |
void Window::renameThisAtom(int index){ |
| 13958 |
printf("renameThisAtom(index) \n"); |
| 13959 |
// QTime rzeit; |
| 13960 |
// rzeit.start(); |
| 13961 |
// printf("renameThisAtom\n"); |
| 13962 |
if ((index<0)||index>=mole.asymm.size()){ |
| 13963 |
if ((index>=0)&&(mole.showatoms.at(index).Label.startsWith('Q'))){ |
| 13964 |
MyAtom ato(mole.showatoms.at(index)); |
| 13965 |
ato.Label=ato.Label.remove("'"); |
| 13966 |
ato.symmGroup=0; |
| 13967 |
ato.sg=0; |
| 13968 |
ato.scod=555;//the identity |
| 13969 |
ato.auidx=index; |
| 13970 |
|
| 13971 |
int nindex=mole.asymm.indexOf(ato); |
| 13972 |
if (nindex!=-1 ){ |
| 13973 |
// mole.asymm.append(mole.asymm[nindex]); |
| 13974 |
mole.asymm[nindex].frac=mole.showatoms.at(index).frac; |
| 13975 |
mole.asymm[nindex].pos=mole.showatoms.at(index).pos; |
| 13976 |
double uEQ=0.05;//mole.ueq(mole.asymm.at(i).uf); |
| 13977 |
mole.asymm[nindex].uf.m11= mole.asymm[nindex].uc.m11= mole.asymm[nindex].uc.m22= mole.asymm[nindex].uc.m33=uEQ; |
| 13978 |
mole.asymm[nindex].isIso=true; |
| 13979 |
mole.asymm[nindex].uf.m33=uEQ; |
| 13980 |
mole.asymm[nindex].uf.m12= mole.asymm[nindex].uf.m21= mole.asymm[nindex].uf.m13= mole.asymm[nindex].uf.m31= |
| 13981 |
mole.asymm[nindex].uf.m23= mole.asymm[nindex].uf.m32= mole.asymm[nindex].uc.m21= mole.asymm[nindex].uc.m12= |
| 13982 |
mole.asymm[nindex].uc.m13= mole.asymm[nindex].uc.m31= mole.asymm[nindex].uc.m32= mole.asymm[nindex].uc.m23=0.0; |
| 13983 |
index=nindex; |
| 13984 |
}else return; |
| 13985 |
} |
| 13986 |
else{ |
| 13987 |
QMessageBox::information(0,"information","The Atom you have clicked is not present in the file (yet) and can't be renamed by this program!<br>You can try 'move ... here' in the context menu of this atom. "); |
| 13988 |
return; |
| 13989 |
} |
| 13990 |
} |
| 13991 |
|
| 13992 |
// printf("PAUSE!\n"); |
| 13993 |
bool warnicht=false; |
| 13994 |
static int previousHorse=-1; |
| 13995 |
static int previousJokey=-1; |
| 13996 |
CEnvironment respar; |
| 13997 |
QString insertSuchString; |
| 13998 |
for (int i=0; i<mole.asymm.size();i++){ |
| 13999 |
if (mole.asymm.at(i).resiNr!=resiNrSpin->value()) continue; |
| 14000 |
if (mole.asymm.at(i).part!=partSpin->value()) continue; |
| 14001 |
if (i!=index) respar.append(mole.asymm[i]); |
| 14002 |
} |
| 14003 |
|
| 14004 |
MyAtom testat=mole.asymm[index]; |
| 14005 |
testat.Label=nextLabel; |
| 14006 |
testat.Label.replace("any",mole.pse((mole.asymm.at(index).an)<0?1:mole.asymm.at(index).an)); |
| 14007 |
testat.Label=testat.Label.left(4); |
| 14008 |
testat.ResiClass = resiResiClass->text(); |
| 14009 |
testat.resiNr=resiNrSpin->value(); |
| 14010 |
testat.part=partSpin->value(); |
| 14011 |
// printf("testatom\n"); |
| 14012 |
testat.an=mole.getOZ(labelPSE); |
| 14013 |
if (testat.an<0) { |
| 14014 |
testat.an=5; |
| 14015 |
} |
| 14016 |
//respar.append(testat); |
| 14017 |
// printf("AN: %d\n", testat.an); |
| 14018 |
insertSuchString = editor->sortLabelList(respar,testat); |
| 14019 |
|
| 14020 |
respar.clear(); |
| 14021 |
|
| 14022 |
|
| 14023 |
QString nlab = nextLabel ; |
| 14024 |
//b= nlab.contains("any"); |
| 14025 |
//QString nsn = nlab.replace("any",mole.pse(mole.asymm.at(index).an)); |
| 14026 |
bool ridingH = false; |
| 14027 |
|
| 14028 |
if (insertSuchString.startsWith('Q')) insertSuchString="HKLF"; |
| 14029 |
//printf("seek to: %s\n",insertSuchString.toStdString().c_str()); |
| 14030 |
if ((mole.getOZ(labelPSE)==0)&&(mole.asymm.at(index).an==-1)){ |
| 14031 |
int dahin2=-1; |
| 14032 |
//double dd=0.0; |
| 14033 |
for (int isd=0; isd<mole.sdm.size(); isd++){//sdm is sorted in that way that the smalest |
| 14034 |
if (mole.sdm.at(isd).d>1.3) continue; |
| 14035 |
if ((mole.sdm.at(isd).a1==index)&&(mole.asymm.at(mole.sdm.at(isd).a2).an>0)) { |
| 14036 |
// dd=mole.sdm.at(isd).d; |
| 14037 |
dahin2=mole.sdm.at(isd).a2; |
| 14038 |
break; |
| 14039 |
} //qDebug()<<isd<<'a'<<mole.asymm.at(mole.sdm.at(isd).a2).Label<<mole.sdm.at(isd).d; |
| 14040 |
if ((mole.sdm.at(isd).a2==index)&&(mole.asymm.at(mole.sdm.at(isd).a1).an>0)) { |
| 14041 |
// dd=mole.sdm.at(isd).d; |
| 14042 |
dahin2=mole.sdm.at(isd).a1; |
| 14043 |
break; |
| 14044 |
} //qDebug()<<isd<<'b'<<mole.asymm.at(mole.sdm.at(isd).a1).Label<<mole.sdm.at(isd).d; |
| 14045 |
} |
| 14046 |
//qDebug()<<insertSuchString<<dahin2<<index<<dd<<mole.asymm.at(dahin2).orginalLine.left(80).trimmed();;a |
| 14047 |
if (dahin2==-1)insertSuchString="HKLF"; |
| 14048 |
else{ |
| 14049 |
if (!enterRenameMode->isChecked()) { |
| 14050 |
nowaste=false; |
| 14051 |
rename2ThisAtom(dahin2); |
| 14052 |
nowaste=true; |
| 14053 |
} |
| 14054 |
ridingH=true; |
| 14055 |
//int orderer=0; |
| 14056 |
if (previousHorse==dahin2){ |
| 14057 |
insertSuchString=mole.asymm.at(previousJokey).orginalLine.left(80).trimmed(); |
| 14058 |
//printf("second or later H here %d %d\n",previousJokey,dahin2); |
| 14059 |
}else{ |
| 14060 |
insertSuchString=mole.asymm.at(dahin2).orginalLine.left(80).trimmed(); |
| 14061 |
} |
| 14062 |
previousHorse=dahin2; |
| 14063 |
previousJokey=index; |
| 14064 |
// insertSuchString=mole.asymm.at(dahin2).orginalLine.left(80).trimmed(); |
| 14065 |
} |
| 14066 |
|
| 14067 |
} |
| 14068 |
//qDebug()<<"suche nach: "<<insertSuchString; |
| 14069 |
QString label = mole.showatoms.at(index).orginalLine.left(80).trimmed(); |
| 14070 |
// printf("2 => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14071 |
QTextDocument *document = editor->document(); |
| 14072 |
QTextCursor cursor = editor->textCursor(); |
| 14073 |
cursor.beginEditBlock (); |
| 14074 |
//insert missing afix 0 at end |
| 14075 |
cursor.movePosition(QTextCursor::Start); |
| 14076 |
cursor = document->find("HKLF",cursor); |
| 14077 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 14078 |
cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); |
| 14079 |
if (editor->parenthesis.at(cursor.blockNumber())){ |
| 14080 |
cursor.select(QTextCursor::WordUnderCursor); |
| 14081 |
if ((cursor.selectedText().contains("RESI",Qt::CaseInsensitive))||(cursor.selectedText().contains("PART",Qt::CaseInsensitive))) |
| 14082 |
cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); |
| 14083 |
cursor.select(QTextCursor::WordUnderCursor); |
| 14084 |
if ((cursor.selectedText().contains("RESI",Qt::CaseInsensitive))||(cursor.selectedText().contains("PART",Qt::CaseInsensitive))) |
| 14085 |
cursor.movePosition(QTextCursor::Up,QTextCursor::KeepAnchor); |
| 14086 |
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); |
| 14087 |
cursor.clearSelection(); |
| 14088 |
cursor.insertText("AFIX 0 ! chuebsch want to keep this here!!\nREM #####\n"); |
| 14089 |
editor->updateAfix(); |
| 14090 |
} |
| 14091 |
//insert missing afix 0 at End! |
| 14092 |
|
| 14093 |
cursor.movePosition(QTextCursor::Start); |
| 14094 |
cursor = document->find(label,cursor); |
| 14095 |
//printf("find{%s}\n",label.toStdString().c_str()); |
| 14096 |
if (cursor.isNull()){ |
| 14097 |
cursor = editor->textCursor(); |
| 14098 |
cursor.movePosition(QTextCursor::Start); |
| 14099 |
label.chop(10); |
| 14100 |
//printf("2find{%s}\n",label.toStdString().c_str()); |
| 14101 |
cursor = document->find(label,cursor); |
| 14102 |
if (cursor.isNull()) { |
| 14103 |
cursor = editor->textCursor(); |
| 14104 |
warnicht=true; |
| 14105 |
printf("oje!\n"); |
| 14106 |
} |
| 14107 |
} |
| 14108 |
if (editor->parenthesis.at(cursor.blockNumber())){ |
| 14109 |
QMessageBox::information(0,"information",QString("ATOM %1 is in a AFIX construct and can't be renamed by this program!").arg(label.section(' ',0,0))); |
| 14110 |
cursor.endEditBlock (); |
| 14111 |
editor->setTextCursor(cursor); |
| 14112 |
// printf("qpeakbug? %d\n",__LINE__); |
| 14113 |
|
| 14114 |
// printf("%d\n",__LINE__); |
| 14115 |
return; |
| 14116 |
} |
| 14117 |
if (warnicht) { |
| 14118 |
QMessageBox::information(0,"information","The Atom you have clicked is not present in the file (yet) and can't be renamed by this program!"); |
| 14119 |
cursor.endEditBlock (); |
| 14120 |
editor->setTextCursor(cursor); |
| 14121 |
|
| 14122 |
// printf("%d\n",__LINE__); |
| 14123 |
return;//hier muss eingefuegt werden: verhalten bei objecten die noch nicht in der datei stehen |
| 14124 |
} |
| 14125 |
QString vorherig,neues; |
| 14126 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 14127 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14128 |
QString otxt= cursor.selectedText(); |
| 14129 |
while (cursor.selectedText().endsWith("=")) { |
| 14130 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 14131 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14132 |
} |
| 14133 |
while (editor->parenthesis.at(cursor.blockNumber()+1)){ |
| 14134 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 14135 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14136 |
} |
| 14137 |
neues = vorherig= cursor.selectedText(); |
| 14138 |
//qDebug()<<otxt<<neues; |
| 14139 |
if (tieType->itemData(tieType->currentIndex()).toInt()){ |
| 14140 |
QString asof=neues.section(leer,5,5,QString::SectionSkipEmpty); |
| 14141 |
asof.prepend(" "); |
| 14142 |
int fnj=tieFVNr->value(); |
| 14143 |
QString nsof=(fnj!=1)?QString(" %1").arg(tieType->itemData(tieType->currentIndex()).toInt()*(fabs(fmod(mole.asymm.at(index).sof_org,10))+(10*fnj)),7,'f',5): |
| 14144 |
QString(" %1").arg(fabs(fmod(mole.asymm.at(index).sof_org,10)*tieFix->value()+10),7,'f',5); |
| 14145 |
; |
| 14146 |
// qDebug()<<asof<<nsof; |
| 14147 |
neues.replace(asof,nsof); |
| 14148 |
otxt.replace(asof,nsof); |
| 14149 |
mole.asymm[index].sof_org=nsof.toDouble(); |
| 14150 |
} |
| 14151 |
QString oldSfac=neues.section(leer,1,1,QString::SectionSkipEmpty); |
| 14152 |
int ii=editor->sfacsmbl.indexOf(QRegularExpression(labelPSE,QRegularExpression::CaseInsensitiveOption)); |
| 14153 |
//printf("ii %d\n",ii); |
| 14154 |
QString nl=QString("%1 ").arg(nextLabel,-4,' '); |
| 14155 |
nl=nl.replace("any",mole.pse(editor->sfac.at(oldSfac.toInt()-1))).left(4); |
| 14156 |
if (ii<0) { |
| 14157 |
nl=nl.replace("any",mole.pse(editor->sfac.at(oldSfac.toInt()-1))).left(4); |
| 14158 |
ii=oldSfac.toInt()-1; |
| 14159 |
} |
| 14160 |
else{ |
| 14161 |
neues.replace(QRegularExpression(QString("\\s%1\\s").arg(oldSfac)),QString(" %1 ").arg((ii+1))); |
| 14162 |
otxt.replace(QRegularExpression(QString("\\s%1\\s").arg(oldSfac)),QString(" %1 ").arg((ii+1))); |
| 14163 |
} |
| 14164 |
nl=nl.left(4); |
| 14165 |
neues.replace(0,4,nl); |
| 14166 |
otxt.replace(0,4,nl); |
| 14167 |
// printf("3 => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14168 |
undoAtom.append(mole.asymm[index]); |
| 14169 |
undoAtomIndex.append(index); |
| 14170 |
// printf("3' => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14171 |
QString ol=mole.asymm[index].Label.section('_',0,0); |
| 14172 |
QString oldH=ol; |
| 14173 |
oldH.replace(QRegularExpression(QString("^%1").arg(mole.pse(mole.asymm[index].an)),QRegularExpression::CaseInsensitiveOption),"H"); |
| 14174 |
mole.asymm[index].Label=nextLabel; |
| 14175 |
mole.asymm[index].Label.replace("any",mole.pse(editor->sfac.at(oldSfac.toInt()-1))); |
| 14176 |
mole.asymm[index].Label=mole.asymm[index].Label.left(4); |
| 14177 |
if (mole.asymm[index].an<0) { |
| 14178 |
otxt=neues= |
| 14179 |
QString("%1 %2 %3 %4 %5 %6 %7 \n") |
| 14180 |
.arg(mole.asymm[index].Label,-5) |
| 14181 |
.arg(ii+1) |
| 14182 |
.arg(mole.asymm.at(index).frac.x,9,'f',5) |
| 14183 |
.arg(mole.asymm.at(index).frac.y,9,'f',5) |
| 14184 |
.arg(mole.asymm.at(index).frac.z,9,'f',5) |
| 14185 |
.arg(mole.asymm.at(index).sof_org,9,'f',5) |
| 14186 |
.arg((ridingH)?"-1.5":"0.05"); |
| 14187 |
} |
| 14188 |
mole.asymm[index].an=mole.getOZ(labelPSE); |
| 14189 |
if (mole.asymm[index].an<0) { |
| 14190 |
mole.asymm[index].an=editor->sfac.at(oldSfac.toInt()-1); |
| 14191 |
} |
| 14192 |
QString newH=mole.asymm[index].Label; |
| 14193 |
newH.replace(QRegularExpression(QString("^%1").arg(mole.pse(mole.asymm.at(index).an)),QRegularExpression::CaseInsensitiveOption),"H"); |
| 14194 |
newH=newH.left(3); |
| 14195 |
neues.replace(oldH,newH); |
| 14196 |
|
| 14197 |
//printf("altes H='%s' neues H='%s' %s %s\n",oldH.toStdString().c_str(),newH.toStdString().c_str(),mole.asymm[index].Label.toStdString().c_str(),mole.pse(mole.asymm.at(index).an).toStdString().c_str()); |
| 14198 |
mole.asymm[index].orginalLine=otxt.left(80).section('=',0); |
| 14199 |
// printf(":%s:\n",mole.asymm[index].orginalLine.toStdString().c_str()); |
| 14200 |
// qDebug()<<"aa"<<mole.asymm[index].orginalLine; |
| 14201 |
mole.asymm[index].ResiClass = resiResiClass->text(); |
| 14202 |
mole.asymm[index].resiNr=resiNrSpin->value(); |
| 14203 |
mole.asymm[index].part=partSpin->value(); |
| 14204 |
cursor.deleteChar(); |
| 14205 |
|
| 14206 |
//cursor.deleteChar();//...this seems to cause errors but those emty lines are so ugly! |
| 14207 |
//cursor.insertText(QString(" %1 has been renamed to %2. SHELXL ignores this line.").arg(ol).arg(mole.asymm[index].Label)); |
| 14208 |
QTextCursor wc = cursor; |
| 14209 |
if ((partSpin->value()!=0)||(resiNrSpin->value()!=0)){ |
| 14210 |
mole.asymm[index].Label=QString("%1_%3%4") |
| 14211 |
.arg(nextLabel) |
| 14212 |
.arg((resiNrSpin->value())?QString::number(resiNrSpin->value()):"") |
| 14213 |
.arg((partSpin->value())?QString::number((partSpin->value()<0)? |
| 14214 |
36+partSpin->value(): |
| 14215 |
partSpin->value()+9,36):""); |
| 14216 |
mole.asymm[index].Label.replace("any",mole.pse(editor->sfac.at(oldSfac.toInt()-1))); |
| 14217 |
|
| 14218 |
} |
| 14219 |
cursor = editor->textCursor(); |
| 14220 |
cursor.movePosition(QTextCursor::Start); |
| 14221 |
editor->updateAfix(); |
| 14222 |
cursor = document->find(insertSuchString,cursor); |
| 14223 |
if (cursor.isNull()){ |
| 14224 |
cursor = wc; //alte schreibposition setzen (wir haben atom nicht gefunden weil wir es gerade geloescht haben.... |
| 14225 |
cursor.movePosition(QTextCursor::Down); |
| 14226 |
//printf("%s not found %d\n",insertSuchString.toStdString().c_str(),wc.position()); |
| 14227 |
} |
| 14228 |
else if(insertSuchString!="HKLF"){ |
| 14229 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 14230 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14231 |
while (cursor.selectedText().endsWith("=")) { |
| 14232 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 14233 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14234 |
} |
| 14235 |
while (editor->parenthesis.at(cursor.blockNumber()+1)){ |
| 14236 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 14237 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14238 |
} |
| 14239 |
cursor.movePosition(QTextCursor::Down); //10.09.2020 do i need this really?=>yes |
| 14240 |
//printf("%s found %d\n",insertSuchString.toStdString().c_str(),cursor.position()); |
| 14241 |
} |
| 14242 |
cursor.clearSelection (); |
| 14243 |
cursor.movePosition(QTextCursor::StartOfLine); |
| 14244 |
if ((insertSuchString=="HKLF")&&(mole.asymm[index].resiNr)) cursor.insertText(QString("RESI %1 %2\n") |
| 14245 |
.arg(mole.asymm[index].resiNr) |
| 14246 |
.arg(mole.asymm[index].ResiClass)); |
| 14247 |
if ((insertSuchString=="HKLF")&&(mole.asymm[index].part)) cursor.insertText(QString("PART %1 \n") |
| 14248 |
.arg(mole.asymm[index].part) |
| 14249 |
// .arg((tieType->itemData(tieType->currentIndex()).toInt())? |
| 14250 |
// QString::number((tieType->itemData(tieType->currentIndex()).toInt()*(10*tieFVNr->value()+1))):"") |
| 14251 |
); |
| 14252 |
cursor.insertText(neues); |
| 14253 |
if (!neues.endsWith("\n")) cursor.insertText("\n"); |
| 14254 |
if ((insertSuchString=="HKLF")&&(mole.asymm[index].part)) cursor.insertText("PART 0\n"); |
| 14255 |
if ((insertSuchString=="HKLF")&&(mole.asymm[index].resiNr)) cursor.insertText("RESI 0\n"); |
| 14256 |
if ((tieType->itemData(tieType->currentIndex()).toInt())&&(mole.asymm[index].part)&&(fvar.size()<tieFVNr->value())){ |
| 14257 |
// !!!Neue Freie Variable anlegen!!! |
| 14258 |
cursor.movePosition(QTextCursor::End); |
| 14259 |
cursor = document->find("FVAR",cursor,QTextDocument::FindBackward); |
| 14260 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 14261 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14262 |
while (cursor.selectedText().endsWith("=")) { |
| 14263 |
cursor.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 14264 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14265 |
} |
| 14266 |
QString fvstr = cursor.selectedText().trimmed(); |
| 14267 |
fvstr.append(" 0.666 "); |
| 14268 |
fvar.append(0.667); |
| 14269 |
cursor.deleteChar(); |
| 14270 |
fvstr = DSRGui::textWrap(fvstr, "\nFVAR "); |
| 14271 |
cursor.insertText(fvstr); |
| 14272 |
updateTieFreeVar(); |
| 14273 |
// !!!! |
| 14274 |
} |
| 14275 |
//qDebug()<<"redi"; |
| 14276 |
// printf("3! => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14277 |
|
| 14278 |
|
| 14279 |
|
| 14280 |
cursor.movePosition(QTextCursor::Start); |
| 14281 |
int apo,po=cursor.position(); |
| 14282 |
apo=po; |
| 14283 |
do { |
| 14284 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 14285 |
cursor.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 14286 |
if (cursor.selectedText().isEmpty()) { |
| 14287 |
cursor.deleteChar(); |
| 14288 |
} |
| 14289 |
//cursor.deleteChar(); |
| 14290 |
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); |
| 14291 |
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); |
| 14292 |
apo=po; |
| 14293 |
po=cursor.position(); |
| 14294 |
} |
| 14295 |
while (!cursor.isNull()&&(po!=apo)); |
| 14296 |
|
| 14297 |
// printf("3!a => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14298 |
cursor.endEditBlock (); |
| 14299 |
// printf("3!b => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14300 |
if ((!indexIncr->isChecked())&&(labelIndex!=-1)) labelIndex++; |
| 14301 |
else { |
| 14302 |
if (sufixBox->currentIndex()<0) sufixBox->setCurrentIndex(0); |
| 14303 |
sufixBox->setCurrentIndex((sufixBox->count()>sufixBox->currentIndex()+1)?sufixBox->currentIndex()+1:sufixBox->currentIndex()); |
| 14304 |
} |
| 14305 |
updateLabel(); |
| 14306 |
|
| 14307 |
// printf("3!0 => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14308 |
chgl->disSelection(); |
| 14309 |
chgl->update(); |
| 14310 |
// printf("3!1 => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14311 |
// printf("Qpeak-Crash %d %d\n",__LINE__,mole.showatoms.size()); |
| 14312 |
if (chgl->fuse->isVisible())chgl->mol->grow(); |
| 14313 |
else chgl->mol->fuse(); |
| 14314 |
loadMolInTest(true); |
| 14315 |
// printf("Qpeak-Crash %d %d\n",__LINE__,mole.showatoms.size()); |
| 14316 |
|
| 14317 |
// printf("3!2 => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14318 |
switch (duplicates()){ |
| 14319 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 14320 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 14321 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 14322 |
} |
| 14323 |
|
| 14324 |
editor->setTextCursor(cursor); |
| 14325 |
/* |
| 14326 |
QFile dump("dkcrash.res"); |
| 14327 |
dump.open(QIODevice::WriteOnly|QIODevice::Text); |
| 14328 |
dump.write( editor->toPlainText().toLatin1()); |
| 14329 |
dump.close(); |
| 14330 |
*/ |
| 14331 |
//fileSave(false,true); |
| 14332 |
|
| 14333 |
//chgl->setRotationCenter(index); |
| 14334 |
// printf("4# => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14335 |
|
| 14336 |
|
| 14337 |
|
| 14338 |
//chgl->updateLabelTextures(); |
| 14339 |
// printf("%d\n",__LINE__); |
| 14340 |
|
| 14341 |
// printf("NO PAUSE!\n"); |
| 14342 |
chgl->update(); |
| 14343 |
//printf("NO PAUSE!!\n"); |
| 14344 |
//sdm(); |
| 14345 |
// exportCoordinates(); |
| 14346 |
//printf("Qpeak-Crash %d \n",__LINE__); |
| 14347 |
// printf("5 => %d ms\n", rzeit.elapsed()); rzeit.restart(); |
| 14348 |
} |
| 14349 |
|
| 14350 |
void Window::changeResiPart(){ |
| 14351 |
if (chgl->mol->selectedatoms.isEmpty()) return; |
| 14352 |
|
| 14353 |
CEnvironment todos = chgl->mol->selectedatoms; |
| 14354 |
changeElemetofLabel("any"); |
| 14355 |
pserbt[0]->setChecked(true); |
| 14356 |
int unusedpart=0; |
| 14357 |
for (int i=0; i<mole.asymm.size();i++){ |
| 14358 |
unusedpart=qMax(mole.asymm.at(i).part,unusedpart); |
| 14359 |
} |
| 14360 |
unusedpart++; |
| 14361 |
partSpin->setValue(unusedpart); |
| 14362 |
tieType->setCurrentIndex(1); |
| 14363 |
tieFVNr->setValue(fvar.size()+1); |
| 14364 |
updateTieFreeVar(); |
| 14365 |
QDialog *groupReNaMo= new QDialog(this); |
| 14366 |
groupReNaMo->setLayout(rnla); |
| 14367 |
indexL->hide(); |
| 14368 |
indexSpin->hide(); |
| 14369 |
sufixL->hide(); |
| 14370 |
nextNameL->hide(); |
| 14371 |
sufixBox->hide(); |
| 14372 |
QString text=nliL->text(); |
| 14373 |
nliL->setText("Change RESI or PART of selected atoms.<br><> 0 value leaves current values unchaged."); |
| 14374 |
rufModeBox->hide(); |
| 14375 |
indexIncr->hide(); |
| 14376 |
willpse->hide(); |
| 14377 |
qsa->hide(); |
| 14378 |
connect(buttonBoxRN, SIGNAL(accepted()), groupReNaMo, SLOT(accept())); |
| 14379 |
connect(buttonBoxRN, SIGNAL(rejected()), groupReNaMo, SLOT(reject())); |
| 14380 |
buttonBoxRN->show(); |
| 14381 |
int result=groupReNaMo->exec(); |
| 14382 |
renameBox->setLayout(rnla); |
| 14383 |
nliL->setText(text); |
| 14384 |
indexL->show(); |
| 14385 |
indexSpin->show(); |
| 14386 |
sufixL->show(); |
| 14387 |
sufixBox->show(); |
| 14388 |
nextNameL->show(); |
| 14389 |
rufModeBox->show(); |
| 14390 |
indexIncr->show(); |
| 14391 |
willpse->show(); |
| 14392 |
qsa->show(); |
| 14393 |
buttonBoxRN->hide(); |
| 14394 |
buttonBoxRN->disconnect(); |
| 14395 |
int rn= resiNrSpin->value(); |
| 14396 |
int pn= partSpin->value(); |
| 14397 |
if (result==QDialog::Accepted) |
| 14398 |
for (int i=0; i<todos.size();i++){ |
| 14399 |
if (todos.at(i).symmGroup) continue; |
| 14400 |
if (todos.at(i).Label.contains(QString::fromUtf8("»")))continue; |
| 14401 |
if ((todos.at(i).an<0)) continue; |
| 14402 |
if ((todos.at(i).afix>0)&&(todos.at(i).an==0)) continue; |
| 14403 |
|
| 14404 |
int das=todos.at(i).style; |
| 14405 |
// qDebug()<<"##==>>"<<i<<das<<todos.size()<<mole.asymm.at(das).Label; |
| 14406 |
|
| 14407 |
labelIndex=mole.asymm.at(das).Label.section(nonumbers,0,0,QString::SectionSkipEmpty).toInt(); |
| 14408 |
labelSuffix=mole.asymm.at(das).Label.section(numbers,1,1); |
| 14409 |
labelSuffix.remove(vorneweg); |
| 14410 |
if (pn==0) partSpin->setValue(mole.asymm.at(das).part); |
| 14411 |
if (rn==0){ |
| 14412 |
resiNrSpin->setValue(mole.asymm.at(das).resiNr); |
| 14413 |
resiResiClass->setText(mole.asymm.at(das).ResiClass); |
| 14414 |
} |
| 14415 |
//printf("%d\n",__LINE__); |
| 14416 |
renamUpdate(false); |
| 14417 |
updateLabel(); |
| 14418 |
renameThisAtom(das); |
| 14419 |
} |
| 14420 |
|
| 14421 |
//printf("%d\n",__LINE__); |
| 14422 |
chgl->update(); |
| 14423 |
} |
| 14424 |
|
| 14425 |
bool Window::restraintsOrConstraints(){ |
| 14426 |
bool corr = (editor->toPlainText().contains("AFIX")) ; |
| 14427 |
corr=(corr)||(editor->toPlainText().contains("BIND")) ; |
| 14428 |
corr=(corr)||(editor->toPlainText().contains("CHIV")) ; |
| 14429 |
corr=(corr)||(editor->toPlainText().contains("DANG")) ; |
| 14430 |
corr=(corr)||(editor->toPlainText().contains("DFIX")) ; |
| 14431 |
corr=(corr)||(editor->toPlainText().contains("EADP")) ; |
| 14432 |
corr=(corr)||(editor->toPlainText().contains("EXYZ")) ; |
| 14433 |
corr=(corr)||(editor->toPlainText().contains("FRAG")) ; |
| 14434 |
corr=(corr)||(editor->toPlainText().contains("FEND")) ; |
| 14435 |
corr=(corr)||(editor->toPlainText().contains("FREE")) ; |
| 14436 |
corr=(corr)||(editor->toPlainText().contains("HFIX")) ; |
| 14437 |
corr=(corr)||(editor->toPlainText().contains("MPLA")) ; |
| 14438 |
corr=(corr)||(editor->toPlainText().contains("SADI")) ; |
| 14439 |
corr=(corr)||(editor->toPlainText().contains("SAME")) ; |
| 14440 |
corr=(corr)||(editor->toPlainText().contains("FLAT")) ; |
| 14441 |
if (corr){ |
| 14442 |
QTextCursor cursor = editor->textCursor(); |
| 14443 |
cursor.setPosition(0); |
| 14444 |
editor->setTextCursor(cursor); |
| 14445 |
editor->searchLE->setText("(AFIX)|(BIND)|(CHIV)|(DANG)|(DFIX)|(EADP)|(EXYZ)|(FRAG)|(FEND)|(FREE)|(FLAT)|(HFIX)|(MPLA)|(SADI)|(SAME)"); |
| 14446 |
editor->wholeLine->setChecked(true); |
| 14447 |
editor->findNext(); |
| 14448 |
editor->showSearch(); |
| 14449 |
} |
| 14450 |
return corr; |
| 14451 |
} |
| 14452 |
|
| 14453 |
void Window::aula(){//!< Auto Labeling |
| 14454 |
|
| 14455 |
if (mole.asymm.isEmpty())return; |
| 14456 |
bool hasafix = (editor->toPlainText().contains("AFIX")) ; |
| 14457 |
bool hasrest = restraintsOrConstraints(); |
| 14458 |
bool hash=false; |
| 14459 |
bool useResis; |
| 14460 |
for (int i=0;i<mole.asymm.size();i++){if (mole.asymm.at(i).an==0) {hash=true; break;}} |
| 14461 |
QPushButton *okmitresi=nullptr,*okohneresi=nullptr; |
| 14462 |
QMessageBox mb(QMessageBox::NoIcon, |
| 14463 |
"Automatic Labeling", |
| 14464 |
QString( |
| 14465 |
"<img src=\""+theIconPath+"aula.svg\"><p><h3>AuLa <u>Au</u>tomatic <u>La</u>beling</h3> It will probably never give you satisfying results, but hopefully consitent ones." |
| 14466 |
"<p>Please use this feature before adding Hydrogen atoms and %3restraints or constraints%4." |
| 14467 |
"<p>%1 It will complain about any atom that is in a AFIX environment.%2" |
| 14468 |
"<p>When finished it will sort and save the file automatically. Please be a little patient." |
| 14469 |
"<p>First it searches for rings in each molecule or fragment. Rings may consist only of nonmetals. " |
| 14470 |
"In each molecule it starts numbering in the ring that if most distant away from the molecules center of mass." |
| 14471 |
"If possible, it annulate other rings to the first one. It then adds side chains and the side chains of these until no atoms are left in the molecule." |
| 14472 |
"When there are no rings in the molecule it starts at the end of the chain that is most distant from molecules center of mass. " |
| 14473 |
"Center of mass here means just the geometrical average position. %5") |
| 14474 |
.arg((hasafix)?"<font color=red><b>":"") |
| 14475 |
.arg((hasafix)?"</b></font>":"") |
| 14476 |
.arg((hasrest)?"<font color=red><b>":"") |
| 14477 |
.arg((hasrest)?"</b></font>":"") |
| 14478 |
.arg((hasrest)?"<p><h3><font color=red> Please remove all Hydrogen atoms and constraints/restraints first and come back here later.</font></h3> " |
| 14479 |
"You should not have any of these instructions in your file:<br> <b>AFIX BIND CHIV DANG DFIX EADP EXYZ FLAT FRAG FEND FREE HFIX MPLA SADI SAME</b> " |
| 14480 |
:"<p><h3>Click on one of the AutoLabel buttons below to run the auto labeling procedure now. </h3>") |
| 14481 |
, |
| 14482 |
(QMessageBox::Cancel )); |
| 14483 |
if (hash){ |
| 14484 |
QPushButton *killh = mb.addButton("remove Hydrogen atoms now",QMessageBox::ActionRole); |
| 14485 |
connect(killh,SIGNAL(clicked()),this,SLOT(deleteAllH())); |
| 14486 |
} |
| 14487 |
if (!hasrest){ |
| 14488 |
okmitresi = mb.addButton("AutoLabel with RESIdues",QMessageBox::AcceptRole); |
| 14489 |
okohneresi= mb.addButton("AutoLabel without RESIdues",QMessageBox::AcceptRole); |
| 14490 |
} |
| 14491 |
mb.exec(); |
| 14492 |
bool ok=false; |
| 14493 |
if (mb.clickedButton()==nullptr)return; |
| 14494 |
if (mb.clickedButton()==okmitresi){useResis=true;ok=true;} |
| 14495 |
if (mb.clickedButton()==okohneresi){useResis=false;ok=true;} |
| 14496 |
if (!ok)return; |
| 14497 |
sdm(); |
| 14498 |
AulaWorker *owl = new AulaWorker(this, useResis); |
| 14499 |
connect(owl, SIGNAL(finished()), this, SLOT(sdm())); |
| 14500 |
connect(owl, SIGNAL(finished()), owl, SLOT(finalize())); |
| 14501 |
//connect(owl, SIGNAL(finished()), chgl, SLOT(updateLabelTextures())); |
| 14502 |
connect(owl, SIGNAL(finished()), chgl, SLOT(update())); |
| 14503 |
connect(owl, SIGNAL(message(const QString&)), this, SLOT(updateStatusBar(const QString&))); |
| 14504 |
connect(owl, SIGNAL(message(const QString&)), this, SLOT(update())); |
| 14505 |
connect(owl, SIGNAL(finished()), owl, SLOT(deleteLater())); |
| 14506 |
QWhatsThis::showText(QPoint(pos().x() + width()/2,pos().y() + height()/2),"<H1>Auto Labeling in process please be patient!<br> You can follow progress below in the status bar.</H1>",this); |
| 14507 |
maybeSave2(); |
| 14508 |
sdm(); |
| 14509 |
owl->start(); |
| 14510 |
} |
| 14511 |
|
| 14512 |
void AulaWorker::aula(){ |
| 14513 |
|
| 14514 |
/* |
| 14515 |
printf("TEST\n========Au=La=====================================================================\n"); |
| 14516 |
printf( |
| 14517 |
" .-\"-~-\"-.\n" |
| 14518 |
" /.-\"-.-\"-.\\\n" |
| 14519 |
" ||((o|o))||\n" |
| 14520 |
" )\\__/V\\__/(\n" |
| 14521 |
" / ~ -...- ~ \\\n" |
| 14522 |
" |\\` ~. ~ .~ `/|\n" |
| 14523 |
" | `~ - ^ - ~` |\n" |
| 14524 |
" | ; ' : . |\n" |
| 14525 |
" \\ . : ' ; '/\n" |
| 14526 |
" '. ; ' .'\n" |
| 14527 |
" `uu---uu`\n");*/ |
| 14528 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14529 |
inventNewLabels(chain); |
| 14530 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14531 |
possible=0; |
| 14532 |
for (int i=0; i<_w->mole.asymm.size(); i++) if (_w->mole.asymm.at(i).an>=0) possible++; |
| 14533 |
QFile res(_w->dirName); |
| 14534 |
res.open(QIODevice::ReadOnly|QIODevice::Text); |
| 14535 |
all = QString(res.readAll()); |
| 14536 |
res.close(); |
| 14537 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14538 |
QStringList newlabels; |
| 14539 |
int partmin=0; |
| 14540 |
int partmax=0; |
| 14541 |
for (int i=0; i<chain.size(); i++){ |
| 14542 |
int das = chain.at(i); |
| 14543 |
partmin = qMin(partmin, _w->mole.asymm.at(das).part); |
| 14544 |
partmax = qMax(partmax, _w->mole.asymm.at(das).part); |
| 14545 |
QString old = _w->mole.asymm.at(das).Label; |
| 14546 |
int j=1; |
| 14547 |
int rn=(useResis)?_w->mole.asymm.at(das).molindex:0; |
| 14548 |
QString nl=QString("%1%2_%3").arg(_w->mole.pse(_w->mole.asymm.at(das).an)).arg(j).arg(rn); |
| 14549 |
while (newlabels.contains(nl)) nl=QString("%1%2_%3").arg(_w->mole.pse(_w->mole.asymm.at(das).an)).arg(++j).arg(rn); |
| 14550 |
newlabels.append(nl); |
| 14551 |
if (useResis){ |
| 14552 |
_w->mole.asymm[das].resiNr = rn; |
| 14553 |
_w->mole.asymm[das].ResiClass = QString("M%1").arg(rn); |
| 14554 |
} |
| 14555 |
_w->mole.asymm[das].Label = nl.section('_',0,0); |
| 14556 |
/*printf("%d#%d %s=>%s/%s j=%d an=%d PSE%s\n",i, |
| 14557 |
das, |
| 14558 |
old.toStdString().c_str(), |
| 14559 |
nl.section('_',0,0).toStdString().c_str(), |
| 14560 |
_w->mole.asymm.at(das).Label.toStdString().c_str(), |
| 14561 |
j , _w->mole.asymm.at(das).an, |
| 14562 |
_w->mole.asymm.at(das).orginalLine.toStdString().c_str() |
| 14563 |
);*/ |
| 14564 |
} |
| 14565 |
newlabels.clear(); |
| 14566 |
emit message("New labels created."); |
| 14567 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14568 |
int firstatom = all.indexOf(_w->mole.asymm.at(0).orginalLine); |
| 14569 |
int firstpart = all.indexOf("\nPART",0,Qt::CaseInsensitive); |
| 14570 |
int firstresi = all.indexOf("\nRESI",0,Qt::CaseInsensitive); |
| 14571 |
int vonhier = firstatom; |
| 14572 |
if (firstpart>-1) vonhier = qMin(vonhier,firstpart); |
| 14573 |
if (firstresi>-1) vonhier = qMin(vonhier,firstresi); |
| 14574 |
|
| 14575 |
int bisda =all.lastIndexOf("\nHKLF"); |
| 14576 |
//printf("%d ---- >%d\n", vonhier, bisda); |
| 14577 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14578 |
_w->editor->sortAtoms(_w->mole.asymm); |
| 14579 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14580 |
QString insert = "\n"; |
| 14581 |
int pr=0,pp=0; |
| 14582 |
for (int i=0; i<_w->mole.asymm.size(); i++){ |
| 14583 |
int das = i; |
| 14584 |
int _sfacnr = 1 + _w->editor->sfac.indexOf(_w->mole.asymm.at(das).an); |
| 14585 |
if ((useResis)&&(pr!=_w->mole.asymm.at(das).molindex)) { |
| 14586 |
insert+=QString("RESI %1 M%2\n").arg(_w->mole.asymm.at(das).molindex).arg(_w->mole.asymm.at(das).molindex); |
| 14587 |
pr=_w->mole.asymm.at(das).molindex; |
| 14588 |
} |
| 14589 |
if (((partmin<0)||(partmax>0))&&(pp!=_w->mole.asymm.at(das).part)) { |
| 14590 |
insert+=QString("PART %1\n").arg(_w->mole.asymm.at(das).part); |
| 14591 |
pp=_w->mole.asymm.at(das).part; |
| 14592 |
} |
| 14593 |
if (_w->mole.asymm.at(das).isIso) |
| 14594 |
insert+=QString("%1 %2 %3 %4 %5 %6 %7\n") |
| 14595 |
.arg(_w->mole.asymm.at(das).Label,-4) |
| 14596 |
.arg(_sfacnr) |
| 14597 |
.arg(_w->mole.asymm.at(das).frac.x,10,'f',5) |
| 14598 |
.arg(_w->mole.asymm.at(das).frac.y,10,'f',5) |
| 14599 |
.arg(_w->mole.asymm.at(das).frac.z,10,'f',5) |
| 14600 |
.arg(_w->mole.asymm.at(das).sof_org,10,'f',5) |
| 14601 |
.arg(_w->mole.asymm.at(das).ufiso_org) |
| 14602 |
; |
| 14603 |
else |
| 14604 |
// 0.01902 0.00464 0.01485 -0.00203 |
| 14605 |
insert+=QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12\n") |
| 14606 |
.arg(_w->mole.asymm.at(das).Label,-4) |
| 14607 |
.arg(_sfacnr) |
| 14608 |
.arg(_w->mole.asymm.at(das).frac.x,10,'f',5) |
| 14609 |
.arg(_w->mole.asymm.at(das).frac.y,10,'f',5) |
| 14610 |
.arg(_w->mole.asymm.at(das).frac.z,10,'f',5) |
| 14611 |
.arg(_w->mole.asymm.at(das).sof_org,10,'f',5) |
| 14612 |
.arg(_w->mole.asymm.at(das).uf.m11,10,'f',5) |
| 14613 |
.arg(_w->mole.asymm.at(das).uf.m22,10,'f',5) |
| 14614 |
.arg(_w->mole.asymm.at(das).uf.m33,10,'f',5) |
| 14615 |
.arg(_w->mole.asymm.at(das).uf.m32,10,'f',5) |
| 14616 |
.arg(_w->mole.asymm.at(das).uf.m31,10,'f',5) |
| 14617 |
.arg(_w->mole.asymm.at(das).uf.m21,10,'f',5) |
| 14618 |
; |
| 14619 |
|
| 14620 |
} |
| 14621 |
all.replace(vonhier,bisda-vonhier,insert); |
| 14622 |
emit message("...old labeld atoms replaced with new ones..."); |
| 14623 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14624 |
//printf("%d %d %d\n",vonhier,bisda-vonhier,bisda); |
| 14625 |
//printf("%s\n==================\n%s\n",insert.toStdString().c_str(),all.toStdString().c_str()); |
| 14626 |
|
| 14627 |
} |
| 14628 |
|
| 14629 |
void AulaWorker::extendChain(QList<Ring> &rings,QList<int> ¤tChain, QList<QList<int> > &neighbors,QSet<int> &nogo){ |
| 14630 |
int last=currentChain.last(); |
| 14631 |
for (int ri=0; ri<rings.size();ri++){ |
| 14632 |
if (rings.at(ri).done) continue; |
| 14633 |
if (rings[ri].members.contains(last)){ |
| 14634 |
int bbv=currentChain.size(); |
| 14635 |
int strt=rings[ri].members.indexOf(last); |
| 14636 |
for (int rri=0,rrj=0; rri<rings[ri].members.size(); rri++){ |
| 14637 |
rrj=(strt>=0)?(strt+rri)%rings[ri].members.size():rri; |
| 14638 |
if (!currentChain.contains(rings[ri].members.at(rrj))) currentChain.append(rings[ri].members.at(rrj)); |
| 14639 |
} |
| 14640 |
bbv-=currentChain.size(); |
| 14641 |
if (bbv) { |
| 14642 |
rings[ri].done=true; |
| 14643 |
} |
| 14644 |
} |
| 14645 |
} |
| 14646 |
if (neighbors.at(last).size()==1) return; |
| 14647 |
QList<int> c; |
| 14648 |
int ic=-1; |
| 14649 |
int manb=0; |
| 14650 |
for (int i=0; i<neighbors.at(last).size(); i++){ |
| 14651 |
if (currentChain.contains(neighbors.at(last).at(i))) continue; |
| 14652 |
if (nogo.contains(neighbors.at(last).at(i))) continue; |
| 14653 |
int z=neighbors.at(neighbors.at(last).at(i)).size(); |
| 14654 |
if(z>manb){ |
| 14655 |
manb=z; |
| 14656 |
ic=i; |
| 14657 |
} |
| 14658 |
} |
| 14659 |
if (ic!=-1){ |
| 14660 |
c=currentChain; |
| 14661 |
currentChain.append(neighbors.at(last).at(ic)); |
| 14662 |
extendChain(rings, currentChain, neighbors, nogo); |
| 14663 |
}/*else{ // forking |
| 14664 |
chains.append(c); |
| 14665 |
int lc = chains.size() - 1; |
| 14666 |
chains[lc].append(neighbors.at(last).at(i)); |
| 14667 |
extendChain(chains, chains[lc], neighbors, ng); |
| 14668 |
ic++; |
| 14669 |
ng.unite(chains[lc].toSet()); |
| 14670 |
}// */ |
| 14671 |
c.clear(); |
| 14672 |
} |
| 14673 |
|
| 14674 |
void AulaWorker::inventNewLabels(QList<int> &result){ |
| 14675 |
|
| 14676 |
/* |
| 14677 |
* Idea / draft: |
| 14678 |
* for atoms in a molecule |
| 14679 |
* find chain ends (E) neighbors 1 |
| 14680 |
* find chain atoms (C) neighbors 2 |
| 14681 |
* find nodes (N) neighbors >2 |
| 14682 |
* start at an E and append indexes to a QList chain |
| 14683 |
* when a node N appears copy the list neighbors - 1 times (forking) |
| 14684 |
* when no atoms left then compare number members in each chain |
| 14685 |
* the longest chain wins |
| 14686 |
* the longest part with carbons wins |
| 14687 |
* the E with the greatest distance from center of mass wins |
| 14688 |
* E-C-C-C-N-C-C-N-N-N-C-C-E |
| 14689 |
* | | | | |
| 14690 |
* C-C-C-C E E |
| 14691 |
* |
| 14692 |
* 1-2-3-4-5-g-h-a-b-c-d-e-f |
| 14693 |
* | | | | |
| 14694 |
* 6-7-8-9 i j |
| 14695 |
*/ |
| 14696 |
//return; |
| 14697 |
QList<QList<int> > neighbors; |
| 14698 |
QList<QList<int> > chains; |
| 14699 |
QList<int> emptyChain; |
| 14700 |
QSet<int> nogo; |
| 14701 |
QList<int> molsizes; |
| 14702 |
QList<bool> moleIsDone; |
| 14703 |
QList<double> avan, di2com;// avarage atomic number, distance to center of mass |
| 14704 |
QList<V3> centerOfMass; |
| 14705 |
QList<int>cmax;//maximal chain length |
| 14706 |
for (int i=0; i<_w->mole.asymm.size(); i++){ |
| 14707 |
if (_w->mole.asymm.at(i).an<0 )continue; |
| 14708 |
neighbors.append(emptyChain); |
| 14709 |
if (_w->mole.asymm.at(i).molindex < 0) printf("_w->mole.asymm.at(i).molindex = %d\n",_w->mole.asymm.at(i).molindex); |
| 14710 |
if (_w->mole.asymm.at(i).molindex> molsizes.size()) { |
| 14711 |
molsizes.append(0); |
| 14712 |
cmax.append(0); |
| 14713 |
moleIsDone.append(false); |
| 14714 |
centerOfMass.append(V3(0.0,0.0,0.0)); |
| 14715 |
avan.append(999990.0); |
| 14716 |
di2com.append(0.0); |
| 14717 |
} |
| 14718 |
molsizes[_w->mole.asymm.at(i).molindex-1]++; |
| 14719 |
centerOfMass[_w->mole.asymm.at(i).molindex-1]+=_w->mole.asymm.at(i).pos; |
| 14720 |
} |
| 14721 |
for (int i=0; i<molsizes.size(); i++){ |
| 14722 |
centerOfMass[i]*=1.0/molsizes.at(i); |
| 14723 |
} |
| 14724 |
for (int i=0; i<_w->mole.sdm.size(); i++){ |
| 14725 |
if ((_w->mole.sdm.at(i).a1>=neighbors.size())||(_w->mole.sdm.at(i).a2>=neighbors.size())) continue; |
| 14726 |
if (_w->mole.sdm.at(i).covalent) neighbors[_w->mole.sdm.at(i).a1].append(_w->mole.sdm.at(i).a2); |
| 14727 |
} |
| 14728 |
// find rings first |
| 14729 |
QList<QList<int> > rings; |
| 14730 |
QList<Tripel> tripels; |
| 14731 |
Tripel t;//midcenter |
| 14732 |
QList<Ring> ringe; |
| 14733 |
QSet<int>nonMetals; |
| 14734 |
emit message("find rings..."); |
| 14735 |
//B, C, N, O, F, Si, P, S, Cl, Ge, As, Se, Br, Sb, Te, I |
| 14736 |
nonMetals<<4<<5<<6<<7<<8<<13<<14<<15<<16<<31<<32<<33<<34<<50<<51<<52; |
| 14737 |
for (int i=0; i<neighbors.size();i++){ |
| 14738 |
if (!nonMetals.contains(_w->mole.asymm.at(i).an)) continue; //no rings with metals |
| 14739 |
if (neighbors.at(i).size()>1) |
| 14740 |
for (int j=0; j<neighbors.at(i).size();j++){ |
| 14741 |
for (int k=j+1; k<neighbors.at(i).size();k++){ |
| 14742 |
if (!nonMetals.contains(_w->mole.asymm.at(neighbors.at(i).at(j)).an)) continue; //no rings with metals |
| 14743 |
if (!nonMetals.contains(_w->mole.asymm.at(neighbors.at(i).at(k)).an)) continue; //no rings with metals |
| 14744 |
t.n[0]=i; |
| 14745 |
t.n[1]=neighbors.at(i).at(j); |
| 14746 |
t.n[2]=neighbors.at(i).at(k); |
| 14747 |
double w = _w->mole.winkel(_w->mole.asymm.at(t.n[1]).pos - _w->mole.asymm.at(t.n[0]).pos, |
| 14748 |
_w->mole.asymm.at(t.n[2]).pos - _w->mole.asymm.at(t.n[0]).pos) / 180.0 * M_PI; |
| 14749 |
double scal = sin(w * 0.5) * sin(w * 0.5) / (sin(w) * sin(w)); |
| 14750 |
t.midcenter = _w->mole.asymm.at(t.n[0]).pos + scal * (_w->mole.asymm.at(t.n[1]).pos + |
| 14751 |
_w->mole.asymm.at(t.n[2]).pos -(_w->mole.asymm.at(t.n[0]).pos * 2.0)); |
| 14752 |
tripels.append(t); |
| 14753 |
} |
| 14754 |
} |
| 14755 |
} |
| 14756 |
//printf("atoms%d tripel%d\n",neighbors.size(),tripels.size()); |
| 14757 |
const double RINGTEST=0.7; |
| 14758 |
for (int i=0; i<tripels.size(); i++){ |
| 14759 |
/* print the midcenter as q peaks |
| 14760 |
V3 f; |
| 14761 |
kart2frac(tripels.at(i).midcenter,f); |
| 14762 |
printf("Q%03d 1 %9.5f %9.5f %9.5f 11.0 0.05 %5.2f\n",i,f.x,f.y,f.z,i*0.01); |
| 14763 |
*/ |
| 14764 |
for (int j=0; j<i; j++){ |
| 14765 |
double dist=Distance(tripels.at(i).midcenter,tripels.at(j).midcenter); |
| 14766 |
if (dist<RINGTEST){ |
| 14767 |
bool alreadyHaveIt=false; |
| 14768 |
for (int k = 0; k < ringe.size(); k++){ |
| 14769 |
//printf("j%d i%d k%d\n",j,i,k); |
| 14770 |
// if (ringe[k].isComplete()) continue; |
| 14771 |
V3 r1=ringe[k].theCenter(); |
| 14772 |
double |
| 14773 |
d1=Distance(tripels.at(i).midcenter,r1), |
| 14774 |
d2=Distance(tripels.at(j).midcenter,r1); |
| 14775 |
if ((d1<RINGTEST)||(d2<RINGTEST)){ |
| 14776 |
ringe[k].addTripel(tripels.at(i)); |
| 14777 |
ringe[k].addTripel(tripels.at(j)); |
| 14778 |
//printf(":: %d %f %f ::\n", k, d1, d2); |
| 14779 |
alreadyHaveIt=true; |
| 14780 |
// continue; |
| 14781 |
} |
| 14782 |
//else printf(":: %f %f ::\n",d1,d2); |
| 14783 |
} |
| 14784 |
if (!alreadyHaveIt){ |
| 14785 |
//printf("tic\n"); |
| 14786 |
ringe.append(Ring(tripels.at(i),tripels.at(j))); |
| 14787 |
//ringe.last().printRing(this); |
| 14788 |
} |
| 14789 |
}//else {printf("DIST %g\n",dist);} |
| 14790 |
//printf("j%d %d\n",j,i); |
| 14791 |
} |
| 14792 |
//printf("i%d \n",i); |
| 14793 |
} |
| 14794 |
//return; |
| 14795 |
//printf("Rings %d\n",ringe.size()); |
| 14796 |
emit message(QString("found %1 rings.").arg(ringe.size())); |
| 14797 |
// int fix=0; |
| 14798 |
for (int ri=0; ri<ringe.size(); ri++){ |
| 14799 |
bool fertig = ringe[ri].isComplete(); |
| 14800 |
if ((!fertig)&&(ringe[ri].members.size()<7)) { |
| 14801 |
//ringe[ri].printRing(this); |
| 14802 |
int u=ringe[ri].members.size(); |
| 14803 |
for (int w=0; w<u; w++) { |
| 14804 |
for (int v=0; v<tripels.size();v++){ |
| 14805 |
if ( |
| 14806 |
(ringe[ri].members.contains(tripels.at(v).n[0]))&& |
| 14807 |
(ringe[ri].members.contains(tripels.at(v).n[1]))&& |
| 14808 |
(ringe[ri].members.contains(tripels.at(v).n[2]))) { |
| 14809 |
ringe[ri].addTripel(tripels.at(v)); |
| 14810 |
continue; |
| 14811 |
} |
| 14812 |
} |
| 14813 |
} |
| 14814 |
} |
| 14815 |
//ringe[ri].printRing(this); |
| 14816 |
fertig = ringe[ri].isComplete(); |
| 14817 |
ringe[ri].isItARealRing(); |
| 14818 |
fertig = ringe[ri].isComplete(); |
| 14819 |
//printf("%d %d %d\n",ringe[ri].t.size(),ringe[ri].members.size(),fertig); |
| 14820 |
if (!fertig) {ringe.removeAt(ri);ri--;} |
| 14821 |
} |
| 14822 |
/* |
| 14823 |
for (int ri=0; ri<ringe.size(); ri++){ |
| 14824 |
for (int rj=1; rj<ri; rj++){ |
| 14825 |
if (rj==ri)continue; |
| 14826 |
if (Distance(ringe[ri].theCenter(),ringe[rj].theCenter())<0.2){ringe.removeAt(ri);ri--;break;} |
| 14827 |
} |
| 14828 |
} |
| 14829 |
*/ |
| 14830 |
//printf("Rings %d are real and complete.\n",ringe.size()); |
| 14831 |
emit message(QString("found %1 rings.").arg(ringe.size())); |
| 14832 |
// return; |
| 14833 |
for (int mi=0; mi<centerOfMass.size();mi++){ |
| 14834 |
//printf("Molecule#%d has %d atoms\n", mi, molsizes.at(mi)); |
| 14835 |
double away=-10.0; |
| 14836 |
int itakethisring=0; |
| 14837 |
for (int ri=0; ri<ringe.size(); ri++){ |
| 14838 |
if ((_w->mole.asymm.at(ringe.at(ri).members.at(0)).molindex-1)!=mi) continue; |
| 14839 |
//bool fertig = ringe[ri].isComplete(); |
| 14840 |
// if (fertig) fix++; |
| 14841 |
//ringe[ri].printRing(this); |
| 14842 |
//printf("Ring #%d size = %d/%d is complete %d\n",ri,ringe.at(ri).t.size(),ringe.at(ri).members.size(),fertig); |
| 14843 |
if (ringe.at(ri).members.size()==7){ |
| 14844 |
ringe[ri].debugRing(&_w->mole); |
| 14845 |
ringe[ri].isItARealRing(); |
| 14846 |
} |
| 14847 |
double d=Distance(centerOfMass[_w->mole.asymm.at(ringe.at(ri).members.at(0)).molindex-1],ringe[ri].theCenter()); |
| 14848 |
V3 dir = (_w->mole.asymm.at(ringe.at(ri).members.at(0)).pos - |
| 14849 |
ringe[ri].theCenter())%(_w->mole.asymm.at(ringe.at(ri).members.at(1)).pos - ringe[ri].theCenter()); |
| 14850 |
V3 com2r = ringe[ri].theCenter()-centerOfMass[_w->mole.asymm.at(ringe.at(ri).members.at(0)).molindex-1]; |
| 14851 |
double test= dir*com2r; |
| 14852 |
QList<int> rcpy=ringe[ri].members; |
| 14853 |
if (test>0.0){//flip ring order |
| 14854 |
ringe[ri].members.clear(); |
| 14855 |
for (int kk=rcpy.size()-1; kk>=0; kk--){ |
| 14856 |
ringe[ri].members.append(rcpy.at(kk)); |
| 14857 |
} |
| 14858 |
dir = (_w->mole.asymm.at(ringe.at(ri).members.at(0)).pos - |
| 14859 |
ringe[ri].theCenter())%(_w->mole.asymm.at(ringe.at(ri).members.at(1)).pos - ringe[ri].theCenter()); |
| 14860 |
test= dir*com2r; |
| 14861 |
//printf("fliped "); |
| 14862 |
} |
| 14863 |
//ringe[ri].printRing(this); |
| 14864 |
if (away<d){ |
| 14865 |
away=d; |
| 14866 |
itakethisring=ri; |
| 14867 |
} |
| 14868 |
//printf("AWAYOFCOM %f %d test%g \n",d,ri,test); |
| 14869 |
} |
| 14870 |
//printf("Complete Rings %d\n",fix); |
| 14871 |
//printf("Rings %d\n",ringe.size()); |
| 14872 |
emit message(QString("found %1 rings.").arg(ringe.size())); |
| 14873 |
if ((!ringe.isEmpty())&&((_w->mole.asymm.at(ringe.at(itakethisring).members.at(0)).molindex-1)==mi)){ |
| 14874 |
//ringe[itakethisring].printRing(this); |
| 14875 |
//printf("most far AWAY from COM %f %d\n",away,itakethisring); |
| 14876 |
int starthere=0,mn=0; |
| 14877 |
double away2=1000; |
| 14878 |
for (int i=0; i<ringe[itakethisring].members.size(); i++){ |
| 14879 |
if ((neighbors.at(ringe[itakethisring].members.at(i)).size()>=mn)&& |
| 14880 |
(Distance(_w->mole.asymm.at(ringe[itakethisring].members.at(i)).pos,centerOfMass[_w->mole.asymm.at(ringe.at(itakethisring).members.at(i)).molindex-1])<away2)){ |
| 14881 |
mn=neighbors.at(ringe[itakethisring].members.at(i)).size(); |
| 14882 |
away2=Distance(_w->mole.asymm.at(ringe[itakethisring].members.at(i)).pos,centerOfMass[_w->mole.asymm.at(ringe.at(itakethisring).members.at(i)).molindex-1]); |
| 14883 |
starthere=i; |
| 14884 |
} |
| 14885 |
} |
| 14886 |
chains.append(emptyChain); |
| 14887 |
for (int i=0; i<ringe[itakethisring].members.size(); i++){ |
| 14888 |
chains.last().append(ringe[itakethisring].members.at(starthere%ringe[itakethisring].members.size())); |
| 14889 |
starthere++; |
| 14890 |
} |
| 14891 |
ringe[itakethisring].done=true; |
| 14892 |
//aneal ring |
| 14893 |
for (int ci=0; ci<chains.last().size(); ci++){ |
| 14894 |
for (int ri=0; ri<ringe.size();ri++){ |
| 14895 |
if (ringe.at(ri).done) continue; |
| 14896 |
if ((ringe[ri].members.contains(chains.last().at(ci)))&&(ringe[ri].members.contains(chains.last().at((ci+1)%chains.last().size())))){ |
| 14897 |
int bbv=chains.last().size(); |
| 14898 |
int ll=chains.last().last(); |
| 14899 |
int strt=ringe[ri].members.indexOf(ll); |
| 14900 |
if (strt<0)strt = ringe[ri].members.indexOf(chains.last().at(ci)); |
| 14901 |
for (int rri=0,rrj=0; rri<ringe[ri].members.size(); rri++){ |
| 14902 |
rrj=(strt>=0)?(strt+rri)%ringe[ri].members.size():rri; |
| 14903 |
if (!chains.last().contains(ringe[ri].members.at(rrj))) chains.last().append(ringe[ri].members.at(rrj)); |
| 14904 |
} |
| 14905 |
bbv-=chains.last().size(); |
| 14906 |
if (bbv) ringe[ri].done=true; |
| 14907 |
//printf("RING%d %d %d %d %d\n",ri,bbv,ci,chains.last().size(),ringe[ri].members.size()); |
| 14908 |
} |
| 14909 |
} |
| 14910 |
} |
| 14911 |
do{ |
| 14912 |
int ce=chains.last().size(); |
| 14913 |
for (int cc=0; cc<ce; cc++){ |
| 14914 |
for (int nn=0; nn<neighbors.at(chains.last().at(cc)).size();nn++){ |
| 14915 |
if (!chains.last().contains(neighbors.at(chains.last().at(cc)).at(nn))) { |
| 14916 |
chains.last().append(neighbors.at(chains.last().at(cc)).at(nn)); |
| 14917 |
//printf("ext %s\n",asymm.at(neighbors.at(chains.last().at(cc)).at(nn)).Label.toStdString().c_str()); |
| 14918 |
extendChain(ringe,chains.last(), neighbors,nogo); |
| 14919 |
} |
| 14920 |
} |
| 14921 |
} |
| 14922 |
}while(chains.last().size()<molsizes.at(mi)); |
| 14923 |
if (chains.last().size()==molsizes.at(mi))moleIsDone[mi]=true; |
| 14924 |
} |
| 14925 |
if ((!chains.isEmpty())&&(!result.contains(chains.last().last()))) { |
| 14926 |
result.append(chains.last()); |
| 14927 |
} |
| 14928 |
}//mi |
| 14929 |
|
| 14930 |
/* |
| 14931 |
for (int cs=0; cs<chains.size(); cs++){ |
| 14932 |
chains[cs].clear(); |
| 14933 |
} |
| 14934 |
chains.clear(); |
| 14935 |
*/ |
| 14936 |
//for(int i=0; i<result.size(); i++){printf("%s[%d]=",asymm.at(result.at(i)).Label.toStdString().c_str(),i+1);if(!(i%10))printf("\n");}printf("\n"); |
| 14937 |
//return; |
| 14938 |
// |
| 14939 |
//printf("Molecules with rings are done\n"); |
| 14940 |
emit message(QString("Molecules with rings are done.")); |
| 14941 |
for (int mi=0; mi<molsizes.size(); mi++){ |
| 14942 |
if (moleIsDone.at(mi)) continue; |
| 14943 |
//printf("mol%d %d %d %d resultsize%d chains%d\n",mi,molsizes.at(mi),molsizes.size(),centerOfMass.size(), |
| 14944 |
// result.size(),chains.size()); |
| 14945 |
int starthere=-1; |
| 14946 |
double away=-10; |
| 14947 |
for (int i=0; i<neighbors.size(); i++){ |
| 14948 |
if (_w->mole.asymm.at(i).an<0)continue; |
| 14949 |
if ((_w->mole.asymm.at(i).molindex-1 == mi)&&(neighbors.at(i).size()==0)){ |
| 14950 |
result.append(i);//isolated atoms |
| 14951 |
continue; |
| 14952 |
} |
| 14953 |
if ((_w->mole.asymm.at(i).molindex-1 == mi)&&(neighbors.at(i).size()==1)){//chain end |
| 14954 |
//printf("%d %d %d %d %d\n",__LINE__,i,asymm.size(),neighbors.size()); |
| 14955 |
double d=Distance(_w->mole.asymm.at(i).pos,centerOfMass.at(mi)); |
| 14956 |
//printf("%d\n",__LINE__); |
| 14957 |
if (d>away){ |
| 14958 |
away=d; |
| 14959 |
starthere=i; |
| 14960 |
} |
| 14961 |
} |
| 14962 |
// printf("%d\n",__LINE__); |
| 14963 |
} |
| 14964 |
//printf("%d\n",__LINE__); |
| 14965 |
if (starthere<0) continue; |
| 14966 |
//printf("start at %d if not done%d\n",starthere,!result.contains(starthere)); |
| 14967 |
|
| 14968 |
if (!result.contains(starthere)){ |
| 14969 |
chains.append(emptyChain); |
| 14970 |
chains.last().append(starthere); |
| 14971 |
extendChain(ringe,chains.last(),neighbors,nogo); |
| 14972 |
} |
| 14973 |
do{ |
| 14974 |
int ce=chains.last().size(); |
| 14975 |
for (int cc=0; cc<ce; cc++){ |
| 14976 |
for (int nn=0; nn<neighbors.at(chains.last().at(cc)).size();nn++){ |
| 14977 |
if (!chains.last().contains(neighbors.at(chains.last().at(cc)).at(nn))) { |
| 14978 |
chains.last().append(neighbors.at(chains.last().at(cc)).at(nn)); |
| 14979 |
//printf("ext %s\n",asymm.at(neighbors.at(chains.last().at(cc)).at(nn)).Label.toStdString().c_str()); |
| 14980 |
extendChain(ringe,chains.last(), neighbors,nogo); |
| 14981 |
} |
| 14982 |
} |
| 14983 |
} |
| 14984 |
}while(chains.last().size()<molsizes.at(mi)); |
| 14985 |
if ((!chains.isEmpty())&&(!result.contains(chains.last().last()))) { |
| 14986 |
result.append(chains.last()); |
| 14987 |
} |
| 14988 |
|
| 14989 |
} |
| 14990 |
for (int cs=0; cs<chains.size(); cs++){ |
| 14991 |
chains[cs].clear(); |
| 14992 |
} |
| 14993 |
chains.clear(); |
| 14994 |
emit message("All chains are done!"); |
| 14995 |
} |
| 14996 |
|
| 14997 |
void AulaWorker::finalize(){ |
| 14998 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 14999 |
_w->editor->setPlainText(all); |
| 15000 |
all.clear(); |
| 15001 |
_w->fileSave(); |
| 15002 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 15003 |
//_w->editor->textCursor().beginEditBlock(); |
| 15004 |
|
| 15005 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 15006 |
|
| 15007 |
//_w->sdm(); |
| 15008 |
_w->chgl->update(); |
| 15009 |
//printf("AuLa take %d ms. %d\n", rzeit.elapsed(),__LINE__); // rzeit.restart(); |
| 15010 |
_w->fileSave(); |
| 15011 |
|
| 15012 |
//printf("AuLa took %d ms.\n", rzeit.elapsed()); // rzeit.restart(); |
| 15013 |
QWhatsThis::hideText(); |
| 15014 |
QMessageBox mb2(QMessageBox::Information, |
| 15015 |
"Automatic Labeling",QString("<h4>Labeled %1 atoms out of %2 atoms in the asymmetic unit in %3 seconds </h4>") |
| 15016 |
.arg(chain.size()).arg(possible).arg((rzeit.elapsed()/1000.0),0,'f',1)); |
| 15017 |
mb2.exec(); |
| 15018 |
} |
| 15019 |
|
| 15020 |
void Window::changeSelectedElements(){ |
| 15021 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 15022 |
int index=0; |
| 15023 |
if (action) |
| 15024 |
index=action->data().toInt(); |
| 15025 |
else return; |
| 15026 |
if (index>editor->sfac.size()) return; |
| 15027 |
//if ((chgl->ImeanThisAtom>mole.asymm.size())||(chgl->ImeanThisAtom<0)) return; |
| 15028 |
QList<int> diese; |
| 15029 |
for (int i=0; i<chgl->mol->selectedatoms.size(); i++){ |
| 15030 |
int das=(chgl->mol->selectedatoms.at(i).style>mole.asymm.size())? |
| 15031 |
chgl->mol->showatoms.at(chgl->mol->selectedatoms.at(i).style).auidx: |
| 15032 |
chgl->mol->selectedatoms.at(i).style; |
| 15033 |
if (!diese.contains(das)) diese.append(das); |
| 15034 |
printf("changeSelectedElements %s -> %s %d %d %d %d %s\n", |
| 15035 |
chgl->mol->selectedatoms.at(i).Label.toStdString().c_str(), |
| 15036 |
(chgl->mol->selectedatoms.at(i).style>mole.asymm.size())? |
| 15037 |
chgl->mol->asymm.at(chgl->mol->showatoms.at(chgl->mol->selectedatoms.at(i).style).auidx).Label.toStdString().c_str(): |
| 15038 |
chgl->mol->asymm.at(chgl->mol->selectedatoms.at(i).style).Label.toStdString().c_str(), |
| 15039 |
|
| 15040 |
i, |
| 15041 |
chgl->mol->showatoms.at(chgl->mol->selectedatoms.at(i).style).auidx, |
| 15042 |
chgl->mol->selectedatoms.at(i).style, |
| 15043 |
index, |
| 15044 |
mole.pse(editor->sfac.at(index)).toStdString().c_str() ); |
| 15045 |
} |
| 15046 |
//return; |
| 15047 |
mole.selectedatoms.clear(); |
| 15048 |
////////////////// |
| 15049 |
sdm(); |
| 15050 |
rename_selected *owl = new rename_selected(this); |
| 15051 |
owl->setChainAndNewAN(diese,editor->sfac.at(index)); |
| 15052 |
connect(owl, SIGNAL(finished()), this, SLOT(sdm())); |
| 15053 |
connect(owl, SIGNAL(finished()), owl, SLOT(finalize())); |
| 15054 |
//connect(owl, SIGNAL(finished()), chgl, SLOT(updateLabelTextures())); |
| 15055 |
connect(owl, SIGNAL(finished()), chgl, SLOT(update())); |
| 15056 |
connect(owl, SIGNAL(message(const QString&)), this, SLOT(updateStatusBar(const QString&))); |
| 15057 |
connect(owl, SIGNAL(message(const QString&)), this, SLOT(update())); |
| 15058 |
connect(owl, SIGNAL(finished()), owl, SLOT(deleteLater())); |
| 15059 |
maybeSave2(); |
| 15060 |
QWhatsThis::showText(QPoint(pos().x() + width()/2,pos().y() + height()/2),"<H1>Auto Labeling in process please be patient!<br> You can follow progress below in the status bar.</H1>",this); |
| 15061 |
sdm(); |
| 15062 |
owl->start(); |
| 15063 |
////////////////// |
| 15064 |
/* |
| 15065 |
bool alterMichi=rufModeBox->isChecked(); |
| 15066 |
for (int i=0; diese.size(); i++){ |
| 15067 |
int das=diese.at(i); |
| 15068 |
rufModeBox->setChecked(true); |
| 15069 |
// printf("new Element of %s is %s\n",mole.asymm.at(das).Label.toStdString().c_str(),mole.pse(editor->sfac.at(index)).toStdString().c_str()); |
| 15070 |
static QRegularExpression num=QRegularExpression("\\d+"); |
| 15071 |
if (mole.asymm.at(das).Label.contains(num)) { |
| 15072 |
int p=editor->sfac.at(index); |
| 15073 |
labelPSE=mole.pse(p); |
| 15074 |
|
| 15075 |
labelIndex=mole.asymm.at(das).Label.section(nonumbers,0,0,QString::SectionSkipEmpty).toInt(); |
| 15076 |
labelSuffix=mole.asymm.at(das).Label.section(num,1,1); |
| 15077 |
labelSuffix.remove(vorneweg); |
| 15078 |
} |
| 15079 |
else{ |
| 15080 |
int p=editor->sfac.at(index); |
| 15081 |
labelPSE=mole.pse(p); |
| 15082 |
labelIndex=-1; |
| 15083 |
labelSuffix=mole.asymm.at(das).Label; |
| 15084 |
labelSuffix.remove(0,labelPSE.size()); |
| 15085 |
labelSuffix.remove(vorneweg); |
| 15086 |
} |
| 15087 |
|
| 15088 |
partSpin->setValue(mole.asymm.at(das).part); |
| 15089 |
resiNrSpin->setValue(mole.asymm.at(das).resiNr); |
| 15090 |
resiResiClass->setText(mole.asymm.at(das).ResiClass); |
| 15091 |
pserbt[editor->sfac.at(index)+1]->setChecked(true); |
| 15092 |
printf("%d das %d\n",__LINE__,das); |
| 15093 |
renamUpdate(false); |
| 15094 |
updateLabel(); |
| 15095 |
renameThisAtom(das); |
| 15096 |
printf("->i = %d/%d das = %d %d\n",i,diese.size(),das,alterMichi); |
| 15097 |
} |
| 15098 |
rufModeBox->setChecked(alterMichi); |
| 15099 |
printf("done rename\n"); */ |
| 15100 |
} |
| 15101 |
|
| 15102 |
void Window::changeElement(){ |
| 15103 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 15104 |
int index=0; |
| 15105 |
if (action) |
| 15106 |
index=action->data().toInt(); |
| 15107 |
else return; |
| 15108 |
if (index>editor->sfac.size()) return; |
| 15109 |
if ((chgl->ImeanThisAtom>mole.asymm.size())||(chgl->ImeanThisAtom<0)) return; |
| 15110 |
int das=chgl->ImeanThisAtom; |
| 15111 |
bool alterMichi=rufModeBox->isChecked(); |
| 15112 |
rufModeBox->setChecked(true); |
| 15113 |
// printf("new Element of %s is %s\n",mole.asymm.at(das).Label.toStdString().c_str(),mole.pse(editor->sfac.at(index)).toStdString().c_str()); |
| 15114 |
//static QRegularExpression num=QRegularExpression("\\d+"); |
| 15115 |
if (mole.asymm.at(das).Label.contains(numbers)) { |
| 15116 |
int p=editor->sfac.at(index); |
| 15117 |
labelPSE=mole.pse(p); |
| 15118 |
|
| 15119 |
labelIndex=mole.asymm.at(das).Label.section(nonumbers,0,0,QString::SectionSkipEmpty).toInt(); |
| 15120 |
labelSuffix=mole.asymm.at(das).Label.section(numbers,1,1); |
| 15121 |
labelSuffix.remove(vorneweg); |
| 15122 |
} |
| 15123 |
else{ |
| 15124 |
int p=editor->sfac.at(index); |
| 15125 |
labelPSE=mole.pse(p); |
| 15126 |
labelIndex=-1; |
| 15127 |
labelSuffix=mole.asymm.at(das).Label; |
| 15128 |
labelSuffix.remove(0,labelPSE.size()); |
| 15129 |
labelSuffix.remove(vorneweg); |
| 15130 |
} |
| 15131 |
|
| 15132 |
partSpin->setValue(mole.asymm.at(das).part); |
| 15133 |
resiNrSpin->setValue(mole.asymm.at(das).resiNr); |
| 15134 |
resiResiClass->setText(mole.asymm.at(das).ResiClass); |
| 15135 |
pserbt[editor->sfac.at(index)+1]->setChecked(true); |
| 15136 |
printf("%d\n",__LINE__); |
| 15137 |
renamUpdate(false); |
| 15138 |
updateLabel(); |
| 15139 |
renameThisAtom(das); |
| 15140 |
rufModeBox->setChecked(alterMichi); |
| 15141 |
} |
| 15142 |
|
| 15143 |
void Window::zoomin(){ |
| 15144 |
chgl->zoom(0.1); |
| 15145 |
chgl->update(); |
| 15146 |
} |
| 15147 |
|
| 15148 |
void Window::zoomout(){ |
| 15149 |
chgl->zoom(-0.1); |
| 15150 |
chgl->update(); |
| 15151 |
} |
| 15152 |
|
| 15153 |
void Window::calculator() { |
| 15154 |
if (!calcmenu) calcmenu = new Calculator(CurrentCellString,this); |
| 15155 |
else calcmenu->show(); |
| 15156 |
connect(calcmenu,SIGNAL(currentCellrequest()),this,SLOT(setCalculatorsCurrentCell()) ); |
| 15157 |
} |
| 15158 |
|
| 15159 |
void Window::setCalculatorsCurrentCell(){ |
| 15160 |
if (calcmenu){ |
| 15161 |
calcmenu->setHKLEdit(CurrentCellString); |
| 15162 |
} |
| 15163 |
} |
| 15164 |
|
| 15165 |
void Window::create_DSRGui() { |
| 15166 |
// Only starts DSRGui instance if not already started: |
| 15167 |
if (dsr == nullptr) { |
| 15168 |
dsr = new DSRGui(&mole, shelxlPath, this); |
| 15169 |
connect(dsr, SIGNAL(closed()), this, SLOT(dsrClosed()) ); |
| 15170 |
QList<QAction *> acs = helpMenu->actions(); |
| 15171 |
bool oneisenough=true; |
| 15172 |
for (int i = 0; i < acs.size(); ++i){ |
| 15173 |
if (acs.at(i)->text()=="About DSR Plugin") {oneisenough=false;break;} |
| 15174 |
} |
| 15175 |
if (oneisenough) helpMenu->addAction("About DSR Plugin", dsr, SLOT(aboutDSR())); |
| 15176 |
} |
| 15177 |
// Go out of rename mode. |
| 15178 |
printf("%d\n",__LINE__); |
| 15179 |
renamUpdate(false); |
| 15180 |
if (!dsr->isActiveWindow()){ |
| 15181 |
dsr->raise(); |
| 15182 |
dsr->activateWindow(); |
| 15183 |
printf("%d\n",__LINE__); |
| 15184 |
renamUpdate(false); |
| 15185 |
} |
| 15186 |
} |
| 15187 |
|
| 15188 |
void Window::dsrClosed() { |
| 15189 |
dsr = nullptr; |
| 15190 |
} |
| 15191 |
|
| 15192 |
void Window::insertDSRLine(QString dsrline, int position, QVector<int> previousLine){ |
| 15193 |
// Insert the DSR command line at the position below the FVAR line, |
| 15194 |
// or if not present, the first atom. |
| 15195 |
// If also a previous DSR line is present (previousLine > 0), the previous line will be deleted. |
| 15196 |
foreach (int lineNum, previousLine) { |
| 15197 |
if (lineNum > 0) { |
| 15198 |
QTextCursor cursor = editor->textCursor(); |
| 15199 |
cursor.setPosition(0); |
| 15200 |
cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, lineNum); |
| 15201 |
editor->setTextCursor(cursor); |
| 15202 |
cursor.insertText("REM "); |
| 15203 |
} |
| 15204 |
} |
| 15205 |
QTextCursor cursor = editor->textCursor(); |
| 15206 |
cursor.setPosition(0); |
| 15207 |
cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, position+1); |
| 15208 |
editor->setTextCursor(cursor); |
| 15209 |
cursor.insertText(dsrline); |
| 15210 |
cursor.insertText("\n"); |
| 15211 |
fileSave(true, false); |
| 15212 |
} |
| 15213 |
|
| 15214 |
void Window::rotl(){ |
| 15215 |
emit movedByUser(); |
| 15216 |
chgl->rotY(0.1); |
| 15217 |
chgl->update(); |
| 15218 |
|
| 15219 |
} |
| 15220 |
|
| 15221 |
void Window::rotr(){ |
| 15222 |
emit movedByUser(); |
| 15223 |
chgl->rotY(-0.1); |
| 15224 |
chgl->update(); |
| 15225 |
} |
| 15226 |
|
| 15227 |
void Window::rotu(){ |
| 15228 |
emit movedByUser(); |
| 15229 |
chgl->rotX(0.1); |
| 15230 |
chgl->update(); |
| 15231 |
} |
| 15232 |
|
| 15233 |
void Window::rotd(){ |
| 15234 |
emit movedByUser(); |
| 15235 |
chgl->rotX(-0.1); |
| 15236 |
chgl->update(); |
| 15237 |
} |
| 15238 |
|
| 15239 |
void Window::updateStatusBar(const QString& s) { |
| 15240 |
statusBar()->showMessage(s); |
| 15241 |
emit pipeStatus(s); |
| 15242 |
update(); |
| 15243 |
|
| 15244 |
} |
| 15245 |
|
| 15246 |
int Window::getFvarNr(double v, const QList<double> fv){ |
| 15247 |
double av=qAbs(v); |
| 15248 |
int m=0; |
| 15249 |
while ((-10*m+av) > 5){m++;} |
| 15250 |
if (m>1) m=qMin(m,fv.size()); |
| 15251 |
return m; |
| 15252 |
} |
| 15253 |
|
| 15254 |
double Window::getNumber(double v, const QList<double> fv,int idx,int &fixFlag){ |
| 15255 |
double av=qAbs(v),res=0.0,var=1.0; |
| 15256 |
int m=0; |
| 15257 |
while ((-10*m+av) > 5){m++;} |
| 15258 |
if (m>1) m=qMin(m,fv.size()); |
| 15259 |
if (m>1) var=fv.at(m-1); |
| 15260 |
if (!m) res=v; |
| 15261 |
else if (v>0) res=(av-(10*m))*var; |
| 15262 |
else res=(av-(10*m))*(1.0-var); |
| 15263 |
fvarCntr[m]++; |
| 15264 |
if (m>0) fixFlag|=1<<idx; else if (fixFlag&1<<idx) fixFlag-=1<<idx; |
| 15265 |
//if (m==3) printf("Aidx: %d shift %d flag %d m%d fvarCntr=%d %f %f\n", idx,1<<idx,fixFlag,m,fvarCntr.value(m),v,res); |
| 15266 |
return res; |
| 15267 |
} |
| 15268 |
|
| 15269 |
double Window::getNumber(double v, const QList<double> fv, double uiso){ |
| 15270 |
double av=qAbs(v),res=0.0,var=1.0; |
| 15271 |
if ((v<-0.5)&& (v>-5.0)) return res = av * uiso ; |
| 15272 |
int m=0; |
| 15273 |
while ((-10*m+av) > 5){m++;} |
| 15274 |
if (m>1) m=qMin(m,fv.size()); |
| 15275 |
if (m>1) var=fv.at(m-1); |
| 15276 |
if (!m) return v; |
| 15277 |
else if (v>=0) res=(av-(10*m))*var; |
| 15278 |
else res=(av-(10*m))*(1.0-var); |
| 15279 |
fvarCntr[m]++; |
| 15280 |
//printf("Bidx: m%d fvarCntr=%d\n",m,fvarCntr.value(m)); |
| 15281 |
return res; |
| 15282 |
} |
| 15283 |
|
| 15284 |
int Window::isacommand(QString command){ |
| 15285 |
QStringList keywords; |
| 15286 |
keywords << |
| 15287 |
"ACTA"<<//0 |
| 15288 |
"AFIX"<<//1 |
| 15289 |
"MPLA"<<//2 |
| 15290 |
"ANIS"<<//3 |
| 15291 |
"BASF"<<//4 |
| 15292 |
"BIND"<<//5 |
| 15293 |
"BLOC"<<//6 |
| 15294 |
"BOND"<<//7 AGS4 to MPLA |
| 15295 |
"BUMP"<<//8 |
| 15296 |
"CELL"<<//9 |
| 15297 |
"CGLS"<<//10 |
| 15298 |
"CHIV"<<//11 |
| 15299 |
"CONF"<<//12 |
| 15300 |
"CONN"<<//13 |
| 15301 |
"DAMP"<<//14 |
| 15302 |
"DANG"<<//15 |
| 15303 |
"DEFS"<<//16 |
| 15304 |
"DELU"<<//17 |
| 15305 |
"DFIX"<<//18 |
| 15306 |
"DISP"<<//19 |
| 15307 |
"EADP"<<//20 |
| 15308 |
"EGEN"<<//21 |
| 15309 |
"END" <<//22 |
| 15310 |
"EQIV"<<//23 |
| 15311 |
"ESEL"<<//24 |
| 15312 |
"EXTI"<<//25 |
| 15313 |
"EXYZ"<<//26 |
| 15314 |
"FEND"<<//27 |
| 15315 |
"FLAT"<<//28 |
| 15316 |
"FMAP"<<//29 |
| 15317 |
"FRAG"<<//30 |
| 15318 |
"FREE"<<//31 |
| 15319 |
"FVAR"<<//32 |
| 15320 |
"GRID"<<//33 |
| 15321 |
"HFIX"<<//34 |
| 15322 |
"HKLF"<<//35 |
| 15323 |
"HOPE"<<//36 |
| 15324 |
"HTAB"<<//37 |
| 15325 |
"INIT"<<//38 |
| 15326 |
"ISOR"<<//39 |
| 15327 |
"LAST"<<//40 |
| 15328 |
"LATT"<<//41 |
| 15329 |
"LAUE"<<//42 |
| 15330 |
"LIST"<<//43 |
| 15331 |
"L.S."<<//44 |
| 15332 |
"MERG"<<//45 |
| 15333 |
"MOLE"<<//46 |
| 15334 |
"MORE"<<//47 |
| 15335 |
"MOVE"<<//48 |
| 15336 |
"NCSY"<<//49 |
| 15337 |
"OMIT"<<//50 |
| 15338 |
"PART"<<//51 |
| 15339 |
"PATT"<<//52 |
| 15340 |
"PHAN"<<//53 |
| 15341 |
"PHAS"<<//54 |
| 15342 |
"PLAN"<<//55 |
| 15343 |
"PSEE"<<//56 |
| 15344 |
"REM"<< //57 |
| 15345 |
"RESI"<<//58 |
| 15346 |
"RTAB"<<//59 |
| 15347 |
"SADI"<<//60 |
| 15348 |
"SAME"<<//61 |
| 15349 |
"SFAC"<<//62 |
| 15350 |
"SHEL"<<//63 |
| 15351 |
"SIMU"<<//64 |
| 15352 |
"SIZE"<<//65 |
| 15353 |
"SPEC"<<//66 |
| 15354 |
"SPIN"<<//67 |
| 15355 |
"STIR"<<//68 |
| 15356 |
"SUMP"<<//69 |
| 15357 |
"SWAT"<<//70 |
| 15358 |
"SYMM"<<//71 |
| 15359 |
"TEMP"<<//72 |
| 15360 |
"TEXP"<<//73 |
| 15361 |
"TIME"<<//74 |
| 15362 |
"TITL"<<//75 |
| 15363 |
"TREF"<<//76 |
| 15364 |
"TWIN"<<//77 |
| 15365 |
"UNIT"<<//78 |
| 15366 |
"VECT"<<//79 |
| 15367 |
"WPDB"<<//80 |
| 15368 |
"WGHT"<<//81 |
| 15369 |
"ZERR"<<//82 |
| 15370 |
"XNPD"<<//83 |
| 15371 |
"REST"<<//84 |
| 15372 |
"CHAN"<<//85 |
| 15373 |
"RIGU"<<//86 |
| 15374 |
"FLAP"<<//87 |
| 15375 |
"RNUM"<<//88 |
| 15376 |
"SOCC"<<//89 |
| 15377 |
"PRIG"<<//90 |
| 15378 |
"WIGL"<<//91 |
| 15379 |
"RANG"<<//92 |
| 15380 |
"TANG"<<//93 |
| 15381 |
"ADDA"<<//94 |
| 15382 |
"STAG"<<//95 |
| 15383 |
"ATOM"<<//96PDB dummy commands ... |
| 15384 |
"HETA"<<//97 |
| 15385 |
"SCAL"<<//98 |
| 15386 |
"ABIN"<<//99 |
| 15387 |
"ANSC"<<//100 |
| 15388 |
"ANSR"<<//101 |
| 15389 |
"NOTR"<<//102 |
| 15390 |
"NEUT"<<//103 |
| 15391 |
"TWST"<<//104 |
| 15392 |
"BEDE"<<//105 |
| 15393 |
"LONE"//106<< |
| 15394 |
;// |
| 15395 |
QString c=command; |
| 15396 |
c=c.toUpper(); |
| 15397 |
c.remove(QRegularExpression("_\\S*")); |
| 15398 |
if (c.startsWith("+")) return 666;//file inclusion |
| 15399 |
return keywords.indexOf(c); |
| 15400 |
} |
| 15401 |
|
| 15402 |
void Window::clearStructure(){ |
| 15403 |
printf("clearStructure\n"); |
| 15404 |
chgl->showHidden(); |
| 15405 |
machPlatz=false; |
| 15406 |
chgl->neutrons=false; |
| 15407 |
infoKanal->clear(); |
| 15408 |
shxEditorDock->show(); |
| 15409 |
wghtAct->setEnabled(false); |
| 15410 |
qPeakDock->hide(); |
| 15411 |
|
| 15412 |
|
| 15413 |
enterRenameMode->setVisible(true); |
| 15414 |
chgl->qPeakBonds->setVisible(false); |
| 15415 |
chgl->shpm1->setVisible(false); |
| 15416 |
chgl->hideBeLo->setVisible(false); |
| 15417 |
belocube->setVisible(false); |
| 15418 |
mole.cell.symmops.clear(); |
| 15419 |
mole.cell.trans.clear(); |
| 15420 |
mole.asymm.clear(); |
| 15421 |
mole.sdm.clear(); |
| 15422 |
mole.showbonds.clear(); |
| 15423 |
mole.showatoms.clear(); |
| 15424 |
mole.selectedatoms.clear(); |
| 15425 |
mole.lbonds.clear(); |
| 15426 |
|
| 15427 |
mole.envi_sdm.clear(); |
| 15428 |
mole.contact.clear(); |
| 15429 |
mole.envi_sdm.clear(); |
| 15430 |
mole.contact.clear(); |
| 15431 |
mole.symmopsEQIV.clear(); |
| 15432 |
mole.labelEQIV.clear(); |
| 15433 |
mole.transEQIV.clear(); |
| 15434 |
mole.freeatoms.clear(); |
| 15435 |
mole.bindatoms.clear(); |
| 15436 |
for (int i=0; i<mole.knoepfe.size();i++) mole.knoepfe[i].neighbors.clear(); |
| 15437 |
mole.knoepfe.clear(); |
| 15438 |
mole.showbonds.clear(); |
| 15439 |
mole.selectedatoms.clear(); |
| 15440 |
//chgl->rotCenter(); |
| 15441 |
chgl->updateBondActions(); |
| 15442 |
mole.showatoms.clear(); |
| 15443 |
update(); |
| 15444 |
chgl->update(); |
| 15445 |
|
| 15446 |
} |
| 15447 |
|
| 15448 |
bool Window::quickReLoad(QString fn, QString &content){ |
| 15449 |
//return false; |
| 15450 |
// reasons for return false: |
| 15451 |
// CELL differs + |
| 15452 |
// filename differs + |
| 15453 |
// LATT differs + |
| 15454 |
// SYMM differs + |
| 15455 |
// asymm.size is different - |
| 15456 |
bool xit=(fn==oldFileName); |
| 15457 |
oldFileName=fn; |
| 15458 |
if (!xit) return false; |
| 15459 |
// Disabled SkipEmptyParts because otherwise i is not in sync with the line number! |
| 15460 |
QStringList lines = content.split(QRegularExpression("[\\r\\n]")); //,skipEmptyParts); |
| 15461 |
{//cell |
| 15462 |
int idx =lines.indexOf(QRegularExpression("^CELL.*$")); |
| 15463 |
//printf("IDX %d\n",idx); |
| 15464 |
double wave = lines.at(idx).section(leer,1,1).toDouble(); |
| 15465 |
double a = lines.at(idx).section(leer,2,2).toDouble(); |
| 15466 |
double b = lines.at(idx).section(leer,3,3).toDouble(); |
| 15467 |
double c = lines.at(idx).section(leer,4,4).toDouble(); |
| 15468 |
double al= lines.at(idx).section(leer,5,5).toDouble(); |
| 15469 |
double be = lines.at(idx).section(leer,6,6).toDouble(); |
| 15470 |
double ga = lines.at(idx).section(leer,7,7).toDouble(); |
| 15471 |
double diff= |
| 15472 |
fabs(mole.cell.a-a)+ |
| 15473 |
fabs(mole.cell.b-b)+ |
| 15474 |
fabs(mole.cell.c-c)+ |
| 15475 |
fabs(mole.cell.al-al)+ |
| 15476 |
fabs(mole.cell.be-be)+ |
| 15477 |
fabs(mole.cell.ga-ga)+ |
| 15478 |
fabs(mole.cell.wave-wave); |
| 15479 |
printf("cell differs %g\n",diff); |
| 15480 |
if (diff>0.00001) { |
| 15481 |
printf("cell differs too much!\n"); |
| 15482 |
lines.clear(); |
| 15483 |
return false; |
| 15484 |
} |
| 15485 |
} |
| 15486 |
{//latt |
| 15487 |
int idx =lines.indexOf(QRegularExpression("^LATT.*$")); |
| 15488 |
//printf("IDX %d\n",idx); |
| 15489 |
int thisLattice=lines.at(idx).section(leer,1,1).toInt(); |
| 15490 |
if (mole.latt!=thisLattice){ |
| 15491 |
lines.clear(); |
| 15492 |
return false; |
| 15493 |
} |
| 15494 |
|
| 15495 |
} |
| 15496 |
int minp=1,maxp=0; |
| 15497 |
bool qbeforehkl=false,hklf=false; |
| 15498 |
mole.pmin=10000; |
| 15499 |
mole.pmax=-10000; |
| 15500 |
mole.lmin=10000; |
| 15501 |
mole.lmax=-10000; |
| 15502 |
qPeakDock->hide(); |
| 15503 |
|
| 15504 |
mole.symmopsEQIV.clear(); |
| 15505 |
mole.labelEQIV.clear(); |
| 15506 |
mole.transEQIV.clear(); |
| 15507 |
mole.freeatoms.clear(); |
| 15508 |
mole.bindatoms.clear(); |
| 15509 |
editor->sfac.clear(); |
| 15510 |
editor->sfacsmbl.clear(); |
| 15511 |
fvar.clear(); |
| 15512 |
firstAtomLine = 0; |
| 15513 |
ls_cycls = 0; |
| 15514 |
editor->fvMinLine = 0; // otherwise it does not recognize a moving fvar line |
| 15515 |
MyAtom newAtom; |
| 15516 |
newAtom.part=0; |
| 15517 |
newAtom.resiNr=0; |
| 15518 |
newAtom.hidden=0; |
| 15519 |
newAtom.symmGroup=0; |
| 15520 |
newAtom.sg=0; |
| 15521 |
newAtom.scod=555;//the identity |
| 15522 |
newAtom.sof=0; |
| 15523 |
newAtom.sof_org=0; |
| 15524 |
newAtom.screenX=0; |
| 15525 |
newAtom.screenY=0; |
| 15526 |
newAtom.afix=0; |
| 15527 |
int part=0,afix=0; |
| 15528 |
double part_fvar=11.0; |
| 15529 |
double uiso=0.05; |
| 15530 |
int qpeaks=0; |
| 15531 |
int afixparent=0; |
| 15532 |
Scatt s(&mole); |
| 15533 |
//printf("after scatt\n"); |
| 15534 |
QStringList bedeRloneLY; |
| 15535 |
CEnvironment quickAtoms; |
| 15536 |
bool fragIgnore=false; |
| 15537 |
for (int i=0; i<lines.size(); i++){ |
| 15538 |
if (lines.at(i).startsWith(" ")) continue; |
| 15539 |
if (!lines.at(i).isEmpty()){ |
| 15540 |
newAtom.orginalLine=lines.at(i).section("=",0,0); |
| 15541 |
lines[i].remove("="); |
| 15542 |
int cmd=isacommand(lines.at(i).section(leer,0,0)); |
| 15543 |
//qDebug()<<cmd<<lines.at(i); |
| 15544 |
QString resiSpez=lines.at(i).section(leer,0,0).section('_',1,1); |
| 15545 |
if (cmd==30) fragIgnore=true; |
| 15546 |
if (cmd==27) fragIgnore=false; |
| 15547 |
if (!fragIgnore) |
| 15548 |
switch (cmd) { |
| 15549 |
case 1: //AFIX |
| 15550 |
afix=lines.at(i).section(leer,1,1).toInt(); |
| 15551 |
// For later |
| 15552 |
//afix_fvar = lines.at(i).section(leer,3,3).toInt(); |
| 15553 |
newAtom.afix=afix; |
| 15554 |
break; |
| 15555 |
case 5: {//bind |
| 15556 |
if (!lines.at(i).section(leer,1,2).contains(buchstaben)){ |
| 15557 |
int pn01=0,pn02=0; |
| 15558 |
bool ok1,ok2; |
| 15559 |
pn01=lines.at(i).section(leer,1,1).toInt(&ok1); |
| 15560 |
pn02=lines.at(i).section(leer,2,2).toInt(&ok2); |
| 15561 |
if ((ok1)&&(ok2)) mole.bindPart[pn01]=pn02; |
| 15562 |
if ((ok1)&&(ok2)) mole.bindPart[pn02]=pn01; |
| 15563 |
} |
| 15564 |
if (notRefine) break; |
| 15565 |
MyBind aa; |
| 15566 |
aa.Lab1=lines.at(i).section(leer,1,1).toUpper(); |
| 15567 |
aa.Lab2=lines.at(i).section(leer,2,2).toUpper(); |
| 15568 |
mole.bindatoms.append(aa); |
| 15569 |
} |
| 15570 |
break; |
| 15571 |
case 9: { //CELL |
| 15572 |
} |
| 15573 |
break; |
| 15574 |
case 10: { // L.S. |
| 15575 |
ls_cycls = lines.at(i).section(leer, 1, 1).toInt(); |
| 15576 |
} |
| 15577 |
break; |
| 15578 |
case 19:{//DISP |
| 15579 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15580 |
s.setDISP(tok); |
| 15581 |
} |
| 15582 |
break; |
| 15583 |
|
| 15584 |
case 23:{ //EQIV |
| 15585 |
mole.decodeSymmCardEQIV(lines.at(i)); |
| 15586 |
} |
| 15587 |
break; |
| 15588 |
case 25:{//EXTI |
| 15589 |
mole.exti=lines.at(i).section(leer,1,1).toDouble(); |
| 15590 |
} |
| 15591 |
break; |
| 15592 |
case 31:{//free |
| 15593 |
MyBind aa; |
| 15594 |
aa.Lab1=lines.at(i).section(leer,1,1).toUpper(); |
| 15595 |
aa.Lab2=lines.at(i).section(leer,2,2).toUpper(); |
| 15596 |
mole.freeatoms.append(aa); |
| 15597 |
} |
| 15598 |
break; |
| 15599 |
case 32:{ //FVAR |
| 15600 |
editor->fvMinLine=i; |
| 15601 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15602 |
for (int ifv=1; ifv<tok.size();ifv++){ |
| 15603 |
fvar.append(tok.at(ifv).toDouble()); |
| 15604 |
} |
| 15605 |
if (!fvar.isEmpty()) { |
| 15606 |
mole.osf=fvar.at(0); |
| 15607 |
} |
| 15608 |
} |
| 15609 |
break; |
| 15610 |
case 35: //HKLF |
| 15611 |
{ |
| 15612 |
hklf=true; |
| 15613 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15614 |
if (tok.size()>1){ |
| 15615 |
mole.hklf=tok.at(1).toInt(); |
| 15616 |
if (mole.hklf==5){ |
| 15617 |
switch2HKLF5->setVisible(false); |
| 15618 |
switch2HKLF4->setVisible(true); |
| 15619 |
} |
| 15620 |
//printf("HKLF !! %d %d %d\n",mole.hklf,switch2HKLF4->isVisible(),switch2HKLF5->isVisible()); |
| 15621 |
} |
| 15622 |
if (tok.size()>2)mole.hklScale=tok.at(2).toDouble(); |
| 15623 |
if (tok.size()>11){ |
| 15624 |
mole.hklMat.m11=tok.at(3).toDouble(); |
| 15625 |
mole.hklMat.m12=tok.at(4).toDouble(); |
| 15626 |
mole.hklMat.m13=tok.at(5).toDouble(); |
| 15627 |
mole.hklMat.m21=tok.at(6).toDouble(); |
| 15628 |
mole.hklMat.m22=tok.at(7).toDouble(); |
| 15629 |
mole.hklMat.m23=tok.at(8).toDouble(); |
| 15630 |
mole.hklMat.m31=tok.at(9).toDouble(); |
| 15631 |
mole.hklMat.m32=tok.at(10).toDouble(); |
| 15632 |
mole.hklMat.m33=tok.at(11).toDouble(); |
| 15633 |
|
| 15634 |
} |
| 15635 |
if (tok.size()>12)mole.hklSigmaScale=tok.at(12).toDouble(); |
| 15636 |
/*printf("HKLF N=%d s:%g \n%g %g %g\n%g %g %g\n%g %g %g\nsm: %g \n",mole.hklf,mole.hklScale , |
| 15637 |
mole.hklMat.m11,mole.hklMat.m12,mole.hklMat.m13, |
| 15638 |
mole.hklMat.m21,mole.hklMat.m22,mole.hklMat.m23, |
| 15639 |
mole.hklMat.m31,mole.hklMat.m32,mole.hklMat.m33, |
| 15640 |
mole.hklSigmaScale); |
| 15641 |
// */ |
| 15642 |
|
| 15643 |
} |
| 15644 |
break; |
| 15645 |
case 41: { //LATT |
| 15646 |
break; |
| 15647 |
} |
| 15648 |
case 44: { // CGLS |
| 15649 |
ls_cycls = lines.at(i).section(leer, 1, 1).toInt(); |
| 15650 |
} |
| 15651 |
break; |
| 15652 |
case 50://OMIT |
| 15653 |
{ |
| 15654 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15655 |
QRegularExpression num=QRegularExpression("$[A-Za-z]"); |
| 15656 |
if ((tok.size()==3)&&(!tok.at(1).contains(num))&&(!tok.at(2).contains(num))){ |
| 15657 |
//hklOmitSig,hklOmit2th,hklShellLow,hklShellHig |
| 15658 |
mole.hklOmitSig=tok.at(1).toDouble(); |
| 15659 |
mole.hklOmit2th=tok.at(2).toDouble(); |
| 15660 |
mole.hklShellHig=0.5*mole.cell.wave/sin(mole.hklOmit2th/360.0*M_PI); |
| 15661 |
} |
| 15662 |
} |
| 15663 |
break; |
| 15664 |
case 51: { //PART n sof |
| 15665 |
part = lines.at(i).section(leer,1,1).toInt(); |
| 15666 |
// part_fvar stores sof (and fvar) to decide during atom parsing |
| 15667 |
part_fvar = lines.at(i).section(leer, 2, 2).toDouble(); |
| 15668 |
minp=(minp<part)?minp:part; |
| 15669 |
maxp=(maxp>part)?maxp:part; |
| 15670 |
} |
| 15671 |
break; |
| 15672 |
case 58: {//RESI |
| 15673 |
if (lines.at(i).section(leer,1,1).indexOf(startnumbers)!=-1) { |
| 15674 |
newAtom.resiNr=lines.at(i).section(leer,1,1).toInt(); |
| 15675 |
newAtom.ResiClass=lines.at(i).section(leer,2,2); |
| 15676 |
} else { |
| 15677 |
newAtom.resiNr=lines.at(i).section(leer,2,2).toInt(); |
| 15678 |
newAtom.ResiClass=lines.at(i).section(leer,1,1); |
| 15679 |
} |
| 15680 |
printf("%s %s %d\n",lines.at(i).section(leer,1,1).toStdString().c_str(),newAtom.ResiClass.toStdString().c_str(),newAtom.resiNr); |
| 15681 |
break; |
| 15682 |
} |
| 15683 |
case 62: { //SFAC |
| 15684 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15685 |
if ((tok.size()>4)&&(!tok.at(2).contains(buchstaben))) { |
| 15686 |
s.setSCAT(tok); |
| 15687 |
if ((tok.at(2).toDouble()==0)&&((tok.at(3).toDouble()==1))) { |
| 15688 |
chgl->neutrons=true; |
| 15689 |
} |
| 15690 |
editor->sfac.append(mole.getOZ(tok.at(1))); |
| 15691 |
editor->sfacsmbl.append(tok.at(1)); |
| 15692 |
if (editor->sfac.last()>-2) { |
| 15693 |
if (tok.at(1)==QString("D")) { |
| 15694 |
pserbt[110]->show(); |
| 15695 |
//printf("show D\n"); |
| 15696 |
} |
| 15697 |
else pserbt[editor->sfac.last()+1]->show(); |
| 15698 |
} |
| 15699 |
sfacBox->setFixedSize((editor->sfacsmbl.size()+1)*52,70); |
| 15700 |
} else { |
| 15701 |
for (int isf=1; isf<tok.size();isf++) { |
| 15702 |
editor->sfac.append(mole.getOZ(tok.at(isf))); |
| 15703 |
editor->sfacsmbl.append(tok.at(isf)); |
| 15704 |
if (tok.at(isf)==QString("D")) { |
| 15705 |
pserbt[110]->show(); |
| 15706 |
//printf("show D\n"); |
| 15707 |
} |
| 15708 |
else { |
| 15709 |
pserbt[editor->sfac.last()+1]->show(); |
| 15710 |
//printf("!show %d %sw\n",editor->sfac.last(),tok.at(isf).toStdString().c_str()); |
| 15711 |
} |
| 15712 |
sfacBox->setFixedSize((editor->sfacsmbl.size()+1)*52,70); |
| 15713 |
} |
| 15714 |
} |
| 15715 |
} |
| 15716 |
break; |
| 15717 |
case 63:{//shel |
| 15718 |
//hklOmitSig,hklOmit2th,hklShellLow,hklShellHig |
| 15719 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15720 |
if (tok.size()>2){ |
| 15721 |
mole.hklShellLow=tok.at(1).toDouble(); |
| 15722 |
mole.hklShellHig=tok.at(2).toDouble(); |
| 15723 |
// qDebug()<<mole.hklShellLow<<mole.hklShellHig; |
| 15724 |
} |
| 15725 |
}break; |
| 15726 |
case 69:{ //SUMP |
| 15727 |
QStringList forml= lines.at(i).split(leer); |
| 15728 |
int fvix=4; |
| 15729 |
while (forml.size()>fvix){ |
| 15730 |
int m=forml.at(fvix).toInt(); |
| 15731 |
fvarCntr[m]++; |
| 15732 |
//printf("SUMP m%d fvarCntr=%d\n", m,fvarCntr.value(m)); |
| 15733 |
|
| 15734 |
fvix+=2; |
| 15735 |
} |
| 15736 |
} |
| 15737 |
break; |
| 15738 |
case 70:{//SWAT g[0] U[2] |
| 15739 |
mole.swat=0.0; |
| 15740 |
mole.exti=2.0; |
| 15741 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15742 |
if (tok.size()>1) mole.swat=tok.at(1).toDouble(); |
| 15743 |
if (tok.size()>2) mole.exti=tok.at(2).toDouble(); |
| 15744 |
} |
| 15745 |
break; |
| 15746 |
|
| 15747 |
case 71: {// SYMM |
| 15748 |
if (mole.symmCard2Code(lines.at(i).section(" ",1,130)).isEmpty()){ |
| 15749 |
lines.clear(); |
| 15750 |
return false; |
| 15751 |
} |
| 15752 |
break; |
| 15753 |
} |
| 15754 |
case 75: {// TITL |
| 15755 |
title = QString ("'%1'@ %2") |
| 15756 |
.arg(lines.at(i).section(" ",1,30).simplified()) |
| 15757 |
.arg(fn.section('/', -1)); |
| 15758 |
mole.titl=lines.at(i).section(" ",1,-1).simplified(); |
| 15759 |
break; |
| 15760 |
} |
| 15761 |
case 78: {// UNIT |
| 15762 |
editor->unitAlt = lines.at(i) ; |
| 15763 |
break; |
| 15764 |
} |
| 15765 |
case 81: {// WGHT |
| 15766 |
wghtAct->setEnabled(true); |
| 15767 |
break; |
| 15768 |
} |
| 15769 |
case 82: {// ZERR |
| 15770 |
mole.cell.Z= lines.at(i); |
| 15771 |
break; |
| 15772 |
} |
| 15773 |
case 103: {// NEUT |
| 15774 |
// qDebug()<<"Neutrons!"; |
| 15775 |
|
| 15776 |
chgl->neutrons=true; |
| 15777 |
break; |
| 15778 |
} |
| 15779 |
case 105:// BEDE |
| 15780 |
case 106:{// LONE |
| 15781 |
bedeRloneLY.append(lines.at(i)); |
| 15782 |
chgl->hideBeLo->setVisible(true); |
| 15783 |
belocube->setVisible(true); |
| 15784 |
break; |
| 15785 |
} |
| 15786 |
case -1:{//an atom or an error! |
| 15787 |
newAtom.isIso=false; |
| 15788 |
newAtom.ufiso_org=""; |
| 15789 |
if (firstAtomLine == 0) { |
| 15790 |
firstAtomLine = i; |
| 15791 |
} |
| 15792 |
if ((newAtom.afix>170)&&((newAtom.afix<180))) break; |
| 15793 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 15794 |
newAtom.part=part; |
| 15795 |
if (newAtom.resiNr<0){ |
| 15796 |
newAtom.resiNr=0; |
| 15797 |
newAtom.ResiClass=""; |
| 15798 |
} |
| 15799 |
if (tok.size()==7){ |
| 15800 |
// We have an isotropic atom! |
| 15801 |
if ((newAtom.part!=0)||(newAtom.resiNr!=0)){ |
| 15802 |
newAtom.Label=QString("%1_%3%4") |
| 15803 |
.arg(tok.at(0)) |
| 15804 |
.arg((newAtom.resiNr)?QString::number(newAtom.resiNr):"") |
| 15805 |
.arg((newAtom.part)?QString::number((newAtom.part<0)? |
| 15806 |
36+newAtom.part: |
| 15807 |
newAtom.part+9,36):""); |
| 15808 |
} else { |
| 15809 |
newAtom.Label=tok.at(0); |
| 15810 |
} |
| 15811 |
int fac=tok.at(1).toInt()-1; |
| 15812 |
newAtom.fixFlag=0; |
| 15813 |
|
| 15814 |
newAtom.an=((fac<0)||(fac>=editor->sfac.size()))?-2:editor->sfac.at(fac); |
| 15815 |
newAtom.frac.x = getNumber(tok.at(2).toDouble(),fvar,0,newAtom.fixFlag); |
| 15816 |
newAtom.frac.y = getNumber(tok.at(3).toDouble(),fvar,1,newAtom.fixFlag); |
| 15817 |
newAtom.frac.z = getNumber(tok.at(4).toDouble(),fvar,2,newAtom.fixFlag); |
| 15818 |
if (qAbs(part_fvar) > 11.0 ){ |
| 15819 |
// fvar is defined for entire part: |
| 15820 |
newAtom.sof = getNumber(part_fvar, fvar, 3, newAtom.fixFlag); |
| 15821 |
newAtom.sof_org = part_fvar; |
| 15822 |
} else { |
| 15823 |
// fvar is defined at each atom: |
| 15824 |
newAtom.sof = getNumber(tok.at(5).toDouble(), fvar, 3, newAtom.fixFlag); |
| 15825 |
newAtom.sof_org = tok.at(5).toDouble(); |
| 15826 |
} |
| 15827 |
newAtom.isIso=true; |
| 15828 |
double uIso = getNumber(tok.at(6).toDouble(),fvar,uiso); |
| 15829 |
newAtom.uf.m11 = newAtom.uf.m22 = newAtom.uf.m33 = uIso; |
| 15830 |
newAtom.uf.m32 = newAtom.uf.m23 = uIso * mole.cell.cosra; |
| 15831 |
newAtom.uf.m31 = newAtom.uf.m13 = uIso * mole.cell.cosrb; |
| 15832 |
newAtom.uf.m21 = newAtom.uf.m12 = uIso * mole.cell.cosrg; |
| 15833 |
mole.Uf2Uo(newAtom.uf, newAtom.uc); |
| 15834 |
newAtom.ufiso_org=tok.at(6); |
| 15835 |
newAtom.peakHeight=-666; |
| 15836 |
if (newAtom.an==-66) newAtom.peakHeight=9999.99; |
| 15837 |
newAtom.afixParent=-1; |
| 15838 |
if (newAtom.an>0) afixparent=quickAtoms.size(); |
| 15839 |
else newAtom.afixParent=afixparent; |
| 15840 |
quickAtoms.append(newAtom); |
| 15841 |
} |
| 15842 |
if (tok.size()==8) { |
| 15843 |
// We have a q-peak! |
| 15844 |
newAtom.Label=tok.at(0); |
| 15845 |
if (newAtom.Label.startsWith('Q',Qt::CaseInsensitive)) { |
| 15846 |
newAtom.an=-1; |
| 15847 |
newAtom.resiNr=-1; |
| 15848 |
newAtom.ResiClass="Q-Peak"; |
| 15849 |
qpeaks++; |
| 15850 |
if (!hklf) qbeforehkl=true; |
| 15851 |
} else { |
| 15852 |
int fac=tok.at(1).toInt()-1; |
| 15853 |
newAtom.an=((fac<0)||(fac>=editor->sfac.size()))?-2:editor->sfac.at(fac); |
| 15854 |
//isoat++; |
| 15855 |
} |
| 15856 |
newAtom.fixFlag=0; |
| 15857 |
newAtom.frac.x = tok.at(2).toDouble(); |
| 15858 |
newAtom.frac.y = tok.at(3).toDouble(); |
| 15859 |
newAtom.frac.z = tok.at(4).toDouble(); |
| 15860 |
if (qAbs(part_fvar) > 11.0 ){ |
| 15861 |
// fvar is defined for entire part: |
| 15862 |
newAtom.sof = getNumber(part_fvar, fvar, 3, newAtom.fixFlag); |
| 15863 |
newAtom.sof_org = part_fvar; |
| 15864 |
} else { |
| 15865 |
// fvar is defined at each atom: |
| 15866 |
newAtom.sof = getNumber(tok.at(5).toDouble(), fvar, 3, newAtom.fixFlag); |
| 15867 |
newAtom.sof_org = tok.at(5).toDouble(); |
| 15868 |
} |
| 15869 |
newAtom.isIso=true; |
| 15870 |
double uIso = getNumber(tok.at(6).toDouble(),fvar,uiso); |
| 15871 |
newAtom.uf.m11 = newAtom.uf.m22 = newAtom.uf.m33 = uIso; |
| 15872 |
newAtom.uf.m32 = newAtom.uf.m23 = uIso * mole.cell.cosra; |
| 15873 |
newAtom.uf.m31 = newAtom.uf.m13 = uIso * mole.cell.cosrb; |
| 15874 |
newAtom.uf.m21 = newAtom.uf.m12 = uIso * mole.cell.cosrg; |
| 15875 |
newAtom.ufiso_org=tok.at(6); |
| 15876 |
newAtom.peakHeight=tok.at(7).toDouble(); |
| 15877 |
//printf("##%d %f\n",qpeaks,newAtom.peakHeight); |
| 15878 |
if(newAtom.an==-1){ |
| 15879 |
mole.pmin=qMin(mole.pmin, newAtom.peakHeight); |
| 15880 |
mole.pmax=qMax(mole.pmax, newAtom.peakHeight); |
| 15881 |
} |
| 15882 |
chgl->qPeakBonds->setVisible(true); |
| 15883 |
|
| 15884 |
showQPeakLegend->setVisible(true); |
| 15885 |
newAtom.afixParent=-1; |
| 15886 |
quickAtoms.append(newAtom); |
| 15887 |
|
| 15888 |
} |
| 15889 |
if (tok.size()==12){ |
| 15890 |
// We have an ellipsoid atom! |
| 15891 |
if ((newAtom.part!=0)||(newAtom.resiNr!=0)){ |
| 15892 |
newAtom.Label=QString("%1_%3%4") |
| 15893 |
.arg(tok.at(0)) |
| 15894 |
.arg((newAtom.resiNr)?QString::number(newAtom.resiNr):"") |
| 15895 |
.arg((newAtom.part)?QString::number((newAtom.part<0)? |
| 15896 |
36+newAtom.part: |
| 15897 |
newAtom.part+9,36):""); |
| 15898 |
}else newAtom.Label=tok.at(0); |
| 15899 |
int fac=tok.at(1).toInt()-1; |
| 15900 |
newAtom.an=((fac<0)||(fac>=editor->sfac.size()))?-2:editor->sfac.at(fac); |
| 15901 |
newAtom.frac.x = getNumber(tok.at(2).toDouble(),fvar,0,newAtom.fixFlag); |
| 15902 |
newAtom.frac.y = getNumber(tok.at(3).toDouble(),fvar,1,newAtom.fixFlag); |
| 15903 |
newAtom.frac.z = getNumber(tok.at(4).toDouble(),fvar,2,newAtom.fixFlag); |
| 15904 |
if (qAbs(part_fvar) > 11.0 ){ |
| 15905 |
// fvar is defined for entire part: |
| 15906 |
newAtom.sof = getNumber(part_fvar, fvar, 3, newAtom.fixFlag); |
| 15907 |
newAtom.sof_org = part_fvar; |
| 15908 |
} else { |
| 15909 |
// fvar is defined at each atom: |
| 15910 |
newAtom.sof = getNumber(tok.at(5).toDouble(), fvar, 3, newAtom.fixFlag); |
| 15911 |
newAtom.sof_org = tok.at(5).toDouble(); |
| 15912 |
} |
| 15913 |
newAtom.uf.m11 = getNumber(tok.at(6).toDouble(),fvar,4,newAtom.fixFlag); |
| 15914 |
newAtom.uf.m22 = getNumber(tok.at(7).toDouble(),fvar,5,newAtom.fixFlag); |
| 15915 |
newAtom.uf.m33 = getNumber(tok.at(8).toDouble(),fvar,6,newAtom.fixFlag); |
| 15916 |
newAtom.uf.m32 = newAtom.uf.m23 = getNumber(tok.at(9).toDouble(),fvar,7,newAtom.fixFlag); |
| 15917 |
newAtom.uf.m31 = newAtom.uf.m13 = getNumber(tok.at(10).toDouble(),fvar,8,newAtom.fixFlag); |
| 15918 |
newAtom.uf.m21 = newAtom.uf.m12 = getNumber(tok.at(11).toDouble(),fvar,9,newAtom.fixFlag); |
| 15919 |
newAtom.peakHeight=-666; |
| 15920 |
uiso=mole.ueq(newAtom.uf); |
| 15921 |
if (newAtom.an>0) afixparent=quickAtoms.size(); |
| 15922 |
newAtom.afixParent=-1; |
| 15923 |
quickAtoms.append(newAtom); |
| 15924 |
//adpat++; |
| 15925 |
} |
| 15926 |
} |
| 15927 |
break; |
| 15928 |
} |
| 15929 |
|
| 15930 |
|
| 15931 |
} |
| 15932 |
|
| 15933 |
} |
| 15934 |
int lnrr=0; |
| 15935 |
CEnvironment belo; |
| 15936 |
//printf("belo: %d\n",bedeRloneLY.size()); |
| 15937 |
for (int bl=0; bl<bedeRloneLY.size(); bl++){ |
| 15938 |
int ignore=0; |
| 15939 |
QStringList tok = bedeRloneLY.at(bl).split(leer,skipEmptyParts); |
| 15940 |
//printf("belo: %s\n",tok.at(0).toStdString().c_str()); |
| 15941 |
if ((tok.at(0).endsWith("BEDE",Qt::CaseInsensitive))&&(tok.size()>6)){ |
| 15942 |
lnrr=belo.size(); |
| 15943 |
QString aton1=tok.at(1),aton2=tok.at(2); |
| 15944 |
double rad = getNumber(tok.at(3).toDouble(),fvar,0,ignore); |
| 15945 |
double a = getNumber(tok.at(4).toDouble(),fvar,0,ignore); |
| 15946 |
double b1 = getNumber(tok.at(5).toDouble(),fvar,0,ignore); |
| 15947 |
double b2 = getNumber(tok.at(6).toDouble(),fvar,0,ignore); |
| 15948 |
newAtom.an=-42; |
| 15949 |
newAtom.symmGroup=0; |
| 15950 |
newAtom.sg=0; |
| 15951 |
newAtom.scod=555;//the identity |
| 15952 |
newAtom.auidx=-1; |
| 15953 |
int an1=-1,an2=-2; |
| 15954 |
for (int bl1=0; bl1<mole.asymm.size(); bl1++) |
| 15955 |
for (int bl2=0; bl2<mole.asymm.size(); bl2++){ |
| 15956 |
if ((mole.asymm.at(bl1).an<0)||(mole.asymm.at(bl2).an<0)) continue; |
| 15957 |
double soll=-1,d= sqrt(Distance(mole.asymm.at(bl1).pos,mole.asymm.at(bl2).pos)); |
| 15958 |
if ((mole.asymm.at(bl1).an==0)&&(mole.asymm.at(bl2).an==0)) continue; |
| 15959 |
if ((mole.asymm.at(bl1).an>-1)&&(mole.asymm.at(bl2).an>-1)&& |
| 15960 |
((!mole.asymm.at(bl1).part)||(!mole.asymm.at(bl2).part)||(mole.asymm.at(bl1).part==mole.asymm.at(bl2).part))) |
| 15961 |
soll=(mole.Kovalenz_Radien[mole.asymm.at(bl1).an]+ mole.Kovalenz_Radien[mole.asymm.at(bl2).an])*0.012; |
| 15962 |
else |
| 15963 |
soll=-1; |
| 15964 |
if ((d>0.1)&&(d<soll)) { |
| 15965 |
an1=-1; |
| 15966 |
an2=-2; |
| 15967 |
if (aton1[0]=='$') an1=mole.getOZ(aton1); |
| 15968 |
if (aton2[0]=='$') an2=mole.getOZ(aton2); |
| 15969 |
if (((an1>=0)&&(mole.asymm.at(bl1).an==an1))||(aton1==mole.asymm.at(bl1).Label.section('_',0,0))) |
| 15970 |
if (((an2>=0)&&(mole.asymm.at(bl2).an==an2))||(aton2==mole.asymm.at(bl2).Label.section('_',0,0))){ |
| 15971 |
V3 pos = mole.asymm.at(bl1).pos+Normalize(mole.asymm.at(bl2).pos-mole.asymm.at(bl1).pos)*rad; |
| 15972 |
newAtom.pos=pos; |
| 15973 |
mole.kart2frac(pos,pos); |
| 15974 |
newAtom.Label=QString("L%1").arg(++lnrr); |
| 15975 |
newAtom.frac=pos; |
| 15976 |
newAtom.peakHeight=b1; |
| 15977 |
newAtom.sof=a; |
| 15978 |
newAtom.auidx=-1; |
| 15979 |
newAtom.uf=mole.u2b(mole.asymm.at(bl1).uf);//posible problem if U is not anisotrop |
| 15980 |
belo.append(newAtom); |
| 15981 |
pos=mole.asymm.at(bl1).frac; |
| 15982 |
newAtom.Label=QString("L%1").arg(++lnrr); |
| 15983 |
newAtom.frac=mole.asymm.at(bl1).frac; |
| 15984 |
mole.frac2kart(newAtom.frac,newAtom.pos); |
| 15985 |
newAtom.sof=-a; |
| 15986 |
newAtom.peakHeight=b2; |
| 15987 |
belo.append(newAtom); |
| 15988 |
|
| 15989 |
mole.lmin=qMin(mole.lmin,-a); |
| 15990 |
mole.lmax=qMax(mole.lmax, a); |
| 15991 |
|
| 15992 |
} |
| 15993 |
} |
| 15994 |
} |
| 15995 |
|
| 15996 |
}else |
| 15997 |
if (tok.at(0).endsWith("LONE",Qt::CaseInsensitive)){ |
| 15998 |
belo.append(lonesome(bedeRloneLY.at(bl),belo.size()+1)); |
| 15999 |
} |
| 16000 |
} |
| 16001 |
if (!belo.isEmpty()) { |
| 16002 |
for (int bl=0; bl<belo.size(); bl++){ |
| 16003 |
belo[bl].orginalLine=QString("%1 2 %2 %3 %4").arg(belo.at(bl).Label.section('_',0,0),-4) |
| 16004 |
.arg(belo.at(bl).frac.x,10,'f',5) |
| 16005 |
.arg(belo.at(bl).frac.y,10,'f',5) |
| 16006 |
.arg(belo.at(bl).frac.z,10,'f',5); |
| 16007 |
} |
| 16008 |
quickAtoms.append(belo); |
| 16009 |
} |
| 16010 |
//printf("qck %d au %d\n",quickAtoms.size(),mole.asymm.size()); |
| 16011 |
for (int i=0;i<quickAtoms.size();i++){ |
| 16012 |
mole.Uf2Uo(quickAtoms.at(i).uf,quickAtoms[i].uc); |
| 16013 |
mole.frac2kart(quickAtoms.at(i).frac,quickAtoms[i].pos); |
| 16014 |
} |
| 16015 |
if (quickAtoms.size()>mole.asymm.size()){ |
| 16016 |
int osiz=mole.asymm.size(); |
| 16017 |
for (int k=osiz;k<quickAtoms.size();k++){ |
| 16018 |
mole.showatoms.insert(k,quickAtoms[k]); |
| 16019 |
} |
| 16020 |
} |
| 16021 |
//printf("qck %d au %d\n",quickAtoms.size(),mole.asymm.size()); |
| 16022 |
if (quickAtoms.size()<mole.asymm.size()){ |
| 16023 |
mole.asymm.clear(); |
| 16024 |
quickAtoms.clear(); |
| 16025 |
//printf("number of atoms differs too much!\n"); |
| 16026 |
lines.clear(); |
| 16027 |
return false; |
| 16028 |
} |
| 16029 |
mole.asymm.clear(); |
| 16030 |
for (int i=0; i<quickAtoms.size(); i++){ |
| 16031 |
mole.asymm.append(quickAtoms[i]); |
| 16032 |
} |
| 16033 |
//mole.asymm=quickAtoms; |
| 16034 |
//printf("X-\n"); |
| 16035 |
for (int i=0; i<mole.showatoms.size(); i++){ |
| 16036 |
int idx=0; |
| 16037 |
if ((mole.showatoms.at(i).auidx<0)||(mole.showatoms.at(i).auidx>quickAtoms.size())){ |
| 16038 |
idx=i; |
| 16039 |
/* printf("AU:%s=%s %d=%d %f %f %f %f %f %f\n",mole.showatoms.at(i).Label.toStdString().c_str(),quickAtoms.at(idx).Label.toStdString().c_str(), |
| 16040 |
mole.showatoms.at(i).scod,quickAtoms.at(i).scod, |
| 16041 |
mole.showatoms.at(i).pos.x,mole.showatoms.at(i).pos.y,mole.showatoms.at(i).pos.z, |
| 16042 |
quickAtoms.at(i).pos.x,quickAtoms.at(i).pos.y,quickAtoms.at(i).pos.z |
| 16043 |
);*/ |
| 16044 |
} |
| 16045 |
else idx=mole.showatoms.at(i).auidx; |
| 16046 |
if (idx>=quickAtoms.size()) continue; |
| 16047 |
//printf("quickAtoms %s %d %d %d %d %s\n",mole.showatoms.at(i).Label.toStdString().c_str(),i,idx,quickAtoms.size(),mole.showatoms.size(),quickAtoms.at(idx).Label.toStdString().c_str()); |
| 16048 |
V3 actpos = mole.applySymCode(quickAtoms.at(idx).frac,mole.showatoms.at(i).scod); |
| 16049 |
//printf("#%-4d %d %d %d %d %g\n",i,mole.showatoms.at(i).symmGroup,mole.showatoms.at(i).sg,mole.showatoms.at(i).scod,mole.showatoms.at(i).hidden,Distance(actpos,mole.showatoms.at(i).frac)); |
| 16050 |
mole.showatoms[i].frac = actpos; |
| 16051 |
mole.showatoms[i].isIso = quickAtoms.at(idx).isIso; |
| 16052 |
if (mole.showatoms.at(i).scod==555){ |
| 16053 |
mole.showatoms[i].orginalLine = quickAtoms.at(idx).orginalLine; |
| 16054 |
mole.showatoms[i].Label = quickAtoms.at(idx).Label; |
| 16055 |
} |
| 16056 |
//printf("tick %d scod%d %d %d\n",__LINE__,mole.showatoms.at(i).scod,i,idx); |
| 16057 |
///printf("%f %f\n",mole.showatoms[i].peakHeight , quickAtoms.at(idx).peakHeight); |
| 16058 |
if (quickAtoms[idx].an>=0){ |
| 16059 |
mole.USymCode(quickAtoms[idx].uf,mole.showatoms.at(i).scod,mole.showatoms[i].uf); |
| 16060 |
//printf("tick %d\n",__LINE__); |
| 16061 |
mole.Uf2Uo(mole.showatoms[i].uf,mole.showatoms[i].uc); |
| 16062 |
} |
| 16063 |
mole.showatoms[i].peakHeight = quickAtoms.at(idx).peakHeight; |
| 16064 |
//printf("tick %d\n",__LINE__); |
| 16065 |
mole.showatoms[i].part = quickAtoms.at(idx).part; |
| 16066 |
mole.showatoms[i].an = quickAtoms.at(idx).an; |
| 16067 |
//printf("tick %d\n",__LINE__); |
| 16068 |
mole.showatoms[i].resiNr= quickAtoms.at(idx).resiNr; |
| 16069 |
//printf("tick %d\n",__LINE__); |
| 16070 |
mole.showatoms[i].auidx = idx; |
| 16071 |
//printf("tick %d\n",__LINE__); |
| 16072 |
mole.showatoms[i].sof = quickAtoms.at(idx).sof; |
| 16073 |
//printf("tick %d\n",__LINE__); |
| 16074 |
mole.showatoms[i].sof_org = quickAtoms.at(idx).sof_org; |
| 16075 |
//printf("tick %d\n",__LINE__); |
| 16076 |
mole.showatoms[i].screenX = quickAtoms.at(idx).screenX; |
| 16077 |
//printf("tick %d\n",__LINE__); |
| 16078 |
mole.showatoms[i].screenY = quickAtoms.at(idx).screenY; |
| 16079 |
//printf("tick %d\n",__LINE__); |
| 16080 |
mole.showatoms[i].afix = quickAtoms.at(idx).afix; |
| 16081 |
//printf("tick %d\n",__LINE__); |
| 16082 |
mole.frac2kart(actpos,mole.showatoms[i].pos); |
| 16083 |
//printf("tick %d\n",__LINE__); |
| 16084 |
} |
| 16085 |
//printf("x\n"); |
| 16086 |
|
| 16087 |
chgl->shpm1->setVisible(false); |
| 16088 |
chgl->highlightParts->setVisible(false); |
| 16089 |
if (minp<0) { |
| 16090 |
chgl->shpm1->setVisible(true); |
| 16091 |
chgl->highlightParts->setVisible(true); |
| 16092 |
} |
| 16093 |
if (maxp>0) chgl->highlightParts->setVisible(true); |
| 16094 |
mole.qbeforehkl=qbeforehkl; |
| 16095 |
actionUniq->setDisabled(mole.qbeforehkl); |
| 16096 |
QString info; |
| 16097 |
for (int ifv=0; ifv<fvar.size();ifv++){ |
| 16098 |
if (ifv==0) { |
| 16099 |
info.append("OSF: "); |
| 16100 |
info.append(QString("<font color=red>%1</font>").arg(fvar.at(ifv))); |
| 16101 |
} |
| 16102 |
else { |
| 16103 |
info.append(QString("FVAR<font color=blue>%1</font>: ").arg(ifv+1)); |
| 16104 |
if (fvarCntr.value(ifv+1)<1)info.append(QString("<font color=red>%1</font>(Never Used!)").arg(fvar.at(ifv))); |
| 16105 |
else info.append(QString("<font color=red>%1</font>(used %2 time%3.)").arg(fvar.at(ifv)) |
| 16106 |
.arg(fvarCntr.value(ifv+1)).arg((fvarCntr.value(ifv+1)>1)?"s":"")); |
| 16107 |
} |
| 16108 |
if ((ifv+1)<fvar.size()) info.append(", "); |
| 16109 |
info.append("<br>"); |
| 16110 |
} |
| 16111 |
fvarinfo=QString("<b>Free variables:</b> %1").arg(info); |
| 16112 |
qpv->setMin(mole.pmin); |
| 16113 |
qpv->setMax(mole.pmax); |
| 16114 |
//printf("%f %f\n",mole.pmin,mole.pmax); |
| 16115 |
|
| 16116 |
qpv->update(); |
| 16117 |
for (int i=0; i<mole.showatoms.size(); i++){ |
| 16118 |
if (mole.showatoms.at(i).an!=-1) continue; |
| 16119 |
if (mole.showatoms.at(i).peakHeight>mole.pmax) {printf("remove q %d %d %s %f %f max\n",i,mole.showatoms.at(i).an,mole.showatoms.at(i).Label.toStdString().c_str(),mole.showatoms.at(i).peakHeight,mole.pmax); mole.showatoms.removeAt(i); i--; i=(i<0)?0:i;} |
| 16120 |
} |
| 16121 |
for (int i=0; i<mole.showatoms.size(); i++){ |
| 16122 |
if (mole.showatoms.at(i).an!=-1) continue; |
| 16123 |
if (mole.showatoms.at(i).peakHeight<mole.pmin) {printf("remove q %d %d %s %f %f min\n",i,mole.showatoms.at(i).an,mole.showatoms.at(i).Label.toStdString().c_str(),mole.showatoms.at(i).peakHeight,mole.pmin); mole.showatoms.removeAt(i); i--; i=(i<0)?0:i;} |
| 16124 |
} |
| 16125 |
updateStatusBar("finding bonds..."); |
| 16126 |
mole.showbonds.clear(); |
| 16127 |
mole.showbonds = mole.connecting(mole.showatoms); |
| 16128 |
if (qpeaks) qPeakDock->show(); |
| 16129 |
//QTime zeit; zeit.start(); |
| 16130 |
//printf("MAPS?\n"); |
| 16131 |
fxle->resDir=QDir(fn); |
| 16132 |
fxle->fouName=(fxle->MYFCF)?s.myfcf(fn):""; |
| 16133 |
if (fxle->fouName.isEmpty()){ |
| 16134 |
fxle->fouName=fn; |
| 16135 |
fxle->fouName.chop(4); |
| 16136 |
fxle->fouName.append(".fcf"); |
| 16137 |
} |
| 16138 |
|
| 16139 |
if ((fxle->doMaps->isChecked())&& (!fxle->loadFouAndPerform(fxle->fouName.toLocal8Bit()))) { |
| 16140 |
if (fxle->doMaps->isChecked()) infoKanalNews(QString("<font color=red>Error while loading %1!</font><br>").arg(fxle->fouName)); |
| 16141 |
|
| 16142 |
//printf("%d\n",__LINE__); |
| 16143 |
fxle->killmaps(); |
| 16144 |
//printf("%d\n",__LINE__); |
| 16145 |
fxle->n1=fxle->n2=fxle->n3=fxle->n5=0; |
| 16146 |
} |
| 16147 |
if (fxle->doMaps->isChecked()){ |
| 16148 |
fxle->mapcontrol->setVisible(true); |
| 16149 |
} |
| 16150 |
fxle->doMaps->show(); |
| 16151 |
//printf("MAPS!\n"); |
| 16152 |
QString listName=fn; |
| 16153 |
listName.replace(punktins,".lst"); |
| 16154 |
listName.replace(punktres,".lst"); |
| 16155 |
QFile lstf(listName); |
| 16156 |
if (lstf.open(QIODevice::ReadOnly|QIODevice::Text)){ |
| 16157 |
QString liste=QString(lstf.readAll()); |
| 16158 |
while (liste.contains(QRegularExpression("\n\\s+REM"))) liste=liste.replace(QRegularExpression("\n\\s+REM[^\n]*\n",QRegularExpression::CaseInsensitiveOption),"\n"); |
| 16159 |
if (liste.contains("Flack x parameter =")){ |
| 16160 |
QString flackS=liste.section("Flack x parameter =",1).section('\n',0,0); |
| 16161 |
double flackX=flackS.split(leer,skipEmptyParts).first().toDouble(); |
| 16162 |
double flackXesd=flackS.split(leer,skipEmptyParts).last().toDouble(); |
| 16163 |
infoKanalNews(QString("SHELXL-list file reports <b>Flack</b> x parameter:<b> %1 ± %2</b>").arg(flackX).arg(flackXesd)); |
| 16164 |
} |
| 16165 |
//Flack x = |
| 16166 |
if (liste.contains("Flack x =")) { |
| 16167 |
QString flackS=liste.section("\n Flack x = ",1).section('\n',0,1); |
| 16168 |
QString flackX = ""; |
| 16169 |
// prevent crash from empty flackS: |
| 16170 |
if (flackS.split(leer,skipEmptyParts).length() > 0) { |
| 16171 |
flackX=flackS.split(leer,skipEmptyParts).first(); |
| 16172 |
} |
| 16173 |
QString parsonsZ=flackS.section('\n',1,1); |
| 16174 |
if (parsonsZ.isEmpty() && !flackX.isEmpty()) { |
| 16175 |
infoKanalNews(QString("SHELXL-list file reports <b>Flack</b> x parameter:<b> %1 </b>").arg(flackX)); |
| 16176 |
} |
| 16177 |
if (!parsonsZ.isEmpty() && !flackX.isEmpty()) { |
| 16178 |
parsonsZ=parsonsZ.split(leer,skipEmptyParts).first(); |
| 16179 |
infoKanalNews(QString("SHELXL-list file reports <br><b>Flack</b> x parameter:<b> %1 </b><br><b>Parsons</b> parameter:<b> %2</b>") |
| 16180 |
.arg(flackX).arg(parsonsZ)); |
| 16181 |
} |
| 16182 |
} |
| 16183 |
lstf.close(); |
| 16184 |
} |
| 16185 |
QMap<QString,double> unit; |
| 16186 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 16187 |
QStringList ol = mole.asymm.at(i).orginalLine.split(' ',skipEmptyParts,Qt::CaseInsensitive); |
| 16188 |
QString smbl="!!"; |
| 16189 |
if (ol.size()>1) smbl=editor->sfacsmbl.at(ol.at(1).toInt()); |
| 16190 |
if (mole.asymm.at(i).an>=0) { |
| 16191 |
unit[smbl]+= mole.asymm.at(i).sof * mole.cell.symmops.size(); |
| 16192 |
//printf("%s %f ;-)\n",smbl.toStdString().c_str(),unit.value(smbl)); |
| 16193 |
} |
| 16194 |
} |
| 16195 |
editor->unitNeu="UNIT"; |
| 16196 |
for (int i = 0; i < editor->sfacsmbl.size() ; i++){ |
| 16197 |
if (unit.value(editor->sfacsmbl.at(i))>9999) |
| 16198 |
editor->unitNeu.append(QString(" %1").arg((int)unit.value(editor->sfacsmbl.at(i)))); else |
| 16199 |
editor->unitNeu.append(QString(" %1").arg(unit.value(editor->sfacsmbl.at(i)),0,'g')); |
| 16200 |
if (editor->unitNeu.split('\n').last().size()>76) editor->unitNeu.append("=\n "); |
| 16201 |
} |
| 16202 |
//printf("EX %d\n",__LINE__); |
| 16203 |
//return false; |
| 16204 |
return true; |
| 16205 |
} |
| 16206 |
|
| 16207 |
void Window::load_sheldrick(QString fileName, QString &inhalt){ |
| 16208 |
//! Parses the SHELX res/ins file into data structures. |
| 16209 |
if (quickReLoadButton->isChecked())if (quickReLoad(fileName, inhalt)) return;// if quickreload works then here is nothing to do |
| 16210 |
//printf("%d\n",__LINE__); |
| 16211 |
fxle->killmaps(); |
| 16212 |
//printf("%d\n",__LINE__); |
| 16213 |
fxle->n5=0; |
| 16214 |
symmElementsAct->setChecked(false); |
| 16215 |
symmElements(false); |
| 16216 |
mole.newstructure(); |
| 16217 |
switch2HKLF4->setVisible(false); |
| 16218 |
chgl->showHidden(); |
| 16219 |
machPlatz=false; |
| 16220 |
chgl->neutrons=false; |
| 16221 |
static QString maidenName=""; |
| 16222 |
infoKanal->clear(); |
| 16223 |
shxEditorDock->show(); |
| 16224 |
wghtAct->setEnabled(false); |
| 16225 |
QString problem; |
| 16226 |
qPeakDock->hide(); |
| 16227 |
|
| 16228 |
int minp=1,maxp=0; |
| 16229 |
bool qbeforehkl=false,hklf=false; |
| 16230 |
enterRenameMode->setVisible(true); |
| 16231 |
chgl->qPeakBonds->setVisible(false); |
| 16232 |
chgl->shpm1->setVisible(false); |
| 16233 |
chgl->hideHydrogen->setVisible(false); |
| 16234 |
chgl->hideBeLo->setVisible(false); |
| 16235 |
belocube->setVisible(false); |
| 16236 |
mole.cell.symmops.clear(); |
| 16237 |
mole.cell.trans.clear(); |
| 16238 |
mole.asymm.clear(); |
| 16239 |
mole.sdm.clear(); |
| 16240 |
mole.showbonds.clear(); |
| 16241 |
mole.showatoms.clear(); |
| 16242 |
mole.selectedatoms.clear(); |
| 16243 |
|
| 16244 |
mole.lbonds.clear(); |
| 16245 |
mole.envi_sdm.clear(); |
| 16246 |
mole.contact.clear(); |
| 16247 |
mole.envi_sdm.clear(); |
| 16248 |
mole.contact.clear(); |
| 16249 |
mole.symmopsEQIV.clear(); |
| 16250 |
mole.labelEQIV.clear(); |
| 16251 |
mole.transEQIV.clear(); |
| 16252 |
mole.freeatoms.clear(); |
| 16253 |
mole.bindatoms.clear(); |
| 16254 |
for (int i=0; i<mole.knoepfe.size();i++) mole.knoepfe[i].neighbors.clear(); |
| 16255 |
mole.knoepfe.clear(); |
| 16256 |
mole.showbonds.clear(); |
| 16257 |
mole.selectedatoms.clear(); |
| 16258 |
chgl->updateBondActions(); |
| 16259 |
mole.showatoms.clear(); |
| 16260 |
V3 nl(0,0,0); |
| 16261 |
QStringList bedeRloneLY; |
| 16262 |
mole.cell.trans.append(nl); |
| 16263 |
mole.cell.symmops.append(Matrix(1,0,0, 0,1,0, 0,0,1)); |
| 16264 |
mole.pmin=10000; |
| 16265 |
mole.pmax=-10000; |
| 16266 |
mole.lmin=10000; |
| 16267 |
mole.lmax=-10000; |
| 16268 |
firstAtomLine = 0; |
| 16269 |
ls_cycls = 0; |
| 16270 |
editor->fvMinLine = 0; // otherwise it does not recognize a moving fvar line |
| 16271 |
MyAtom newAtom; |
| 16272 |
newAtom.part=0; |
| 16273 |
newAtom.resiNr=0; |
| 16274 |
newAtom.hidden=0; |
| 16275 |
newAtom.symmGroup=0; |
| 16276 |
newAtom.sg=0; |
| 16277 |
newAtom.scod=555;//the identity |
| 16278 |
newAtom.auidx=-1; |
| 16279 |
newAtom.sof=0; |
| 16280 |
newAtom.sof_org=0; |
| 16281 |
newAtom.screenX=0; |
| 16282 |
newAtom.screenY=0; |
| 16283 |
newAtom.afix=0; |
| 16284 |
//bool virg=true; |
| 16285 |
if (maidenName!=fileName) { |
| 16286 |
labelIndex=1; |
| 16287 |
nextLabel="C1"; |
| 16288 |
labelPSE="C"; |
| 16289 |
pserbt[6]->setChecked(true); |
| 16290 |
renamDock->hide(); |
| 16291 |
updateLabel(); |
| 16292 |
}else{ |
| 16293 |
//virg=false; |
| 16294 |
} |
| 16295 |
maidenName=fileName; |
| 16296 |
int part=0,afix=0; |
| 16297 |
double part_fvar=11.0; |
| 16298 |
double uiso=0.05; |
| 16299 |
int lattice=1; |
| 16300 |
//int isoat=0, |
| 16301 |
int adpat=0,qpeaks=0; |
| 16302 |
int afixparent=0; |
| 16303 |
mole.exti=-666.0; |
| 16304 |
mole.swat=-666.0; |
| 16305 |
editor->sfac.clear(); |
| 16306 |
editor->sfacsmbl.clear(); |
| 16307 |
fvar.clear(); |
| 16308 |
chgl->sfacMenu->clear(); |
| 16309 |
chgl->selSfacMenu->clear(); |
| 16310 |
MyAtom xda; |
| 16311 |
xda.symmGroup=0; |
| 16312 |
xda.sg=0; |
| 16313 |
xda.scod=555;//the identity |
| 16314 |
xda.auidx=-1; |
| 16315 |
xda.hidden=0; |
| 16316 |
xda.isIso=false; |
| 16317 |
xda.part=0; |
| 16318 |
xda.Label="H"; |
| 16319 |
xda.pos.x=-2.75; |
| 16320 |
xda.pos.y=-6.8; |
| 16321 |
xda.pos.z=0; |
| 16322 |
xda.an=5; |
| 16323 |
xda.peakHeight=0.02; |
| 16324 |
xda.uc=Matrix( |
| 16325 |
0.01773,-0.00303, 0.00266, |
| 16326 |
-0.00303, 0.01456, 0.00172, |
| 16327 |
0.00266, 0.00172, 0.01110); |
| 16328 |
mole.legendAtoms.clear(); |
| 16329 |
// |
| 16330 |
mole.osf=0.0; |
| 16331 |
mole.hklScale=mole.hklSigmaScale=1.0; |
| 16332 |
mole.hklMat=Matrix(1,0,0,0,1,0,0,0,1); |
| 16333 |
mole.hklOmitSig=-2; |
| 16334 |
mole.hklOmit2th=180.0; |
| 16335 |
mole.hklShellLow=99999.0; |
| 16336 |
mole.hklShellHig=0.0; |
| 16337 |
fvarCntr.clear(); |
| 16338 |
mole.transEQIV.clear(); |
| 16339 |
mole.symmopsEQIV.clear(); |
| 16340 |
mole.labelEQIV.clear(); |
| 16341 |
mole.freeatoms.clear(); |
| 16342 |
mole.bindatoms.clear(); |
| 16343 |
mole.envi_sdm.clear(); |
| 16344 |
mole.bindPart.clear(); |
| 16345 |
Scatt s(&mole); |
| 16346 |
editor->easf.clear(); |
| 16347 |
editor->easf = s.loadElectronScatteringFactors(); |
| 16348 |
editor->xasf.clear(); |
| 16349 |
|
| 16350 |
editor->xasf =s.loadXRayScatteringFactors(); |
| 16351 |
chgl->labs.clear(); |
| 16352 |
chgl->enviPositions.clear(); |
| 16353 |
for (int i=1; i<109; i++) pserbt[i]->hide(); |
| 16354 |
pserbt[110]->hide(); |
| 16355 |
if (notRefine) lattice=-1; |
| 16356 |
// Disabled SkipEmptyParts because otherwise i is not in sync with the line number! |
| 16357 |
QStringList lines = inhalt.split(QRegularExpression("[\\r\\n]")); //,skipEmptyParts); |
| 16358 |
bool fragIgnore=false; |
| 16359 |
for (int i=0; i<lines.size(); i++){ |
| 16360 |
if (lines.at(i).startsWith(" ")) continue; |
| 16361 |
if (!lines.at(i).isEmpty()){ |
| 16362 |
newAtom.orginalLine=lines.at(i).section("=",0,0); |
| 16363 |
lines[i].remove("="); |
| 16364 |
int cmd=isacommand(lines.at(i).section(leer,0,0)); |
| 16365 |
//qDebug()<<cmd<<lines.at(i); |
| 16366 |
QString resiSpez=lines.at(i).section(leer,0,0).section('_',1,1); |
| 16367 |
if (cmd==30) fragIgnore=true; |
| 16368 |
if (cmd==27) fragIgnore=false; |
| 16369 |
if (!fragIgnore) |
| 16370 |
switch (cmd) { |
| 16371 |
case 1: //AFIX |
| 16372 |
afix=lines.at(i).section(leer,1,1).toInt(); |
| 16373 |
// For later |
| 16374 |
//afix_fvar = lines.at(i).section(leer,3,3).toInt(); |
| 16375 |
newAtom.afix=afix; |
| 16376 |
break; |
| 16377 |
case 5: {//bind |
| 16378 |
if (!lines.at(i).section(leer,1,2).contains(buchstaben)){ |
| 16379 |
int pn01=0,pn02=0; |
| 16380 |
bool ok1,ok2; |
| 16381 |
pn01=lines.at(i).section(leer,1,1).toInt(&ok1); |
| 16382 |
pn02=lines.at(i).section(leer,2,2).toInt(&ok2); |
| 16383 |
if ((ok1)&&(ok2)) mole.bindPart[pn01]=pn02; |
| 16384 |
if ((ok1)&&(ok2)) mole.bindPart[pn02]=pn01; |
| 16385 |
} |
| 16386 |
if (notRefine) break; |
| 16387 |
MyBind aa; |
| 16388 |
aa.Lab1=lines.at(i).section(leer,1,1).toUpper(); |
| 16389 |
aa.Lab2=lines.at(i).section(leer,2,2).toUpper(); |
| 16390 |
mole.bindatoms.append(aa); |
| 16391 |
} |
| 16392 |
break; |
| 16393 |
case 9: { //CELL |
| 16394 |
CurrentCellString=lines.at(i); |
| 16395 |
mole.cell.wave = lines.at(i).section(leer,1,1).toDouble(); |
| 16396 |
mole.cell.a = lines.at(i).section(leer,2,2).toDouble(); |
| 16397 |
mole.cell.b = lines.at(i).section(leer,3,3).toDouble(); |
| 16398 |
mole.cell.c = lines.at(i).section(leer,4,4).toDouble(); |
| 16399 |
mole.cell.al= lines.at(i).section(leer,5,5).toDouble(); |
| 16400 |
mole.cell.be = lines.at(i).section(leer,6,6).toDouble(); |
| 16401 |
mole.cell.ga = lines.at(i).section(leer,7,7).toDouble(); |
| 16402 |
mole.cellSetup(); |
| 16403 |
} |
| 16404 |
break; |
| 16405 |
case 10: { // L.S. |
| 16406 |
ls_cycls = lines.at(i).section(leer, 1, 1).toInt(); |
| 16407 |
} |
| 16408 |
break; |
| 16409 |
case 19:{//DISP |
| 16410 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16411 |
s.setDISP(tok); |
| 16412 |
} |
| 16413 |
break; |
| 16414 |
|
| 16415 |
case 23:{ //EQIV |
| 16416 |
mole.decodeSymmCardEQIV(lines.at(i)); |
| 16417 |
} |
| 16418 |
break; |
| 16419 |
case 25:{//EXTI |
| 16420 |
mole.exti=lines.at(i).section(leer,1,1).toDouble(); |
| 16421 |
} |
| 16422 |
break; |
| 16423 |
case 31:{//free |
| 16424 |
MyBind aa; |
| 16425 |
aa.Lab1=lines.at(i).section(leer,1,1).toUpper(); |
| 16426 |
aa.Lab2=lines.at(i).section(leer,2,2).toUpper(); |
| 16427 |
mole.freeatoms.append(aa); |
| 16428 |
} |
| 16429 |
break; |
| 16430 |
case 32:{ //FVAR |
| 16431 |
editor->fvMinLine=i; |
| 16432 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16433 |
for (int ifv=1; ifv<tok.size();ifv++){ |
| 16434 |
fvar.append(tok.at(ifv).toDouble()); |
| 16435 |
} |
| 16436 |
if (!fvar.isEmpty()) { |
| 16437 |
mole.osf=fvar.at(0); |
| 16438 |
} |
| 16439 |
} |
| 16440 |
break; |
| 16441 |
case 35: //HKLF |
| 16442 |
{ |
| 16443 |
hklf=true; |
| 16444 |
newAtom.afix=afix=0; |
| 16445 |
part=0; |
| 16446 |
newAtom.resiNr=0; |
| 16447 |
newAtom.ResiClass=""; |
| 16448 |
part_fvar=0.0; |
| 16449 |
|
| 16450 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16451 |
if (tok.size()>1){ |
| 16452 |
mole.hklf=tok.at(1).toInt(); |
| 16453 |
if (mole.hklf==5){ |
| 16454 |
switch2HKLF5->setVisible(false); |
| 16455 |
switch2HKLF4->setVisible(true); |
| 16456 |
} |
| 16457 |
//printf("HKLF !! %d %d %d\n",mole.hklf,switch2HKLF4->isVisible(),switch2HKLF5->isVisible()); |
| 16458 |
} |
| 16459 |
if (tok.size()>2)mole.hklScale=tok.at(2).toDouble(); |
| 16460 |
if (tok.size()>11){ |
| 16461 |
mole.hklMat.m11=tok.at(3).toDouble(); |
| 16462 |
mole.hklMat.m12=tok.at(4).toDouble(); |
| 16463 |
mole.hklMat.m13=tok.at(5).toDouble(); |
| 16464 |
mole.hklMat.m21=tok.at(6).toDouble(); |
| 16465 |
mole.hklMat.m22=tok.at(7).toDouble(); |
| 16466 |
mole.hklMat.m23=tok.at(8).toDouble(); |
| 16467 |
mole.hklMat.m31=tok.at(9).toDouble(); |
| 16468 |
mole.hklMat.m32=tok.at(10).toDouble(); |
| 16469 |
mole.hklMat.m33=tok.at(11).toDouble(); |
| 16470 |
|
| 16471 |
} |
| 16472 |
if (tok.size()>12)mole.hklSigmaScale=tok.at(12).toDouble(); |
| 16473 |
/* printf("HKLF N=%d s:%g \n%g %g %g\n%g %g %g\n%g %g %g\nsm: %g \n",mole.hklf,mole.hklScale , |
| 16474 |
mole.hklMat.m11,mole.hklMat.m12,mole.hklMat.m13, |
| 16475 |
mole.hklMat.m21,mole.hklMat.m22,mole.hklMat.m23, |
| 16476 |
mole.hklMat.m31,mole.hklMat.m32,mole.hklMat.m33, |
| 16477 |
mole.hklSigmaScale);*/ |
| 16478 |
|
| 16479 |
} |
| 16480 |
break; |
| 16481 |
case 41: { //LATT |
| 16482 |
lattice=lines.at(i).section(leer,1,1).toInt(); |
| 16483 |
break; |
| 16484 |
} |
| 16485 |
case 44: { // CGLS |
| 16486 |
ls_cycls = lines.at(i).section(leer, 1, 1).toInt(); |
| 16487 |
} |
| 16488 |
break; |
| 16489 |
case 50://OMIT |
| 16490 |
{ |
| 16491 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16492 |
QRegularExpression num=QRegularExpression("$[A-Za-z]"); |
| 16493 |
if ((tok.size()==3)&&(!tok.at(1).contains(num))&&(!tok.at(2).contains(num))){ |
| 16494 |
//hklOmitSig,hklOmit2th,hklShellLow,hklShellHig |
| 16495 |
mole.hklOmitSig=tok.at(1).toDouble(); |
| 16496 |
mole.hklOmit2th=tok.at(2).toDouble(); |
| 16497 |
mole.hklShellHig=0.5*mole.cell.wave/sin(mole.hklOmit2th/360.0*M_PI); |
| 16498 |
} |
| 16499 |
} |
| 16500 |
break; |
| 16501 |
case 51: { //PART n sof |
| 16502 |
part = lines.at(i).section(leer,1,1).toInt(); |
| 16503 |
// part_fvar stores sof (and fvar) to decide during atom parsing |
| 16504 |
part_fvar = lines.at(i).section(leer, 2, 2).toDouble(); |
| 16505 |
minp=(minp<part)?minp:part; |
| 16506 |
maxp=(maxp>part)?maxp:part; |
| 16507 |
} |
| 16508 |
break; |
| 16509 |
case 58: {//RESI |
| 16510 |
if (lines.at(i).section(leer,1,1).indexOf(startnumbers)!=-1) { |
| 16511 |
newAtom.resiNr=lines.at(i).section(leer,1,1).toInt(); |
| 16512 |
newAtom.ResiClass=lines.at(i).section(leer,2,2); |
| 16513 |
} else { |
| 16514 |
newAtom.resiNr=lines.at(i).section(leer,2,2).toInt(); |
| 16515 |
newAtom.ResiClass=lines.at(i).section(leer,1,1); |
| 16516 |
} |
| 16517 |
//printf("RESI %s %s %d\n",lines.at(i).section(leer,1,1).toStdString().c_str(),newAtom.ResiClass.toStdString().c_str(),newAtom.resiNr); |
| 16518 |
break; |
| 16519 |
} |
| 16520 |
case 62: { //SFAC |
| 16521 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16522 |
if ((tok.size()>4)&&(!tok.at(2).contains(buchstaben))) { |
| 16523 |
s.setSCAT(tok); |
| 16524 |
if ((tok.at(2).toDouble()==0)&&((tok.at(3).toDouble()==1))) { |
| 16525 |
chgl->neutrons=true; |
| 16526 |
} |
| 16527 |
editor->sfac.append(mole.getOZ(tok.at(1))); |
| 16528 |
editor->sfacsmbl.append(tok.at(1)); |
| 16529 |
if (editor->sfac.last()>-2) { |
| 16530 |
if (tok.at(1)==QString("D")) { |
| 16531 |
pserbt[110]->show(); |
| 16532 |
//printf("show D\n"); |
| 16533 |
} |
| 16534 |
else pserbt[editor->sfac.last()+1]->show(); |
| 16535 |
} |
| 16536 |
sfacBox->setFixedSize((editor->sfacsmbl.size()+1)*52,70); |
| 16537 |
} else { |
| 16538 |
for (int isf=1; isf<tok.size();isf++) { |
| 16539 |
editor->sfac.append(mole.getOZ(tok.at(isf))); |
| 16540 |
editor->sfacsmbl.append(tok.at(isf)); |
| 16541 |
if (tok.at(isf)==QString("D")) { |
| 16542 |
pserbt[110]->show(); |
| 16543 |
//printf("show D\n"); |
| 16544 |
} |
| 16545 |
else { |
| 16546 |
pserbt[editor->sfac.last()+1]->show(); |
| 16547 |
//printf("!show %d %sw\n",editor->sfac.last(),tok.at(isf).toStdString().c_str()); |
| 16548 |
} |
| 16549 |
sfacBox->setFixedSize((editor->sfacsmbl.size()+1)*52,70); |
| 16550 |
} |
| 16551 |
} |
| 16552 |
} |
| 16553 |
break; |
| 16554 |
case 63:{//shel |
| 16555 |
//hklOmitSig,hklOmit2th,hklShellLow,hklShellHig |
| 16556 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16557 |
if (tok.size()>2){ |
| 16558 |
mole.hklShellLow=tok.at(1).toDouble(); |
| 16559 |
mole.hklShellHig=tok.at(2).toDouble(); |
| 16560 |
// qDebug()<<mole.hklShellLow<<mole.hklShellHig; |
| 16561 |
} |
| 16562 |
}break; |
| 16563 |
case 69:{ //SUMP |
| 16564 |
QStringList forml= lines.at(i).split(leer); |
| 16565 |
int fvix=4; |
| 16566 |
while (forml.size()>fvix){ |
| 16567 |
int m=forml.at(fvix).toInt(); |
| 16568 |
fvarCntr[m]++; |
| 16569 |
//printf("SUMP m%d fvarCntr=%d\n", m,fvarCntr.value(m)); |
| 16570 |
fvix+=2; |
| 16571 |
} |
| 16572 |
} |
| 16573 |
break; |
| 16574 |
case 70:{ |
| 16575 |
//SWAT g[0] U[2] |
| 16576 |
mole.swat=0.0; |
| 16577 |
mole.exti=2.0; |
| 16578 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16579 |
if (tok.size()>1) mole.swat=tok.at(1).toDouble(); |
| 16580 |
if (tok.size()>2) mole.exti=tok.at(2).toDouble(); |
| 16581 |
} |
| 16582 |
break; |
| 16583 |
|
| 16584 |
case 71: {// SYMM |
| 16585 |
mole.decodeSymmCard(lines.at(i).section(" ",1,130)); |
| 16586 |
break; |
| 16587 |
} |
| 16588 |
case 75: {// TITL |
| 16589 |
title = QString ("'%1'@ %2") |
| 16590 |
.arg(lines.at(i).section(" ",1,30).simplified()) |
| 16591 |
.arg(fileName.section('/', -1)); |
| 16592 |
mole.titl=lines.at(i).section(" ",1,-1).simplified(); |
| 16593 |
break; |
| 16594 |
} |
| 16595 |
case 78: {// UNIT |
| 16596 |
editor->unitAlt = lines.at(i) ; |
| 16597 |
mole.applyLatticeCentro(lattice); |
| 16598 |
|
| 16599 |
break; |
| 16600 |
} |
| 16601 |
case 81: {// WGHT |
| 16602 |
wghtAct->setEnabled(true); |
| 16603 |
break; |
| 16604 |
} |
| 16605 |
case 82: {// ZERR |
| 16606 |
mole.cell.Z= lines.at(i); |
| 16607 |
break; |
| 16608 |
} |
| 16609 |
case 103: {// NEUT |
| 16610 |
// qDebug()<<"Neutrons!"; |
| 16611 |
|
| 16612 |
chgl->neutrons=true; |
| 16613 |
break; |
| 16614 |
} |
| 16615 |
case 105:// BEDE |
| 16616 |
case 106:{// LONE |
| 16617 |
bedeRloneLY.append(lines.at(i)); |
| 16618 |
chgl->hideBeLo->setVisible(true); |
| 16619 |
belocube->setVisible(true); |
| 16620 |
break; |
| 16621 |
} |
| 16622 |
case -1:{//an atom or an error! |
| 16623 |
newAtom.isIso=false; |
| 16624 |
newAtom.ufiso_org=""; |
| 16625 |
if (firstAtomLine == 0) { |
| 16626 |
firstAtomLine = i; |
| 16627 |
} |
| 16628 |
if ((newAtom.afix>170)&&((newAtom.afix<180))) break; |
| 16629 |
QStringList tok = lines.at(i).split(leer,skipEmptyParts); |
| 16630 |
newAtom.part=part; |
| 16631 |
if (newAtom.resiNr<0){ |
| 16632 |
newAtom.resiNr=0; |
| 16633 |
newAtom.ResiClass=""; |
| 16634 |
} |
| 16635 |
if (tok.size()==7){ |
| 16636 |
// We have an isotropic atom! |
| 16637 |
if ((newAtom.part!=0)||(newAtom.resiNr!=0)){ |
| 16638 |
newAtom.Label=QString("%1_%3%4") |
| 16639 |
.arg(tok.at(0)) |
| 16640 |
.arg((newAtom.resiNr)?QString::number(newAtom.resiNr):"") |
| 16641 |
.arg((newAtom.part)?QString::number((newAtom.part<0)? |
| 16642 |
36+newAtom.part: |
| 16643 |
newAtom.part+9,36):""); |
| 16644 |
} else { |
| 16645 |
newAtom.Label=tok.at(0); |
| 16646 |
} |
| 16647 |
int fac=tok.at(1).toInt()-1; |
| 16648 |
newAtom.fixFlag=0; |
| 16649 |
|
| 16650 |
newAtom.an=((fac<0)||(fac>=editor->sfac.size()))?-2:editor->sfac.at(fac); |
| 16651 |
newAtom.frac.x = getNumber(tok.at(2).toDouble(),fvar,0,newAtom.fixFlag); |
| 16652 |
newAtom.frac.y = getNumber(tok.at(3).toDouble(),fvar,1,newAtom.fixFlag); |
| 16653 |
newAtom.frac.z = getNumber(tok.at(4).toDouble(),fvar,2,newAtom.fixFlag); |
| 16654 |
if (qAbs(part_fvar) > 11.0 ){ |
| 16655 |
// fvar is defined for entire part: |
| 16656 |
//printf("7part with sof %f %s\n",part_fvar,newAtom.Label.toStdString().c_str()); |
| 16657 |
newAtom.sof = getNumber(part_fvar, fvar, 3, newAtom.fixFlag); |
| 16658 |
newAtom.sof_org = part_fvar; |
| 16659 |
} else { |
| 16660 |
// fvar is defined at each atom: |
| 16661 |
newAtom.sof = getNumber(tok.at(5).toDouble(), fvar, 3, newAtom.fixFlag); |
| 16662 |
newAtom.sof_org = tok.at(5).toDouble(); |
| 16663 |
} |
| 16664 |
newAtom.isIso=true; |
| 16665 |
double uIso = getNumber(tok.at(6).toDouble(),fvar,uiso); |
| 16666 |
newAtom.uf.m11 = newAtom.uf.m22 = newAtom.uf.m33 = uIso; |
| 16667 |
newAtom.uf.m32 = newAtom.uf.m23 = uIso * mole.cell.cosra; |
| 16668 |
newAtom.uf.m31 = newAtom.uf.m13 = uIso * mole.cell.cosrb; |
| 16669 |
newAtom.uf.m21 = newAtom.uf.m12 = uIso * mole.cell.cosrg; |
| 16670 |
mole.Uf2Uo(newAtom.uf, newAtom.uc); |
| 16671 |
newAtom.ufiso_org=tok.at(6); |
| 16672 |
/*printf("Uiso%g uiso%g %g %g %g\n",uIso,uiso,mole.cell.cosra,mole.cell.cosrb,mole.cell.cosrg); |
| 16673 |
printf("%s org=%s iso=%d\n a%9.6f b%9.6f c%9.6f %9.6f %9.6f %9.6f\n d%9.6f e%9.6f f%9.6f %9.6f %9.6f %9.6f\n g%9.6f h%9.6f i%9.6f %9.6f %9.6f %9.6f\n\n", |
| 16674 |
newAtom.Label.toStdString().c_str(), |
| 16675 |
newAtom.ufiso_org.toStdString().c_str(), |
| 16676 |
newAtom.isIso, |
| 16677 |
newAtom.uf.m11,newAtom.uf.m12,newAtom.uf.m13, newAtom.uc.m11,newAtom.uc.m12,newAtom.uc.m13, |
| 16678 |
newAtom.uf.m21,newAtom.uf.m22,newAtom.uf.m23, newAtom.uc.m21,newAtom.uc.m22,newAtom.uc.m23, |
| 16679 |
newAtom.uf.m31,newAtom.uf.m32,newAtom.uf.m33, newAtom.uc.m31,newAtom.uc.m32,newAtom.uc.m33);*/ |
| 16680 |
//qDebug()<< newAtom.ufiso_org<< uIso<<newAtom.uc.m11<<newAtom.uc.m22<<newAtom.uc.m33<<newAtom.uc.m23<<newAtom.uc.m13<<newAtom.uc.m12; |
| 16681 |
newAtom.peakHeight=-666; |
| 16682 |
if (newAtom.an==-66) newAtom.peakHeight=9999.99; |
| 16683 |
newAtom.afixParent=-1; |
| 16684 |
if (newAtom.an>0) afixparent=mole.asymm.size(); |
| 16685 |
else newAtom.afixParent=afixparent; |
| 16686 |
mole.asymm.append(newAtom); |
| 16687 |
//isoat++; |
| 16688 |
} |
| 16689 |
if (tok.size()==8) { |
| 16690 |
// We have a q-peak! |
| 16691 |
newAtom.Label=tok.at(0); |
| 16692 |
if (newAtom.Label.startsWith('Q',Qt::CaseInsensitive)) { |
| 16693 |
newAtom.an=-1; |
| 16694 |
newAtom.resiNr=-1; |
| 16695 |
newAtom.ResiClass="Q-Peak"; |
| 16696 |
qpeaks++; |
| 16697 |
} else { |
| 16698 |
int fac=tok.at(1).toInt()-1; |
| 16699 |
newAtom.an=((fac<0)||(fac>=editor->sfac.size()))?-2:editor->sfac.at(fac); |
| 16700 |
//isoat++; |
| 16701 |
} |
| 16702 |
newAtom.fixFlag=0; |
| 16703 |
newAtom.frac.x = tok.at(2).toDouble(); |
| 16704 |
newAtom.frac.y = tok.at(3).toDouble(); |
| 16705 |
newAtom.frac.z = tok.at(4).toDouble(); |
| 16706 |
if (qAbs(part_fvar) > 11.0 ){ |
| 16707 |
// fvar is defined for entire part: |
| 16708 |
// printf("8part with sof %f %s\n",part_fvar,newAtom.Label.toStdString().c_str()); |
| 16709 |
newAtom.sof = getNumber(part_fvar, fvar, 3, newAtom.fixFlag); |
| 16710 |
newAtom.sof_org = part_fvar; |
| 16711 |
} else { |
| 16712 |
// fvar is defined at each atom: |
| 16713 |
newAtom.sof = getNumber(tok.at(5).toDouble(), fvar, 3, newAtom.fixFlag); |
| 16714 |
newAtom.sof_org = tok.at(5).toDouble(); |
| 16715 |
} |
| 16716 |
newAtom.isIso=true; |
| 16717 |
double uIso = getNumber(tok.at(6).toDouble(),fvar,uiso); |
| 16718 |
newAtom.uf.m11 = newAtom.uf.m22 = newAtom.uf.m33 = uIso; |
| 16719 |
newAtom.uf.m32 = newAtom.uf.m23 = uIso * mole.cell.cosra; |
| 16720 |
newAtom.uf.m31 = newAtom.uf.m13 = uIso * mole.cell.cosrb; |
| 16721 |
newAtom.uf.m21 = newAtom.uf.m12 = uIso * mole.cell.cosrg; |
| 16722 |
newAtom.ufiso_org=tok.at(6); |
| 16723 |
//newAtom.uf.m11= getNumber(tok.at(6).toDouble(), fvar, uiso); |
| 16724 |
//newAtom.isIso=true; |
| 16725 |
//newAtom.uf.m33= tok.at(6).toDouble(); |
| 16726 |
newAtom.peakHeight=tok.at(7).toDouble(); |
| 16727 |
if (!hklf) qbeforehkl=true; |
| 16728 |
if(newAtom.an==-1){ |
| 16729 |
mole.pmin=qMin(mole.pmin, newAtom.peakHeight); |
| 16730 |
mole.pmax=qMax(mole.pmax, newAtom.peakHeight); |
| 16731 |
} |
| 16732 |
chgl->qPeakBonds->setVisible(true); |
| 16733 |
|
| 16734 |
showQPeakLegend->setVisible(true); |
| 16735 |
newAtom.afixParent=-1; |
| 16736 |
mole.asymm.append(newAtom); |
| 16737 |
|
| 16738 |
} |
| 16739 |
if (tok.size()==12){ |
| 16740 |
// We have an ellipsoid atom! |
| 16741 |
if ((newAtom.part!=0)||(newAtom.resiNr!=0)){ |
| 16742 |
newAtom.Label=QString("%1_%3%4") |
| 16743 |
.arg(tok.at(0)) |
| 16744 |
.arg((newAtom.resiNr)?QString::number(newAtom.resiNr):"") |
| 16745 |
.arg((newAtom.part)?QString::number((newAtom.part<0)? |
| 16746 |
36+newAtom.part: |
| 16747 |
newAtom.part+9,36):""); |
| 16748 |
}else newAtom.Label=tok.at(0); |
| 16749 |
int fac=tok.at(1).toInt()-1; |
| 16750 |
newAtom.an=((fac<0)||(fac>=editor->sfac.size()))?-2:editor->sfac.at(fac); |
| 16751 |
newAtom.frac.x = getNumber(tok.at(2).toDouble(),fvar,0,newAtom.fixFlag); |
| 16752 |
newAtom.frac.y = getNumber(tok.at(3).toDouble(),fvar,1,newAtom.fixFlag); |
| 16753 |
newAtom.frac.z = getNumber(tok.at(4).toDouble(),fvar,2,newAtom.fixFlag); |
| 16754 |
if (qAbs(part_fvar) > 11.0 ){ |
| 16755 |
// fvar is defined for entire part: |
| 16756 |
//printf(">11 part with sof %f %s\n",part_fvar,newAtom.Label.toStdString().c_str()); |
| 16757 |
newAtom.sof = getNumber(part_fvar, fvar, 3, newAtom.fixFlag); |
| 16758 |
newAtom.sof_org = part_fvar; |
| 16759 |
} else { |
| 16760 |
// fvar is defined at each atom: |
| 16761 |
newAtom.sof = getNumber(tok.at(5).toDouble(), fvar, 3, newAtom.fixFlag); |
| 16762 |
newAtom.sof_org = tok.at(5).toDouble(); |
| 16763 |
} |
| 16764 |
newAtom.uf.m11 = getNumber(tok.at(6).toDouble(),fvar,4,newAtom.fixFlag); |
| 16765 |
newAtom.uf.m22 = getNumber(tok.at(7).toDouble(),fvar,5,newAtom.fixFlag); |
| 16766 |
newAtom.uf.m33 = getNumber(tok.at(8).toDouble(),fvar,6,newAtom.fixFlag); |
| 16767 |
newAtom.uf.m32 = newAtom.uf.m23 = getNumber(tok.at(9).toDouble(),fvar,7,newAtom.fixFlag); |
| 16768 |
newAtom.uf.m31 = newAtom.uf.m13 = getNumber(tok.at(10).toDouble(),fvar,8,newAtom.fixFlag); |
| 16769 |
newAtom.uf.m21 = newAtom.uf.m12 = getNumber(tok.at(11).toDouble(),fvar,9,newAtom.fixFlag); |
| 16770 |
newAtom.peakHeight=-666; |
| 16771 |
uiso=mole.ueq(newAtom.uf); |
| 16772 |
if (newAtom.an>0) afixparent=mole.asymm.size(); |
| 16773 |
newAtom.afixParent=-1; |
| 16774 |
mole.asymm.append(newAtom); |
| 16775 |
adpat++; |
| 16776 |
} |
| 16777 |
} |
| 16778 |
break; |
| 16779 |
} |
| 16780 |
|
| 16781 |
|
| 16782 |
} |
| 16783 |
|
| 16784 |
} |
| 16785 |
//printf("load sheldrick %d\n",__LINE__); |
| 16786 |
mole.qboMax=1.67; |
| 16787 |
if (minp<0) { |
| 16788 |
chgl->shpm1->setVisible(true); |
| 16789 |
chgl->highlightParts->setVisible(true); |
| 16790 |
} |
| 16791 |
if (maxp>0) chgl->highlightParts->setVisible(true); |
| 16792 |
mole.qbeforehkl=qbeforehkl; |
| 16793 |
actionUniq->setDisabled(mole.qbeforehkl); |
| 16794 |
if (!popel.isEmpty()){ |
| 16795 |
for (int i=0;i<mole.asymm.size();i++){ |
| 16796 |
if (mole.asymm.at(i).orginalLine.contains(popel)){ |
| 16797 |
//printf("HATSCHI %d => %d! (%s)\n",chgl->rotze,i,popel.toStdString().c_str()); |
| 16798 |
chgl->rotze=i; |
| 16799 |
} |
| 16800 |
} |
| 16801 |
} |
| 16802 |
for (int i=0;i<mole.asymm.size();i++){ |
| 16803 |
mole.Uf2Uo(mole.asymm.at(i).uf,mole.asymm[i].uc); |
| 16804 |
mole.frac2kart(mole.asymm.at(i).frac,mole.asymm[i].pos); |
| 16805 |
mole.showatoms.append(mole.asymm.at(i)); |
| 16806 |
} |
| 16807 |
|
| 16808 |
//printf("Average U equivalent (only positive definite counted): %f\n",mole.averageUeq()); |
| 16809 |
getMinMaxSintl(editor->smin,editor->smax); |
| 16810 |
if (mole.asymm.size()){ |
| 16811 |
updateStatusBar("analysing structure..."); |
| 16812 |
|
| 16813 |
if ((!notRefine)&&(mole.asymm.size()<chgl->SDM_Limit)) mole.packer(mole.sdmcompleter()); |
| 16814 |
infoKanalNews(mole.Fragments); |
| 16815 |
bool growYes=chgl->fuse->isVisible (); |
| 16816 |
bool fuseYes=chgl->grow->isVisible (); |
| 16817 |
chgl->fuse->setVisible(true); |
| 16818 |
chgl->grow->setVisible(false); |
| 16819 |
mole.loadSettings(); |
| 16820 |
updateStatusBar("finding bonds..."); |
| 16821 |
|
| 16822 |
mole.showbonds = mole.connecting(mole.showatoms); |
| 16823 |
int lnrr=0; |
| 16824 |
CEnvironment belo; |
| 16825 |
//printf("belo: %d\n",bedeRloneLY.size()); |
| 16826 |
for (int bl=0; bl<bedeRloneLY.size(); bl++){ |
| 16827 |
int ignore=0; |
| 16828 |
QStringList tok = bedeRloneLY.at(bl).split(leer,skipEmptyParts); |
| 16829 |
if ((tok.at(0).endsWith("BEDE",Qt::CaseInsensitive))&&(tok.size()>6)){ |
| 16830 |
lnrr=belo.size(); |
| 16831 |
QString aton1=tok.at(1),aton2=tok.at(2); |
| 16832 |
double rad = getNumber(tok.at(3).toDouble(),fvar,0,ignore); |
| 16833 |
double a = getNumber(tok.at(4).toDouble(),fvar,0,ignore); |
| 16834 |
double b1 = getNumber(tok.at(5).toDouble(),fvar,0,ignore); |
| 16835 |
double b2 = getNumber(tok.at(6).toDouble(),fvar,0,ignore); |
| 16836 |
newAtom.an=-42; |
| 16837 |
newAtom.symmGroup=0; |
| 16838 |
newAtom.sg=0; |
| 16839 |
newAtom.scod=555;//the identity |
| 16840 |
newAtom.auidx=-1; |
| 16841 |
int an1=-1,an2=-2; |
| 16842 |
for (int bl1=0; bl1<mole.asymm.size(); bl1++) |
| 16843 |
for (int bl2=0; bl2<mole.asymm.size(); bl2++){ |
| 16844 |
if ((mole.asymm.at(bl1).an<0)||(mole.asymm.at(bl2).an<0)) continue; |
| 16845 |
double soll=-1,d= sqrt(Distance(mole.asymm.at(bl1).pos,mole.asymm.at(bl2).pos)); |
| 16846 |
if ((mole.asymm.at(bl1).an==0)&&(mole.asymm.at(bl2).an==0)) continue; |
| 16847 |
if ((mole.asymm.at(bl1).an>-1)&&(mole.asymm.at(bl2).an>-1)&& |
| 16848 |
((!mole.asymm.at(bl1).part)||(!mole.asymm.at(bl2).part)||(mole.asymm.at(bl1).part==mole.asymm.at(bl2).part))) |
| 16849 |
soll=(mole.Kovalenz_Radien[mole.asymm.at(bl1).an]+ mole.Kovalenz_Radien[mole.asymm.at(bl2).an])*0.012; |
| 16850 |
else |
| 16851 |
soll=-1; |
| 16852 |
if ((d>0.1)&&(d<soll)) { |
| 16853 |
an1=-1; |
| 16854 |
an2=-2; |
| 16855 |
if (aton1[0]=='$') an1=mole.getOZ(aton1); |
| 16856 |
if (aton2[0]=='$') an2=mole.getOZ(aton2); |
| 16857 |
if (((an1>=0)&&(mole.asymm.at(bl1).an==an1))||(aton1==mole.asymm.at(bl1).Label)) |
| 16858 |
if (((an2>=0)&&(mole.asymm.at(bl2).an==an2))||(aton2==mole.asymm.at(bl2).Label)){ |
| 16859 |
V3 pos = mole.asymm.at(bl1).pos+Normalize(mole.asymm.at(bl2).pos-mole.asymm.at(bl1).pos)*rad; |
| 16860 |
newAtom.pos=pos; |
| 16861 |
mole.kart2frac(pos,pos); |
| 16862 |
newAtom.Label=QString("L%1").arg(++lnrr); |
| 16863 |
newAtom.frac=pos; |
| 16864 |
newAtom.auidx=-1; |
| 16865 |
newAtom.peakHeight=b1; |
| 16866 |
newAtom.sof=a; |
| 16867 |
newAtom.uf=mole.u2b(mole.asymm.at(bl1).uf);//possible problem if U is not anisotrop |
| 16868 |
belo.append(newAtom); |
| 16869 |
pos=mole.asymm.at(bl1).frac; |
| 16870 |
newAtom.Label=QString("L%1").arg(++lnrr); |
| 16871 |
newAtom.frac=mole.asymm.at(bl1).frac; |
| 16872 |
mole.frac2kart(newAtom.frac,newAtom.pos); |
| 16873 |
newAtom.sof=-a; |
| 16874 |
newAtom.peakHeight=b2; |
| 16875 |
belo.append(newAtom); |
| 16876 |
|
| 16877 |
mole.lmin=qMin(mole.lmin,-a); |
| 16878 |
mole.lmax=qMax(mole.lmax, a); |
| 16879 |
|
| 16880 |
} |
| 16881 |
} |
| 16882 |
} |
| 16883 |
|
| 16884 |
}else |
| 16885 |
if (tok.at(0).endsWith("LONE",Qt::CaseInsensitive)){ |
| 16886 |
belo.append(lonesome(bedeRloneLY.at(bl),belo.size()+1)); |
| 16887 |
} |
| 16888 |
} |
| 16889 |
if (!belo.isEmpty()) { |
| 16890 |
for (int bl=0; bl<belo.size(); bl++){ |
| 16891 |
belo[bl].orginalLine=QString("%1 2 %2 %3 %4").arg(belo.at(bl).Label.section('_',0,0),-4) |
| 16892 |
.arg(belo.at(bl).frac.x,10,'f',5) |
| 16893 |
.arg(belo.at(bl).frac.y,10,'f',5) |
| 16894 |
.arg(belo.at(bl).frac.z,10,'f',5); |
| 16895 |
} |
| 16896 |
mole.asymm.append(belo); |
| 16897 |
} |
| 16898 |
QString info; |
| 16899 |
for (int ifv=0; ifv<fvar.size();ifv++){ |
| 16900 |
if (ifv==0) { |
| 16901 |
info.append("OSF: "); |
| 16902 |
info.append(QString("<font color=red>%1</font>").arg(fvar.at(ifv))); |
| 16903 |
} |
| 16904 |
else { |
| 16905 |
info.append(QString("FVAR<font color=blue>%1</font>: ").arg(ifv+1)); |
| 16906 |
if (fvarCntr.value(ifv+1)<1)info.append(QString("<font color=red>%1</font>(Never Used!)").arg(fvar.at(ifv))); |
| 16907 |
else info.append(QString("<font color=red>%1</font>(used %2 time%3.)").arg(fvar.at(ifv)) |
| 16908 |
.arg(fvarCntr.value(ifv+1)).arg((fvarCntr.value(ifv+1)>1)?"s":"")); |
| 16909 |
} |
| 16910 |
if ((ifv+1)<fvar.size()) info.append(", "); |
| 16911 |
info.append("<br>"); |
| 16912 |
} |
| 16913 |
fvarinfo=QString("<b>Free variables:</b> %1").arg(info); |
| 16914 |
|
| 16915 |
chgl->setMolecule(&mole); |
| 16916 |
chgl->mol->fuse(); |
| 16917 |
if ((!notRefine)&&(mole.asymm.size()<chgl->SDM_Limit)) { |
| 16918 |
if (((!fuseYes)&&(growYes))||(((!fuseYes)&&(!growYes))&&(!startFused))) chgl->mol->grow(); |
| 16919 |
else { |
| 16920 |
chgl->fuse->setVisible(false); |
| 16921 |
chgl->grow->setVisible(true); |
| 16922 |
} |
| 16923 |
} |
| 16924 |
else { |
| 16925 |
//if ((mole.asymm.size()>chgl->SDM_Limit)&&(chgl->dratpause==80)) chgl->dratpause=300; |
| 16926 |
chgl->fuse->setVisible(false); |
| 16927 |
chgl->grow->setVisible(false); |
| 16928 |
|
| 16929 |
} |
| 16930 |
|
| 16931 |
infoKanalNews(mole.HumanSymmetry); |
| 16932 |
//updateStatusBar("drawing display lists..."); |
| 16933 |
|
| 16934 |
chgl->rehide(); |
| 16935 |
updateStatusBar(""); |
| 16936 |
} |
| 16937 |
|
| 16938 |
//printf("%d\n",__LINE__); |
| 16939 |
chgl->update(); |
| 16940 |
|
| 16941 |
|
| 16942 |
urs=V3(0,0,0);int gt=0; |
| 16943 |
for (int i=0; i<mole.showatoms.size();i++) |
| 16944 |
if (mole.showatoms.at(i).an>-1) {urs+=mole.showatoms.at(i).frac;gt++;} |
| 16945 |
urs*=1.0/gt; |
| 16946 |
urs=V3(1,1,1)-1.0*urs; |
| 16947 |
mole.frac2kart(urs,urs); |
| 16948 |
mode=0; |
| 16949 |
qpv->cutoff=0;//qMin(0.0,mole.pmin); |
| 16950 |
qpv->setMin(mole.pmin); |
| 16951 |
qpv->setMax(mole.pmax); |
| 16952 |
if (qpeaks) qPeakDock->show(); |
| 16953 |
|
| 16954 |
//QTime zeit; zeit.start(); |
| 16955 |
//printf("MAPS?\n"); |
| 16956 |
fxle->resDir=QDir(fileName); |
| 16957 |
fxle->fouName=(fxle->MYFCF)?s.myfcf(fileName):""; |
| 16958 |
if (fxle->fouName.isEmpty()){ |
| 16959 |
fxle->fouName=fileName; |
| 16960 |
fxle->fouName.chop(4); |
| 16961 |
fxle->fouName.append(".fcf"); |
| 16962 |
} |
| 16963 |
|
| 16964 |
if ((fxle->doMaps->isChecked())&& (!fxle->loadFouAndPerform(fxle->fouName.toLocal8Bit()))) { |
| 16965 |
if (fxle->doMaps->isChecked()) infoKanalNews(QString("<font color=red>Error while loading %1!</font><br>").arg(fxle->fouName)); |
| 16966 |
|
| 16967 |
//printf("%d\n",__LINE__); |
| 16968 |
fxle->killmaps(); |
| 16969 |
//printf("%d\n",__LINE__); |
| 16970 |
fxle->n1=fxle->n2=fxle->n3=fxle->n5=0; |
| 16971 |
} |
| 16972 |
if (fxle->doMaps->isChecked()){ |
| 16973 |
fxle->mapcontrol->setVisible(true); |
| 16974 |
} |
| 16975 |
fxle->doMaps->show(); |
| 16976 |
//printf("MAPS!\n"); |
| 16977 |
/* |
| 16978 |
QMap<int,double> unit; |
| 16979 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 16980 |
if (mole.asymm.at(i).an>=0) unit[mole.asymm.at(i).an]+= mole.asymm.at(i).sof * mole.cell.symmops.size(); |
| 16981 |
} |
| 16982 |
editor->unitNeu="UNIT"; |
| 16983 |
for (int i = 0; i < editor->sfac.size() ; i++){ |
| 16984 |
if (unit.value(editor->sfac.at(i))>9999) |
| 16985 |
editor->unitNeu.append(QString(" %1").arg((int)unit.value(editor->sfac.at(i)))); else |
| 16986 |
editor->unitNeu.append(QString(" %1").arg(unit.value(editor->sfac.at(i)),0,'g')); |
| 16987 |
if (editor->unitNeu.split('\n').last().size()>76) editor->unitNeu.append("=\n "); |
| 16988 |
}*/ |
| 16989 |
QMap<QString,double> unit; |
| 16990 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 16991 |
if (mole.asymm.at(i).an<0) continue; |
| 16992 |
QStringList ol = mole.asymm.at(i).orginalLine.split(' ', skipEmptyParts, Qt::CaseInsensitive); |
| 16993 |
QString smbl="!!"; |
| 16994 |
if ((ol.size()>1)&&(ol.at(1).toInt()-1<editor->sfacsmbl.size())) smbl=editor->sfacsmbl.at(ol.at(1).toInt()-1); |
| 16995 |
//printf("%d %d %d %s {%s}\n",__LINE__,ol.size(),editor->sfacsmbl.size(), mole.asymm.at(i).orginalLine.toStdString().c_str(), smbl.toStdString().c_str()); |
| 16996 |
//printf("%d\n",__LINE__); |
| 16997 |
if (mole.asymm.at(i).an>=0) { |
| 16998 |
|
| 16999 |
//printf("%d\n",__LINE__); |
| 17000 |
unit[smbl]+= mole.asymm.at(i).sof * mole.cell.symmops.size(); |
| 17001 |
// printf("%d\n",__LINE__); |
| 17002 |
/* |
| 17003 |
printf("%s %d %f %f <> %f %f ;-)\n", |
| 17004 |
smbl.toStdString().c_str(),i, |
| 17005 |
unit.value(smbl), unit[smbl], |
| 17006 |
mole.asymm.at(i).sof * mole.cell.symmops.size(), |
| 17007 |
mole.asymm.at(i).sof); |
| 17008 |
// */ |
| 17009 |
} |
| 17010 |
//printf("%d\n",__LINE__); |
| 17011 |
} |
| 17012 |
editor->unitNeu="UNIT"; |
| 17013 |
for (int i = 0; i < editor->sfacsmbl.size() ; i++){ |
| 17014 |
if (unit.value(editor->sfacsmbl.at(i))>9999) |
| 17015 |
editor->unitNeu.append(QString(" %1").arg((int)unit.value(editor->sfacsmbl.at(i)))); else |
| 17016 |
editor->unitNeu.append(QString(" %1").arg(unit.value(editor->sfacsmbl.at(i)),0,'g')); |
| 17017 |
if (editor->unitNeu.split('\n').last().size()>76) editor->unitNeu.append("=\n "); |
| 17018 |
} |
| 17019 |
//printf("%s\n",editor->unitNeu.toStdString().c_str()); |
| 17020 |
chgl->toggleDockWidgets->setVisible(true); |
| 17021 |
astdlg->setDisabled(false); |
| 17022 |
toggDocWid(false); |
| 17023 |
sinaAct->setVisible(adpat!=0); |
| 17024 |
if (!mole.asymm.size()) title.append("!!Empty!!"); |
| 17025 |
|
| 17026 |
refineAct->setVisible(!notRefine); |
| 17027 |
refineAct->setEnabled(!notRefine); |
| 17028 |
|
| 17029 |
refineActAnis->setVisible(!notRefine); |
| 17030 |
refineActAnis->setEnabled(!notRefine); |
| 17031 |
|
| 17032 |
refineActActa->setVisible(!notRefine); |
| 17033 |
refineActActa->setEnabled(!notRefine); |
| 17034 |
|
| 17035 |
refineActExti->setVisible(!notRefine); |
| 17036 |
refineActExti->setEnabled(!notRefine); |
| 17037 |
|
| 17038 |
refineActConf->setVisible(!notRefine); |
| 17039 |
refineActConf->setEnabled(!notRefine); |
| 17040 |
for (int k=0; k<editor->sfac.size();k++){ |
| 17041 |
xda.an = editor->sfac.at(k); |
| 17042 |
xda.Label = mole.pse(editor->sfac.at(k)); |
| 17043 |
mole.legendAtoms.append(xda); |
| 17044 |
if (editor->sfac.at(k)<0) continue; |
| 17045 |
QAction *a = chgl->sfacMenu->addAction(mole.pse(editor->sfac.at(k)),this,SLOT(changeElement())); |
| 17046 |
a->setData(k); |
| 17047 |
a = chgl->selSfacMenu->addAction(mole.pse(editor->sfac.at(k)),this,SLOT(changeSelectedElements())); |
| 17048 |
a->setData(k); |
| 17049 |
} |
| 17050 |
if (qpeaks){ |
| 17051 |
xda.an = -1; |
| 17052 |
xda.Label = "Q"; |
| 17053 |
xda.peakHeight = mole.pmax-0.01; |
| 17054 |
mole.legendAtoms.append(xda); |
| 17055 |
xda.pos.y += 0.5; |
| 17056 |
} |
| 17057 |
if (chgl->hideBeLo->isVisible()){ |
| 17058 |
xda.an = -42; |
| 17059 |
xda.Label = "BELO"; |
| 17060 |
xda.peakHeight = mole.lmax-0.01; |
| 17061 |
mole.legendAtoms.append(xda); |
| 17062 |
xda.pos.y += 0.5; |
| 17063 |
} |
| 17064 |
//printf("%d\n",__LINE__); |
| 17065 |
//int td=0; |
| 17066 |
if (!notRefine) switch ( |
| 17067 |
//td= |
| 17068 |
duplicates()){ |
| 17069 |
case 1:infoKanalNews("<font color=orange >Some hydrogen atoms have identical names please check.</font>");break; |
| 17070 |
case 2:infoKanalNews("<font color=red >Some non-hydrogen atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 17071 |
case 3:infoKanalNews("<font color=red >Some atoms have identical names. YOU HAVE TO CHECK BEFORE REFINING!</font>");break; |
| 17072 |
} |
| 17073 |
QString listName=fileName; |
| 17074 |
listName.replace(punktins,".lst"); |
| 17075 |
listName.replace(punktres,".lst"); |
| 17076 |
QFile lstf(listName); |
| 17077 |
//printf("%d\n",__LINE__); |
| 17078 |
if (lstf.open(QIODevice::ReadOnly|QIODevice::Text)){ |
| 17079 |
QString liste=QString(lstf.readAll()); |
| 17080 |
while (liste.contains(QRegularExpression("\n\\s+REM"))) { |
| 17081 |
liste=liste.replace(QRegularExpression("\n\\s+REM[^\n]*\n",QRegularExpression::CaseInsensitiveOption),"\n"); |
| 17082 |
//printf("%d\n",__LINE__); |
| 17083 |
} |
| 17084 |
//printf("%d\n",__LINE__); |
| 17085 |
if (liste.contains("Flack x parameter =")){ |
| 17086 |
QString flackS=liste.section("Flack x parameter =",1).section('\n',0,0); |
| 17087 |
double flackX=flackS.split(leer,skipEmptyParts).first().toDouble(); |
| 17088 |
double flackXesd=flackS.split(leer,skipEmptyParts).last().toDouble(); |
| 17089 |
infoKanalNews(QString("SHELXL-list file reports <b>Flack</b> x parameter:<b> %1 ± %2</b>").arg(flackX).arg(flackXesd)); |
| 17090 |
} |
| 17091 |
//Flack x = |
| 17092 |
if (liste.contains("Flack x =")) { |
| 17093 |
QString flackS=liste.section("\n Flack x = ",1).section('\n',0,1); |
| 17094 |
QString flackX = ""; |
| 17095 |
// prevent crash from empty flackS: |
| 17096 |
if (flackS.split(leer,skipEmptyParts).length() > 0) { |
| 17097 |
flackX=flackS.split(leer,skipEmptyParts).first(); |
| 17098 |
} |
| 17099 |
QString parsonsZ=flackS.section('\n',1,1); |
| 17100 |
if (parsonsZ.isEmpty() && !flackX.isEmpty()) { |
| 17101 |
infoKanalNews(QString("SHELXL-list file reports <b>Flack</b> x parameter:<b> %1 </b>").arg(flackX)); |
| 17102 |
} |
| 17103 |
if (!parsonsZ.isEmpty() && !flackX.isEmpty()) { |
| 17104 |
parsonsZ=parsonsZ.split(leer,skipEmptyParts).first(); |
| 17105 |
infoKanalNews(QString("SHELXL-list file reports <br><b>Flack</b> x parameter:<b> %1 </b><br><b>Parsons</b> parameter:<b> %2</b>") |
| 17106 |
.arg(flackX).arg(parsonsZ)); |
| 17107 |
} |
| 17108 |
} |
| 17109 |
lstf.close(); |
| 17110 |
} |
| 17111 |
QString fcfname = fileName; |
| 17112 |
fcfname.replace(resorins,".fcf"); |
| 17113 |
fvused->setText(QString("%1 FVARs defined").arg(fvar.count())); |
| 17114 |
fcvsfoAct->setEnabled(QFile::exists(fcfname)); |
| 17115 |
chgl->showHidden(); |
| 17116 |
editor->fitWidth(); |
| 17117 |
|
| 17118 |
//loadMolInTest(); |
| 17119 |
update(); |
| 17120 |
chgl->update(); |
| 17121 |
//return title; |
| 17122 |
}//shelx |
| 17123 |
|
| 17124 |
|
| 17125 |
#include "ideal_defden.h" |
| 17126 |
void Window::beloWriteCube(){ |
| 17127 |
//printf("bWC belo?%d\n",fxle->isBelo); |
| 17128 |
if (fxle->isBelo) return; |
| 17129 |
fxle->isBelo=true; |
| 17130 |
chgl->fofcact->setVisible(true); |
| 17131 |
chgl->fofcact->setChecked(true); |
| 17132 |
IdealDefdenGenerator *idealDefGen = new IdealDefdenGenerator(chgl, fxle, this); |
| 17133 |
connect(idealDefGen, SIGNAL(finished()), fxle, SLOT(controlMap())); |
| 17134 |
connect(idealDefGen, SIGNAL(message(const QString&)), this, SLOT(updateStatusBar(const QString&))); |
| 17135 |
connect(idealDefGen, SIGNAL(finished()), idealDefGen, SLOT(deleteLater())); |
| 17136 |
idealDefGen->start(); |
| 17137 |
chgl->update(); |
| 17138 |
} |
| 17139 |
|
| 17140 |
void Window::configBeLos(){ |
| 17141 |
QColor c = mole.beloColor; |
| 17142 |
QDialog *belodlg = new QDialog(this); |
| 17143 |
QGridLayout *lo = new QGridLayout(belodlg); |
| 17144 |
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel,Qt::Horizontal,belodlg); |
| 17145 |
connect(bb, SIGNAL(accepted()), belodlg, SLOT(accept())); |
| 17146 |
connect(bb, SIGNAL(rejected()), belodlg, SLOT(reject())); |
| 17147 |
QDoubleSpinBox *beloRadSpin = new QDoubleSpinBox(belodlg); |
| 17148 |
beloRadSpin->setMinimum(0.01); |
| 17149 |
beloRadSpin->setMaximum(0.2); |
| 17150 |
beloRadSpin->setValue(mole.beloRad); |
| 17151 |
beloRadSpin->setSingleStep(0.01); |
| 17152 |
QCheckBox *beloLabel = new QCheckBox("Show BEDE LONE Labels",belodlg); |
| 17153 |
beloLabel->setChecked(mole.beloLabels); |
| 17154 |
beloColorButton = new QPushButton("BEDE LONE objects color",belodlg); |
| 17155 |
beloColorButton->setStyleSheet(QString( |
| 17156 |
"QPushButton {" |
| 17157 |
"border: 1px solid #000000;" |
| 17158 |
"border-radius: 9px;" |
| 17159 |
"color: %4;" |
| 17160 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);" |
| 17161 |
"}" |
| 17162 |
"QPushButton:hover {" |
| 17163 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);" |
| 17164 |
"}" |
| 17165 |
"QPushButton:flat {" |
| 17166 |
" border: none; /* no border for a flat push button */" |
| 17167 |
"}" |
| 17168 |
) |
| 17169 |
.arg(mole.beloColor.name()) |
| 17170 |
.arg(mole.beloColor.darker(200).name()) |
| 17171 |
.arg(mole.beloColor.lighter(200).name()) |
| 17172 |
.arg((mole.beloColor.value()<90)?"#ffffff":"#000000")); |
| 17173 |
connect(beloColorButton, SIGNAL(pressed()), this, SLOT(colorButtonDialog())); |
| 17174 |
QCheckBox *beloColorByDefdenBx = new QCheckBox("Use deformation density based color scheme",belodlg); |
| 17175 |
beloColorByDefdenBx->setChecked(mole.beloColorByDefden); |
| 17176 |
lo->addWidget(beloColorByDefdenBx,0,0,1,10); |
| 17177 |
lo->addWidget(beloColorButton,1,0,1,10); |
| 17178 |
lo->addWidget(new QLabel("BEDE LONE objects size:",belodlg),2,0,1,1); |
| 17179 |
lo->addWidget(beloRadSpin,2,1,1,1); |
| 17180 |
lo->addWidget(beloLabel,3,0,1,1); |
| 17181 |
lo->addWidget(bb,10,0,1,10); |
| 17182 |
if (belodlg->exec()==QDialog::Accepted){ |
| 17183 |
mole.beloRad=beloRadSpin->value(); |
| 17184 |
mole.beloColorByDefden = beloColorByDefdenBx->isChecked(); |
| 17185 |
mole.beloLabels = beloLabel->isChecked(); |
| 17186 |
|
| 17187 |
chgl->update(); |
| 17188 |
einstellung->beginGroup("IDEAL"); |
| 17189 |
einstellung->setValue("beloRad", mole.beloRad); |
| 17190 |
einstellung->setValue("beloColor", mole.beloColor); |
| 17191 |
einstellung->setValue("beloColorByDefden", mole.beloColorByDefden); |
| 17192 |
einstellung->setValue("beloLabels", mole.beloLabels); |
| 17193 |
einstellung->endGroup(); |
| 17194 |
}else{ |
| 17195 |
mole.beloColor=c; |
| 17196 |
} |
| 17197 |
belodlg->deleteLater(); |
| 17198 |
|
| 17199 |
} |
| 17200 |
|
| 17201 |
void Window::colorButtonDialog(){ |
| 17202 |
QColor bgcolor; |
| 17203 |
bgcolor=QColorDialog::getColor(mole.beloColor, this); |
| 17204 |
if (bgcolor.isValid()) { |
| 17205 |
beloColorButton->setStyleSheet(QString( |
| 17206 |
"QPushButton {" |
| 17207 |
"border: 1px solid #000000;" |
| 17208 |
"border-radius: 9px;" |
| 17209 |
"color: %4;" |
| 17210 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);" |
| 17211 |
"}" |
| 17212 |
"QPushButton:hover {" |
| 17213 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);" |
| 17214 |
"}" |
| 17215 |
"QPushButton:flat {" |
| 17216 |
" border: none; /* no border for a flat push button */" |
| 17217 |
"}" |
| 17218 |
) |
| 17219 |
.arg(bgcolor.name()) |
| 17220 |
.arg(bgcolor.darker(200).name()) |
| 17221 |
.arg(bgcolor.lighter(200).name()) |
| 17222 |
.arg((bgcolor.value()<90)?"#ffffff":"#000000")); |
| 17223 |
mole.beloColor=bgcolor; |
| 17224 |
} |
| 17225 |
} |
| 17226 |
|
| 17227 |
CEnvironment Window::lonesome(QString s, int stnum){ |
| 17228 |
const QRegularExpression num=QRegularExpression("^\\d+"); |
| 17229 |
const QRegularExpression alp=QRegularExpression("^[\\$A-Za-z]+"); |
| 17230 |
QStringList tok=s.split(leer,skipEmptyParts); |
| 17231 |
int m=0,j=0,k=0,ll=stnum;; |
| 17232 |
MyAtom horse; |
| 17233 |
//static CEnvironment l; |
| 17234 |
CEnvironment l; |
| 17235 |
l.clear(); |
| 17236 |
MyAtom at; |
| 17237 |
at.an=-42; |
| 17238 |
at.auidx=-1; |
| 17239 |
at.scod=555; |
| 17240 |
int ignore=0; |
| 17241 |
while (!tok.at(j).contains(num)) {j++;} |
| 17242 |
m=tok.at(j).toInt(); |
| 17243 |
k=j; |
| 17244 |
QString such; |
| 17245 |
j=1; |
| 17246 |
while ((!tok.at(j).contains(alp))) {j++;if (j>=tok.size()) break;} |
| 17247 |
if (j==tok.size()) { |
| 17248 |
qDebug()<<"oh-oh!"; |
| 17249 |
return l;//big problem |
| 17250 |
} |
| 17251 |
such=tok.at(j); |
| 17252 |
//j=qMax(j,k)+1; |
| 17253 |
j = k + 1; |
| 17254 |
while (tok.at(j).contains(alp)) {j++;} |
| 17255 |
double a = getNumber(tok.at(j).toDouble(),fvar,0,ignore); |
| 17256 |
j++; |
| 17257 |
while (tok.at(j).contains(alp)) {j++;} |
| 17258 |
double b1 = getNumber(tok.at(j).toDouble(),fvar,0,ignore); |
| 17259 |
j++; |
| 17260 |
while (tok.at(j).contains(alp)) {j++;} |
| 17261 |
double b2 = getNumber(tok.at(j).toDouble(),fvar,0,ignore); |
| 17262 |
bool general=true; |
| 17263 |
// qDebug()<<s<<such<<j<<tok.size()<<k<<'m'<<m<<'a'<<a<<"b1"<<b1<<"b2"<<b2; |
| 17264 |
|
| 17265 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 17266 |
if (such==mole.asymm.at(i).Label) { |
| 17267 |
general=false; |
| 17268 |
horse=mole.asymm[i]; |
| 17269 |
break;} |
| 17270 |
} |
| 17271 |
if (general){ |
| 17272 |
|
| 17273 |
QString such2=such; |
| 17274 |
such2.remove('$'); |
| 17275 |
// qDebug()<<such<<such2; |
| 17276 |
int an1= mole.getOZ(such2); |
| 17277 |
int jjj=stnum; |
| 17278 |
for (int recurs=0; recurs<mole.asymm.size();recurs++){ |
| 17279 |
if (mole.asymm.at(recurs).an==an1){ |
| 17280 |
QString s2=s; |
| 17281 |
s2=s2.replace(such,mole.asymm.at(recurs).Label); |
| 17282 |
// qDebug()<<l.size()<<s2; |
| 17283 |
CEnvironment lrec; |
| 17284 |
lrec=lonesome(s2, jjj);//recursion! |
| 17285 |
jjj+=lrec.size(); |
| 17286 |
for (int dii=0; dii<lrec.size();dii++) { |
| 17287 |
// qDebug()<<dii <<lrec.at(dii).Label; |
| 17288 |
l.append(lrec[dii]); |
| 17289 |
} |
| 17290 |
// qDebug()<<l.size()<<jjj<<lrec.size();; |
| 17291 |
} |
| 17292 |
} |
| 17293 |
// for (int dii=0; dii<l.size();dii++) { qDebug()<<"return "<<dii <<l.at(dii).Label; } |
| 17294 |
return l; |
| 17295 |
|
| 17296 |
}else{ |
| 17297 |
MyAtom n1=mole.asymm[0]; |
| 17298 |
MyAtom n2=mole.asymm[0]; |
| 17299 |
MyAtom n3=mole.asymm[0]; |
| 17300 |
switch (m) { |
| 17301 |
case 1:{ |
| 17302 |
j=0; |
| 17303 |
double d,soll=0; |
| 17304 |
for (;j<mole.asymm.size();j++) { |
| 17305 |
if (mole.asymm.at(j).an<0) continue; |
| 17306 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17307 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17308 |
if ((d>0.1)&&(d<soll)){ |
| 17309 |
n1=mole.asymm[j]; |
| 17310 |
j++; |
| 17311 |
break; |
| 17312 |
} |
| 17313 |
} |
| 17314 |
for (;j<mole.asymm.size();j++) { |
| 17315 |
if (mole.asymm.at(j).an<0) continue; |
| 17316 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17317 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17318 |
if ((d>0.1)&&(d<soll)){ |
| 17319 |
n2=mole.asymm[j]; |
| 17320 |
j++; |
| 17321 |
break; |
| 17322 |
} |
| 17323 |
} |
| 17324 |
for (;j<mole.asymm.size();j++) { |
| 17325 |
if (mole.asymm.at(j).an<0) continue; |
| 17326 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17327 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17328 |
if ((d>0.1)&&(d<soll)){ |
| 17329 |
n3=mole.asymm[j]; |
| 17330 |
j++; |
| 17331 |
break; |
| 17332 |
} |
| 17333 |
} |
| 17334 |
V3 va= Normalize(n1.pos-horse.pos); |
| 17335 |
V3 vb= Normalize(n2.pos-horse.pos); |
| 17336 |
V3 vc= Normalize(n3.pos-horse.pos); |
| 17337 |
V3 trisect=Normalize(va+vb+vc); |
| 17338 |
double rad=tok.last().toDouble(); |
| 17339 |
if (rad<0) { |
| 17340 |
rad=-rad; |
| 17341 |
} |
| 17342 |
at.pos=horse.pos-(trisect*rad); |
| 17343 |
at.uf=mole.u2b(horse.uf);//possible problem if U is not anisotrop |
| 17344 |
mole.kart2frac(at.pos,at.frac); |
| 17345 |
at.peakHeight=b1; |
| 17346 |
at.sof=a; |
| 17347 |
at.auidx=-1; |
| 17348 |
at.Label=QString("L%1").arg(ll++); |
| 17349 |
l.append(at); |
| 17350 |
at.pos=horse.pos; |
| 17351 |
at.frac=horse.frac; |
| 17352 |
at.peakHeight=b2; |
| 17353 |
at.sof=-a*l.size(); |
| 17354 |
at.Label=QString("L%1").arg(ll++); |
| 17355 |
l.append(at); |
| 17356 |
//qDebug()<<n1.Label<<n2.Label; |
| 17357 |
if (tok.size()>7) { |
| 17358 |
QString s2=s; |
| 17359 |
s2.remove(horse.Label); |
| 17360 |
//qDebug()<<s2<<ll; |
| 17361 |
|
| 17362 |
l.append(lonesome(s2,ll)); |
| 17363 |
} |
| 17364 |
} |
| 17365 |
break; |
| 17366 |
case 2:{ |
| 17367 |
j=0; |
| 17368 |
double d,soll=0; |
| 17369 |
for (;j<mole.asymm.size();j++) { |
| 17370 |
if (mole.asymm.at(j).an<0) continue; |
| 17371 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17372 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17373 |
if ((d>0.1)&&(d<soll)){ |
| 17374 |
n1=mole.asymm[j]; |
| 17375 |
j++; |
| 17376 |
break; |
| 17377 |
} |
| 17378 |
} |
| 17379 |
for (;j<mole.asymm.size();j++) { |
| 17380 |
if (mole.asymm.at(j).an<0) continue; |
| 17381 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17382 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17383 |
if ((d>0.1)&&(d<soll)){ |
| 17384 |
n2=mole.asymm[j]; |
| 17385 |
j++; |
| 17386 |
break; |
| 17387 |
} |
| 17388 |
} |
| 17389 |
V3 va= Normalize(n1.pos-horse.pos); |
| 17390 |
V3 vb= Normalize(n2.pos-horse.pos); |
| 17391 |
V3 bisect=Normalize(va+vb); |
| 17392 |
V3 ax=Normalize(vb%va);//LLLL |
| 17393 |
double phi=tok.last().toDouble(); |
| 17394 |
double rad=tok.at(tok.size()-2).toDouble(); |
| 17395 |
//qDebug()<<phi<<rad; |
| 17396 |
//qDebug()<<va.x<<va.y<<va.z; |
| 17397 |
//qDebug()<<vb.x<<vb.y<<vb.z; |
| 17398 |
phi*=M_PI/360.0;//we want /2 ! |
| 17399 |
V3 c=-cos(phi)*bisect; |
| 17400 |
if (rad<0) { |
| 17401 |
c=-1.0*c; |
| 17402 |
rad=-rad; |
| 17403 |
} |
| 17404 |
V3 v=sin(phi)*ax; |
| 17405 |
at.pos=horse.pos+(c+v)*rad; |
| 17406 |
at.uf=mole.u2b(horse.uf);//possible problem if U is not anisotrop |
| 17407 |
mole.kart2frac(at.pos,at.frac); |
| 17408 |
at.peakHeight=b1; |
| 17409 |
at.sof=a; |
| 17410 |
at.auidx=-1; |
| 17411 |
at.Label=QString("L%1").arg(ll++); |
| 17412 |
l.append(at); |
| 17413 |
at.pos=horse.pos+(c-v)*rad; |
| 17414 |
mole.kart2frac(at.pos,at.frac); |
| 17415 |
at.Label=QString("L%1").arg(ll++); |
| 17416 |
l.append(at); |
| 17417 |
at.pos=horse.pos; |
| 17418 |
at.frac=horse.frac; |
| 17419 |
at.peakHeight=b2; |
| 17420 |
at.sof=-a*l.size(); |
| 17421 |
at.Label=QString("L%1").arg(ll++); |
| 17422 |
l.append(at); |
| 17423 |
//qDebug()<<n1.Label<<n2.Label; |
| 17424 |
if (tok.size()>8) { |
| 17425 |
QString s2=s; |
| 17426 |
s2.remove(horse.Label); |
| 17427 |
//qDebug()<<s2<<ll; |
| 17428 |
|
| 17429 |
l.append(lonesome(s2,ll)); |
| 17430 |
} |
| 17431 |
} |
| 17432 |
break; |
| 17433 |
|
| 17434 |
case 4:{ |
| 17435 |
j=0; |
| 17436 |
double d,soll=0; |
| 17437 |
for (;j<mole.asymm.size();j++) { |
| 17438 |
if (mole.asymm.at(j).an<0) continue; |
| 17439 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17440 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17441 |
if ((d>0.1)&&(d<soll)){ |
| 17442 |
n1=mole.asymm[j]; |
| 17443 |
j++; |
| 17444 |
break; |
| 17445 |
} |
| 17446 |
} |
| 17447 |
for (;j<mole.asymm.size();j++) { |
| 17448 |
if (mole.asymm.at(j).an<0) continue; |
| 17449 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17450 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17451 |
if ((d>0.1)&&(d<soll)){ |
| 17452 |
n2=mole.asymm[j]; |
| 17453 |
j++; |
| 17454 |
break; |
| 17455 |
} |
| 17456 |
} |
| 17457 |
V3 va= Normalize(n1.pos-horse.pos); |
| 17458 |
V3 vb= Normalize(n2.pos-horse.pos); |
| 17459 |
V3 bisect=Normalize(va+vb); |
| 17460 |
//V3 ax=Normalize(vb%va);//LLLL |
| 17461 |
double rad=tok.last().toDouble(); |
| 17462 |
at.pos=horse.pos-bisect*rad; |
| 17463 |
at.uf=mole.u2b(horse.uf);//possible problem if U is not anisotrop |
| 17464 |
mole.kart2frac(at.pos,at.frac); |
| 17465 |
at.peakHeight=b1; |
| 17466 |
at.sof=a; |
| 17467 |
at.Label=QString("L%1").arg(ll++); |
| 17468 |
l.append(at); |
| 17469 |
at.pos=horse.pos; |
| 17470 |
at.frac=horse.frac; |
| 17471 |
at.peakHeight=b2; |
| 17472 |
at.sof=-a; |
| 17473 |
at.Label=QString("L%1").arg(ll++); |
| 17474 |
l.append(at); |
| 17475 |
//qDebug()<<n1.Label<<n2.Label; |
| 17476 |
if (tok.size()>7) { |
| 17477 |
QString s2=s; |
| 17478 |
s2.remove(horse.Label); |
| 17479 |
//qDebug()<<s2<<ll; |
| 17480 |
|
| 17481 |
l.append(lonesome(s2,ll)); |
| 17482 |
} |
| 17483 |
} |
| 17484 |
break; |
| 17485 |
case 6:{ |
| 17486 |
j=0; |
| 17487 |
double d,soll=0; |
| 17488 |
for (;j<mole.asymm.size();j++) { |
| 17489 |
if (mole.asymm.at(j).an<0) continue; |
| 17490 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17491 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17492 |
if ((d>0.1)&&(d<soll)){ |
| 17493 |
n1=mole.asymm[j]; |
| 17494 |
j++; |
| 17495 |
break; |
| 17496 |
} |
| 17497 |
} |
| 17498 |
for (;j<mole.asymm.size();j++) { |
| 17499 |
if (mole.asymm.at(j).an<0) continue; |
| 17500 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17501 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17502 |
if ((d>0.1)&&(d<soll)){ |
| 17503 |
n2=mole.asymm[j]; |
| 17504 |
j++; |
| 17505 |
break; |
| 17506 |
} |
| 17507 |
} |
| 17508 |
V3 va= Normalize(n1.pos-horse.pos); |
| 17509 |
V3 vb= Normalize(n2.pos-horse.pos); |
| 17510 |
V3 ax=Normalize(vb%va);//LLLL |
| 17511 |
double rad=tok.last().toDouble(); |
| 17512 |
//qDebug()<<phi<<rad; |
| 17513 |
//qDebug()<<va.x<<va.y<<va.z; |
| 17514 |
//qDebug()<<vb.x<<vb.y<<vb.z; |
| 17515 |
if (rad<0) { |
| 17516 |
rad=-rad; |
| 17517 |
} |
| 17518 |
at.pos=horse.pos+(ax)*rad; |
| 17519 |
at.uf=mole.u2b(horse.uf);//possible problem if U is not anisotrop |
| 17520 |
mole.kart2frac(at.pos,at.frac); |
| 17521 |
at.peakHeight=b1; |
| 17522 |
at.sof=a; |
| 17523 |
at.Label=QString("L%1").arg(ll++); |
| 17524 |
l.append(at); |
| 17525 |
at.pos=horse.pos-(ax)*rad; |
| 17526 |
mole.kart2frac(at.pos,at.frac); |
| 17527 |
at.Label=QString("L%1").arg(ll++); |
| 17528 |
l.append(at); |
| 17529 |
at.pos=horse.pos; |
| 17530 |
at.frac=horse.frac; |
| 17531 |
at.peakHeight=b2; |
| 17532 |
at.sof=-a*l.size(); |
| 17533 |
at.Label=QString("L%1").arg(ll++); |
| 17534 |
l.append(at); |
| 17535 |
//qDebug()<<"m=6!"<<s<<n1.Label<<n2.Label<<at.Label; |
| 17536 |
//qDebug()<<tok<<tok.size(); |
| 17537 |
if (tok.size()>7) { |
| 17538 |
QString s2=s; |
| 17539 |
s2.remove(horse.Label); |
| 17540 |
//qDebug()<<s2<<ll; |
| 17541 |
|
| 17542 |
l.append(lonesome(s2,ll)); |
| 17543 |
} |
| 17544 |
} |
| 17545 |
break; |
| 17546 |
case 7:{ |
| 17547 |
j=0; |
| 17548 |
double d,soll=0,d2; |
| 17549 |
for (;j<mole.asymm.size();j++) { |
| 17550 |
if (mole.asymm.at(j).an<0) continue; |
| 17551 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17552 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17553 |
if ((d>0.1)&&(d<soll)){ |
| 17554 |
n1=mole.asymm[j]; |
| 17555 |
j++; |
| 17556 |
break; |
| 17557 |
} |
| 17558 |
} |
| 17559 |
for (j=0;j<mole.asymm.size();j++) { |
| 17560 |
if (mole.asymm.at(j).an<0) continue; |
| 17561 |
soll=(mole.Kovalenz_Radien[n1.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17562 |
d= sqrt(Distance(n1.pos,mole.asymm.at(j).pos)); |
| 17563 |
d2= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17564 |
if ((d2>1.1)&&(d>0.1)&&(d<soll)){ |
| 17565 |
n2=mole.asymm[j]; |
| 17566 |
j++; |
| 17567 |
break; |
| 17568 |
} |
| 17569 |
} |
| 17570 |
V3 va= Normalize(n1.pos-horse.pos); |
| 17571 |
V3 vb= Normalize(n2.pos-n1.pos); |
| 17572 |
V3 ax=Normalize(vb%va);//LLLL |
| 17573 |
double phi=tok.last().toDouble(); |
| 17574 |
double rad=tok.at(tok.size()-2).toDouble(); |
| 17575 |
//qDebug()<<phi<<rad; |
| 17576 |
//qDebug()<<va.x<<va.y<<va.z; |
| 17577 |
//qDebug()<<vb.x<<vb.y<<vb.z; |
| 17578 |
phi*=M_PI/360.0;//we want /2 ! |
| 17579 |
V3 c=-cos(phi)*va; |
| 17580 |
if (rad<0) { |
| 17581 |
c=-1.0*c; |
| 17582 |
rad=-rad; |
| 17583 |
} |
| 17584 |
V3 v=sin(phi)*ax; |
| 17585 |
at.pos=horse.pos+(c+v)*rad; |
| 17586 |
at.uf=mole.u2b(horse.uf);//possible problem if U is not anisotrop |
| 17587 |
mole.kart2frac(at.pos,at.frac); |
| 17588 |
at.peakHeight=b1; |
| 17589 |
at.sof=a; |
| 17590 |
at.Label=QString("L%1").arg(ll++); |
| 17591 |
l.append(at); |
| 17592 |
at.pos=horse.pos+(c-v)*rad; |
| 17593 |
mole.kart2frac(at.pos,at.frac); |
| 17594 |
at.Label=QString("L%1").arg(ll++); |
| 17595 |
l.append(at); |
| 17596 |
at.pos=horse.pos; |
| 17597 |
at.frac=horse.frac; |
| 17598 |
at.peakHeight=b2; |
| 17599 |
at.sof=-a*l.size(); |
| 17600 |
at.Label=QString("L%1").arg(ll++); |
| 17601 |
l.append(at); |
| 17602 |
// qDebug()<<n1.Label<<n2.Label<<tok.size(); |
| 17603 |
if (tok.size()>8) { |
| 17604 |
QString s2=s; |
| 17605 |
s2.remove(horse.Label); |
| 17606 |
//qDebug()<<s2<<ll; |
| 17607 |
|
| 17608 |
l.append(lonesome(s2,ll)); |
| 17609 |
} |
| 17610 |
} |
| 17611 |
break; |
| 17612 |
case 9:{ |
| 17613 |
j=0; |
| 17614 |
double d,soll=0,d2; |
| 17615 |
for (;j<mole.asymm.size();j++) { |
| 17616 |
if (mole.asymm.at(j).an<0) continue; |
| 17617 |
soll=(mole.Kovalenz_Radien[horse.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17618 |
d= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17619 |
if ((d>0.1)&&(d<soll)){ |
| 17620 |
n1=mole.asymm[j]; |
| 17621 |
j++; |
| 17622 |
break; |
| 17623 |
} |
| 17624 |
} |
| 17625 |
for (j=0;j<mole.asymm.size();j++) { |
| 17626 |
if (mole.asymm.at(j).an<0) continue; |
| 17627 |
soll=(mole.Kovalenz_Radien[n1.an]+ mole.Kovalenz_Radien[mole.asymm.at(j).an])*0.012; |
| 17628 |
d= sqrt(Distance(n1.pos,mole.asymm.at(j).pos)); |
| 17629 |
d2= sqrt(Distance(horse.pos,mole.asymm.at(j).pos)); |
| 17630 |
if ((d2>1.1)&&(d>0.1)&&(d<soll)){ |
| 17631 |
n2=mole.asymm[j]; |
| 17632 |
j++; |
| 17633 |
break; |
| 17634 |
} |
| 17635 |
} |
| 17636 |
V3 va= Normalize(n1.pos-horse.pos); |
| 17637 |
V3 vb= Normalize(n2.pos-n1.pos); |
| 17638 |
V3 ax1=Normalize(vb%va);//LLLL |
| 17639 |
V3 ax=Normalize(va%ax1);//LLLL |
| 17640 |
double phi=tok.last().toDouble(); |
| 17641 |
double rad=tok.at(tok.size()-2).toDouble(); |
| 17642 |
//qDebug()<<phi<<rad; |
| 17643 |
//qDebug()<<va.x<<va.y<<va.z; |
| 17644 |
//qDebug()<<vb.x<<vb.y<<vb.z; |
| 17645 |
phi*=M_PI/360.0;//we want /2 ! |
| 17646 |
V3 c=-cos(phi)*va; |
| 17647 |
if (rad<0) { |
| 17648 |
c=-1.0*c; |
| 17649 |
rad=-rad; |
| 17650 |
} |
| 17651 |
V3 v=sin(phi)*ax; |
| 17652 |
at.pos=horse.pos+(c+v)*rad; |
| 17653 |
at.uf=mole.u2b(horse.uf);//possible problem if U is not anisotrop |
| 17654 |
mole.kart2frac(at.pos,at.frac); |
| 17655 |
at.peakHeight=b1; |
| 17656 |
at.sof=a; |
| 17657 |
at.Label=QString("L%1").arg(ll++); |
| 17658 |
l.append(at); |
| 17659 |
at.pos=horse.pos+(c-v)*rad; |
| 17660 |
mole.kart2frac(at.pos,at.frac); |
| 17661 |
at.Label=QString("L%1").arg(ll++); |
| 17662 |
l.append(at); |
| 17663 |
at.pos=horse.pos; |
| 17664 |
at.frac=horse.frac; |
| 17665 |
at.peakHeight=b2; |
| 17666 |
at.sof=-a*l.size(); |
| 17667 |
at.Label=QString("L%1").arg(ll++); |
| 17668 |
l.append(at); |
| 17669 |
//qDebug()<<n1.Label<<n2.Label<<tok.size(); |
| 17670 |
if (tok.size()>8) { |
| 17671 |
QString s2=s; |
| 17672 |
s2.remove(horse.Label); |
| 17673 |
//qDebug()<<s2<<ll; |
| 17674 |
|
| 17675 |
l.append(lonesome(s2,ll)); |
| 17676 |
} |
| 17677 |
} |
| 17678 |
break; |
| 17679 |
default: |
| 17680 |
fprintf(stderr,"%d das kann ich noch nicht! %s\n",m,such.toStdString().c_str()); |
| 17681 |
infoKanalNews(QString("<H1>%1 das kann ich noch nicht! %2</H1>").arg(m).arg(such)); |
| 17682 |
} |
| 17683 |
} |
| 17684 |
// qDebug()<<m<<such<<tok.size(); |
| 17685 |
return l; |
| 17686 |
} |
| 17687 |
|
| 17688 |
void Window::exportFMaps(){ |
| 17689 |
QString al; |
| 17690 |
const double a0 = 0.52917720859; |
| 17691 |
int ina=0; |
| 17692 |
for (int i=0; i<mole.asymm.size();i++){ |
| 17693 |
if (mole.asymm[i].an<0) continue; |
| 17694 |
ina++; |
| 17695 |
} |
| 17696 |
for (int i=0; i<mole.asymm.size();i++){ |
| 17697 |
if (mole.asymm[i].an<0) continue; |
| 17698 |
mole.frac2kart(mole.asymm[i].frac,mole.asymm[i].pos); |
| 17699 |
al.append(QString("\n%1%2%3%4%5").arg(mole.asymm[i].an+1,5).arg(mole.asymm[i].an+1.0,12,'f',6).arg(mole.asymm[i].pos.x/a0,12,'f',6).arg(mole.asymm[i].pos.y/a0,12,'f',6).arg(mole.asymm[i].pos.z/a0,12,'f',6)); |
| 17700 |
} |
| 17701 |
fxle->exportMaps(ina, dirName.toStdString().c_str(), al.toStdString().c_str()); |
| 17702 |
|
| 17703 |
} |
| 17704 |
|
| 17705 |
void Window::toggDocWid(bool weg){ |
| 17706 |
if (weg) { |
| 17707 |
shxEditorDock->hide(); |
| 17708 |
shxOutputDock->hide(); |
| 17709 |
infotainmentDock->hide(); |
| 17710 |
dock->hide(); |
| 17711 |
renamDock->hide(); |
| 17712 |
histDock->hide(); |
| 17713 |
chgl->toggleDockWidgets->setText("Show Text Windows"); |
| 17714 |
} |
| 17715 |
else{ |
| 17716 |
shxEditorDock->show(); |
| 17717 |
histDock->show(); |
| 17718 |
dock->show(); |
| 17719 |
chgl->toggleDockWidgets->setText("Hide Text Windows"); |
| 17720 |
} |
| 17721 |
update(); |
| 17722 |
chgl->update(); |
| 17723 |
} |
| 17724 |
|
| 17725 |
void Window::convergeWght(){ |
| 17726 |
/*! \brief Update WHGT scheme and refine in a loop until scheme has converged or a maximum of runs has exceeded.*/ |
| 17727 |
if (mole.asymm.isEmpty()) return; |
| 17728 |
dirName.replace(punktins,".res"); |
| 17729 |
fileSave(); |
| 17730 |
finWasPressed=false; |
| 17731 |
wght_cycls=0; |
| 17732 |
xlPutor->clear(); |
| 17733 |
//xlPutor->highlighter->setOutputStyle(); |
| 17734 |
shxOutputDock->show(); |
| 17735 |
shxOutputDock->raise(); |
| 17736 |
//stoppRefinement->show(); |
| 17737 |
finishRefinement->show(); |
| 17738 |
loadRes->show(); |
| 17739 |
loadRes2->show(); |
| 17740 |
QObject::disconnect(stoppRefinement, 0, this, 0); |
| 17741 |
QObject::disconnect(finishRefinement, 0, this, 0); |
| 17742 |
refineButtonBox->hide(); |
| 17743 |
shxEditorDock->hide(); |
| 17744 |
dock->hide(); |
| 17745 |
histDock->hide(); |
| 17746 |
renamDock->hide(); |
| 17747 |
update(); |
| 17748 |
runXLWGHT(); |
| 17749 |
} |
| 17750 |
|
| 17751 |
void Window::finXL(){ |
| 17752 |
QString finname =dirName; |
| 17753 |
finname.replace(punktins,".res"); |
| 17754 |
finname.replace(punktres,".fin"); |
| 17755 |
QFile fin(finname); |
| 17756 |
fin.open(QIODevice::WriteOnly|QIODevice::Text); |
| 17757 |
fin.write("stopp",6); |
| 17758 |
fin.close(); |
| 17759 |
finishRefinement->hide(); |
| 17760 |
finishRefinement2->hide(); |
| 17761 |
printf("FINISH!\n%s was written so shelxl should end soon.\n",finname.toStdString().c_str()); |
| 17762 |
finWasPressed=true; |
| 17763 |
} |
| 17764 |
|
| 17765 |
void Window::runXLWGHT() { |
| 17766 |
update(); |
| 17767 |
QString dn=dirName.section('/',0,-2), |
| 17768 |
argument=dirName.section('/',-1); |
| 17769 |
argument.remove(resorins); |
| 17770 |
QStringList al; |
| 17771 |
al.append(argument); |
| 17772 |
defineBarray(); |
| 17773 |
al+=shelxlArgs.split(' ',skipEmptyParts); |
| 17774 |
shelxl = new QProcess(this); |
| 17775 |
shelxl->setWorkingDirectory(dn); // updateXLput() |
| 17776 |
// stoppRefinement->show(); |
| 17777 |
finishRefinement->show(); |
| 17778 |
finishRefinement->setFocus(); |
| 17779 |
refineButtonBox->hide(); |
| 17780 |
#if (QT_VERSION >= 0x060400) |
| 17781 |
connect(shelxl,&QProcess::readyReadStandardOutput,this,&Window::updateXLput); |
| 17782 |
connect(shelxl,&QProcess::finished, this, &Window::updateXLput); |
| 17783 |
connect(shelxl,&QProcess::finished, this, &Window::runXLWGHT); |
| 17784 |
connect(shelxl,&QProcess::errorOccurred,this,&Window::updateXLput); |
| 17785 |
#else |
| 17786 |
|
| 17787 |
connect(shelxl,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateXLput())); |
| 17788 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateXLput())); |
| 17789 |
connect(shelxl,SIGNAL(finished(int,QProcess::ExitStatus)),this ,SLOT(runXLWGHT())); |
| 17790 |
connect(shelxl,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateXLput())); |
| 17791 |
#endif |
| 17792 |
|
| 17793 |
connect(finishRefinement,SIGNAL(clicked()),this,SLOT(finXL()));; |
| 17794 |
shxOutputDock->show(); |
| 17795 |
shxOutputDock->raise(); |
| 17796 |
QFile test; |
| 17797 |
QStringList alltest; |
| 17798 |
QString alls; |
| 17799 |
test.setFileName(dirName); |
| 17800 |
QStringList wghts; |
| 17801 |
if (test.exists()&&test.size()){ |
| 17802 |
test.open(QIODevice::ReadOnly|QIODevice::Text); |
| 17803 |
alls=test.readAll(); |
| 17804 |
alltest=alls.split('\n'); |
| 17805 |
wghts=alltest.filter(QRegularExpression("^WGHT.*$",QRegularExpression::CaseInsensitiveOption)); |
| 17806 |
if ((wghts.size()>1)&&(wght_cycls<qMax(1,wght_max_cycls))) alls.replace(wghts.at(0),wghts.at(1)); |
| 17807 |
else if (wghts.size()<2) { |
| 17808 |
alls.replace(wghts.at(0),"WGHT 0.2!default"); |
| 17809 |
//printf("WGHT %s ==>>%d<==%d\n",wghts.at(0).toStdString().c_str(),wghts.size(),wght_cycls); |
| 17810 |
} |
| 17811 |
for (int i=0; i<wghts.size();i++) { |
| 17812 |
wghts[i].remove(QRegularExpression("\\b0\\.[0]+\\b")); |
| 17813 |
wghts[i].remove(QRegularExpression("\\B[0]+ ")); |
| 17814 |
wghts[i].remove(QRegularExpression("\\B[0]+$")); |
| 17815 |
wghts[i] = wghts.at(i).simplified(); |
| 17816 |
} |
| 17817 |
test.close(); |
| 17818 |
test.open(QIODevice::WriteOnly|QIODevice::Text); |
| 17819 |
test.write(alls.toLatin1()); |
| 17820 |
test.close(); |
| 17821 |
}else{loadRes->setEnabled(false);} |
| 17822 |
xlPutor->ListFile=false; |
| 17823 |
QString s=xlPutor->toPlainText(); |
| 17824 |
/*I think this is good for nothing a job that has not ben started can't have output. Device not open on Qt5 |
| 17825 |
if ((s.isEmpty())&&(shelxl->isOpen())) { |
| 17826 |
//qDebug()<<"what am I doing here?"; |
| 17827 |
s.append(shelxl->readAllStandardOutput()); |
| 17828 |
s.append(shelxl->readAllStandardError()); |
| 17829 |
} |
| 17830 |
*/ |
| 17831 |
bool same = ((wghts.size()>1)&&(wghts.at(0)==wghts.at(1))); |
| 17832 |
double tol=0.0,difsum=0.0; |
| 17833 |
if ((wghts.size()>1)&&(!same)) { |
| 17834 |
difsum=0.0; |
| 17835 |
tol=0.008; |
| 17836 |
same = compareWGHTS(wghts.at(0), wghts.at(1),difsum,tol); |
| 17837 |
} |
| 17838 |
s.append(QString("############################\n%1\n%2\nConverged: %3\nafter %4 runs (tolerance %5 sum of differences %6).\n############################\n") |
| 17839 |
.arg((wghts.size()>0)?wghts.at(0):"WGHT 0.2!default") |
| 17840 |
.arg((wghts.size()>1)?wghts.at(1):"WGHT 0.2!default") |
| 17841 |
.arg((same)?"Yes":"No") |
| 17842 |
.arg(wght_cycls) |
| 17843 |
.arg(tol) |
| 17844 |
.arg(difsum) |
| 17845 |
// .arg(wghts.at(0)) |
| 17846 |
// .arg(wghts.at(1)) |
| 17847 |
); |
| 17848 |
xlPutor->setPlainText(s); |
| 17849 |
QTextCursor tc = xlPutor->textCursor(); |
| 17850 |
tc.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); |
| 17851 |
xlPutor->setTextCursor(tc); |
| 17852 |
xlPutor->ensureCursorVisible(); |
| 17853 |
update(); |
| 17854 |
|
| 17855 |
if (same) { |
| 17856 |
stoppRefinement->hide(); |
| 17857 |
refineButtonBox->show(); |
| 17858 |
loadRes->setEnabled((s.contains("for all data"))||(s.contains("Converged: Yes"))); |
| 17859 |
stoppRefinement2->hide(); |
| 17860 |
finishRefinement2->hide(); |
| 17861 |
finishRefinement->hide(); |
| 17862 |
refineButtonBox2->show(); |
| 17863 |
loadRes2->setEnabled(loadRes->isEnabled()); |
| 17864 |
QTextCursor tc = xlPutor->textCursor(); |
| 17865 |
tc.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); |
| 17866 |
xlPutor->setTextCursor(tc); |
| 17867 |
xlPutor->ensureCursorVisible(); |
| 17868 |
update(); |
| 17869 |
return; |
| 17870 |
} |
| 17871 |
bool endd = (wght_cycls>=wght_max_cycls); |
| 17872 |
if ((wght_max_cycls<0)) endd = false; |
| 17873 |
if ((!loadRes->isEnabled())||(endd)||finWasPressed) { |
| 17874 |
stoppRefinement->hide(); |
| 17875 |
finishRefinement->hide(); |
| 17876 |
refineButtonBox->show(); |
| 17877 |
loadRes->setEnabled((s.contains("for all data"))); |
| 17878 |
stoppRefinement2->hide(); |
| 17879 |
finishRefinement2->hide(); |
| 17880 |
refineButtonBox2->show(); |
| 17881 |
loadRes2->setEnabled(loadRes->isEnabled()); |
| 17882 |
QTextCursor tc = xlPutor->textCursor(); |
| 17883 |
tc.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); |
| 17884 |
xlPutor->setTextCursor(tc); |
| 17885 |
xlPutor->ensureCursorVisible(); |
| 17886 |
update(); |
| 17887 |
return; |
| 17888 |
} |
| 17889 |
if (dirName.contains(punktres)){ |
| 17890 |
QString insname =dirName; |
| 17891 |
insname.replace(punktres,".ins"); |
| 17892 |
|
| 17893 |
QString fcfname = dirName; |
| 17894 |
fcfname.replace(punktres,".fcf"); |
| 17895 |
QString fcfname2 = dirName; |
| 17896 |
fcfname2.replace(punktres,".2fcf"); |
| 17897 |
if (QFileInfo(dirName).lastModified()>=QFileInfo(insname).lastModified()){ |
| 17898 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 17899 |
QStringList filter; |
| 17900 |
filter << QString("%1_*_.ins").arg(argument); |
| 17901 |
QStringList resfs; |
| 17902 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 17903 |
int vers=0; |
| 17904 |
if (resfs.isEmpty()) vers=1; |
| 17905 |
else { |
| 17906 |
bool ok=true; |
| 17907 |
for (int i = 0; i < resfs.size(); i++) |
| 17908 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 17909 |
vers++; |
| 17910 |
} |
| 17911 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 17912 |
QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 17913 |
QFile::remove(insname); |
| 17914 |
QFile::copy(dirName,insname); |
| 17915 |
QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 17916 |
QFile::remove(fcfname2); |
| 17917 |
QFile::copy(fcfname,fcfname2); |
| 17918 |
} else { |
| 17919 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 17920 |
QStringList filter; |
| 17921 |
filter << QString("%1_*_.ins").arg(argument); |
| 17922 |
QStringList resfs; |
| 17923 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 17924 |
int vers=0; |
| 17925 |
if (resfs.isEmpty()) vers=1; |
| 17926 |
else { |
| 17927 |
bool ok=true; |
| 17928 |
for (int i = 0; i < resfs.size(); i++) |
| 17929 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 17930 |
vers++; |
| 17931 |
} |
| 17932 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 17933 |
QFile::copy(insname,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 17934 |
QFile::remove(insname); |
| 17935 |
QFile::copy(dirName,insname); |
| 17936 |
|
| 17937 |
QFile::copy(fcfname2,QString("%1/%4saves/%2_%3_.fcf").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 17938 |
QFile::remove(fcfname2); |
| 17939 |
QFile::copy(fcfname,fcfname2); |
| 17940 |
} |
| 17941 |
} else { |
| 17942 |
QDir work=QDir(QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 17943 |
QStringList filter; |
| 17944 |
filter << QString("%1_*_.ins").arg(argument); |
| 17945 |
QStringList resfs; |
| 17946 |
resfs=work.entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 17947 |
int vers=0; |
| 17948 |
if (resfs.isEmpty()) vers=1; |
| 17949 |
else { |
| 17950 |
bool ok=true; |
| 17951 |
for (int i = 0; i < resfs.size(); i++) |
| 17952 |
vers = qMax(resfs.at(i).section("_",-2,-2).toInt(&ok,36),vers); |
| 17953 |
vers++; |
| 17954 |
} |
| 17955 |
if (!work.exists ( QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME))) work.mkdir (QString("%1/%2saves/").arg(dn).arg(PROGRAM_NAME)); |
| 17956 |
QFile::copy(dirName,QString("%1/%4saves/%2_%3_.ins").arg(dn).arg(argument).arg(vers,2,36,QLatin1Char('0')).arg(PROGRAM_NAME)); |
| 17957 |
} |
| 17958 |
shxOutputDock->setWindowTitle(QString("SHELXL OUTPUT: %1").arg(argument)); |
| 17959 |
shelxl->start(shelxlPath,al); |
| 17960 |
wght_cycls++; |
| 17961 |
} |
| 17962 |
|
| 17963 |
bool Window::compareWGHTS(QString w1, QString w2, double &diff, double tolerance){ |
| 17964 |
QStringList Ws1, Ws2; |
| 17965 |
QList<double> Wd1, Wd2; |
| 17966 |
Ws1 = w1.split(leer); |
| 17967 |
Ws2 = w2.split(leer); |
| 17968 |
for (int i = 1; i < Ws1.size(); i++) Wd1.append(Ws1.at(i).toDouble());//0th element will be 'wght' so we don't need it for comarison |
| 17969 |
for (int i = 1; i < Ws2.size(); i++) Wd2.append(Ws2.at(i).toDouble()); |
| 17970 |
bool same = true; |
| 17971 |
if (Wd1.size() == Wd2.size()) { |
| 17972 |
for (int i=0; i < Wd1.size(); i++){ |
| 17973 |
same = (same) && (fabs(Wd1.at(i) - Wd2.at(i)) < tolerance); |
| 17974 |
diff+=fabs(Wd1.at(i) - Wd2.at(i)); |
| 17975 |
} |
| 17976 |
}else return false; |
| 17977 |
return same; |
| 17978 |
} |
| 17979 |
|
| 17980 |
void Window::togSop(bool b){ |
| 17981 |
QGroupBox *gpx= qobject_cast<QGroupBox *>(sender()); |
| 17982 |
int nn=gpx->objectName().section('=',1,1).toInt(); |
| 17983 |
if (b) chgl->mol->dontshowSop.removeOne(nn); |
| 17984 |
else chgl->mol->dontshowSop.append(nn); |
| 17985 |
chgl->update(); |
| 17986 |
} |
| 17987 |
|
| 17988 |
void Window::togSel(bool b){ |
| 17989 |
QCheckBox *cbx= qobject_cast<QCheckBox *>(sender()); |
| 17990 |
int nn=cbx->objectName().section('=',1,1).toInt(); |
| 17991 |
if (b) chgl->mol->dontshowSel.removeOne(nn); |
| 17992 |
else chgl->mol->dontshowSel.append(nn); |
| 17993 |
chgl->update(); |
| 17994 |
} |
| 17995 |
|
| 17996 |
void Window::changeInvRad(double r){ |
| 17997 |
chgl->InversionCenterRadius=r; |
| 17998 |
update(); |
| 17999 |
chgl->update(); |
| 18000 |
} |
| 18001 |
|
| 18002 |
void Window::changePlaneTransparence(double t){ |
| 18003 |
chgl->planeTransparence=t; |
| 18004 |
update(); |
| 18005 |
chgl->update(); |
| 18006 |
} |
| 18007 |
|
| 18008 |
void Window::changeglideVectorThickness(double t){ |
| 18009 |
chgl->glideVectorThickness=t; |
| 18010 |
update(); |
| 18011 |
chgl->update(); |
| 18012 |
} |
| 18013 |
|
| 18014 |
void Window::changeaxisThickness(double t){ |
| 18015 |
chgl->axisThickness=t; |
| 18016 |
update(); |
| 18017 |
chgl->update(); |
| 18018 |
} |
| 18019 |
void Window::changeplaneFrameThinkness(double t){ |
| 18020 |
chgl->planeFrameThinkness=t; |
| 18021 |
update(); |
| 18022 |
chgl->update(); |
| 18023 |
} |
| 18024 |
|
| 18025 |
void Window::sColorDLG(){ |
| 18026 |
QPushButton *but= qobject_cast<QPushButton *>(sender()); |
| 18027 |
QString style = but->styleSheet();// the styl contains the color we want to change here |
| 18028 |
QString cn=but->objectName(); |
| 18029 |
int nn=cn.section('=',1,1).toInt();// which color we want to change |
| 18030 |
QList<QPushButton*>bbs = findChildren<QPushButton*>(cn); |
| 18031 |
int z=bbs.size(); |
| 18032 |
//printf("%d %d %p %p\n",nn,z,but,bbs[0]); |
| 18033 |
|
| 18034 |
//qDebug()<<cn<<cn.section('=',1,1)<<nn; |
| 18035 |
QColor c = QColor("#" + style.split(QRegularExpression("#|,")).at(7)); |
| 18036 |
c = QColorDialog::getColor(c, this); |
| 18037 |
if (c.isValid()) { |
| 18038 |
chgl->mol->symmColors[nn]=c; |
| 18039 |
//* |
| 18040 |
einstellung->beginGroup("SymmetryElements"); |
| 18041 |
einstellung->beginWriteArray("SymmetryElementColors",107); |
| 18042 |
for (int i = 0; i < 18; ++i) { |
| 18043 |
einstellung->setArrayIndex(i); |
| 18044 |
einstellung->setValue("Color", chgl->mol->symmColors[i]); |
| 18045 |
} |
| 18046 |
einstellung->endArray(); |
| 18047 |
einstellung->endGroup(); |
| 18048 |
einstellung->sync(); |
| 18049 |
// */ |
| 18050 |
for (int i=0; i<z; i++) bbs[i]->setStyleSheet(QString( |
| 18051 |
"QPushButton {" |
| 18052 |
"border: 1px solid #00ff00;" |
| 18053 |
"border-radius: 3px;" |
| 18054 |
"color: %4;" |
| 18055 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);" |
| 18056 |
"}" |
| 18057 |
"QPushButton:hover {" |
| 18058 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);" |
| 18059 |
"}" |
| 18060 |
"QPushButton:pressed {" |
| 18061 |
" border: none; /* no border for a flat push button */" |
| 18062 |
"}" |
| 18063 |
) |
| 18064 |
.arg(c.name()) |
| 18065 |
.arg(c.darker(50).name()) |
| 18066 |
.arg(c.lighter(100).name()) |
| 18067 |
.arg((c.lightness()<130)?"#ffffff":"#000000")); |
| 18068 |
} |
| 18069 |
} |
| 18070 |
|
| 18071 |
void Window::symmElements(bool b){ |
| 18072 |
if (!b){ |
| 18073 |
mole.axvecs.clear(); |
| 18074 |
mole.ptriangles.clear(); |
| 18075 |
mole.axcols.clear(); |
| 18076 |
mole.axoprs.clear(); |
| 18077 |
mole.dontshowSel.clear(); |
| 18078 |
mole.dontshowSop.clear(); |
| 18079 |
mole.invoprs.clear(); |
| 18080 |
mole.invvecs.clear(); |
| 18081 |
QDialog *seDlg_ = findChild<QDialog *>("symmElementsDialog"); |
| 18082 |
if (seDlg_!=nullptr) seDlg_->close(); |
| 18083 |
chgl->makeSymmetryElements(); |
| 18084 |
chgl->update(); |
| 18085 |
return; |
| 18086 |
} |
| 18087 |
if (mole.asymm.isEmpty()) return; |
| 18088 |
QDialog *seDlg = new QDialog(this); |
| 18089 |
seDlg->setObjectName("symmElementsDialog"); |
| 18090 |
seDlg->setMinimumWidth(450); |
| 18091 |
seDlg->setAttribute(Qt::WA_DeleteOnClose); |
| 18092 |
seDlg->setWindowTitle("Symmetry Elements"); |
| 18093 |
QGroupBox *gpx =new QGroupBox("Show symmetry elements",seDlg); |
| 18094 |
gpx->setMinimumWidth(400); |
| 18095 |
QVBoxLayout *vbl = new QVBoxLayout(); |
| 18096 |
QList<QCheckBox *> alleboxen; |
| 18097 |
QStringList snn; |
| 18098 |
snn<<"1" <<"2" <<"3" <<"4" <<"6" |
| 18099 |
<<"-1" <<"m" <<"-3" <<"-4" <<"-6" |
| 18100 |
<<"2_1"<<"3_x" <<"4_x" <<"6_x" |
| 18101 |
<<"g" <<"-3_x"<<"-4_x"<<"-6_x"; |
| 18102 |
mole.findSymmElements(); |
| 18103 |
QGridLayout *hbl0 = new QGridLayout(); |
| 18104 |
for (int i=0,j=0; i<18; i++){ |
| 18105 |
if ((i>5)&&(j%5==0)) j++; |
| 18106 |
//int colori=27+j; |
| 18107 |
QColor c=chgl->mol->symmColors.at(i);//QColor::colorNames().at(colori); |
| 18108 |
QPushButton *colbut = new QPushButton(snn.at(i),seDlg); |
| 18109 |
colbut->setObjectName(QString("color=%1").arg(i)); |
| 18110 |
connect(colbut,SIGNAL(pressed()),this,SLOT(sColorDLG())); |
| 18111 |
QCheckBox *fldchk = new QCheckBox(seDlg); |
| 18112 |
fldchk->setObjectName(QString("Symmetry Element type=%1").arg(i)); |
| 18113 |
fldchk->setChecked(true); |
| 18114 |
connect(fldchk,SIGNAL(toggled(bool)),this,SLOT(togSel(bool))); |
| 18115 |
if (i==0)fldchk->setDisabled(true); |
| 18116 |
colbut->setMinimumWidth(50); |
| 18117 |
colbut->setStyleSheet(QString( |
| 18118 |
"QPushButton {" |
| 18119 |
"border: 1px solid #00ff00;" |
| 18120 |
"border-radius: 3px;" |
| 18121 |
"color: %4;" |
| 18122 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);" |
| 18123 |
"}" |
| 18124 |
"QPushButton:hover {" |
| 18125 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);" |
| 18126 |
"}" |
| 18127 |
"QPushButton:pressed {" |
| 18128 |
" border: none; /* no border for a flat push button */" |
| 18129 |
"}" |
| 18130 |
) |
| 18131 |
.arg(c.name()) |
| 18132 |
.arg(c.darker(50).name()) |
| 18133 |
.arg(c.lighter(100).name()) |
| 18134 |
.arg((c.lightness()<130)?"#ffffff":"#000000")); |
| 18135 |
hbl0->addWidget(colbut,j/5,(j%5)*2+1,Qt::AlignLeft); |
| 18136 |
hbl0->addWidget(fldchk,j/5,(j%5)*2,Qt::AlignRight); |
| 18137 |
j++; |
| 18138 |
} |
| 18139 |
QDoubleSpinBox *invrad = new QDoubleSpinBox(this); |
| 18140 |
invrad->setMinimum(0.02); |
| 18141 |
invrad->setMaximum(0.5); |
| 18142 |
invrad->setValue(chgl->InversionCenterRadius); |
| 18143 |
invrad->setSingleStep(0.01); |
| 18144 |
connect(invrad,SIGNAL(valueChanged(double)),this,SLOT(changeInvRad(double))); |
| 18145 |
QDoubleSpinBox *planeTransparence = new QDoubleSpinBox(this); |
| 18146 |
planeTransparence->setMinimum(0.01); |
| 18147 |
planeTransparence->setMaximum(1.0); |
| 18148 |
planeTransparence->setValue(chgl->planeTransparence); |
| 18149 |
planeTransparence->setSingleStep(0.01); |
| 18150 |
connect(planeTransparence,SIGNAL(valueChanged(double)),this,SLOT(changePlaneTransparence(double))); |
| 18151 |
|
| 18152 |
QDoubleSpinBox *planeFrameThinkness = new QDoubleSpinBox(this); |
| 18153 |
planeFrameThinkness->setMinimum(0.01); |
| 18154 |
planeFrameThinkness->setMaximum(0.3); |
| 18155 |
planeFrameThinkness->setValue(chgl->planeFrameThinkness); |
| 18156 |
planeFrameThinkness->setSingleStep(0.01); |
| 18157 |
connect(planeFrameThinkness,SIGNAL(valueChanged(double)),this,SLOT(changeplaneFrameThinkness(double))); |
| 18158 |
|
| 18159 |
QDoubleSpinBox *axisThickness = new QDoubleSpinBox(this); |
| 18160 |
axisThickness->setMinimum(0.01); |
| 18161 |
axisThickness->setMaximum(0.3); |
| 18162 |
axisThickness->setValue(chgl->axisThickness); |
| 18163 |
axisThickness->setSingleStep(0.01); |
| 18164 |
connect(axisThickness,SIGNAL(valueChanged(double)),this,SLOT(changeaxisThickness(double))); |
| 18165 |
|
| 18166 |
QDoubleSpinBox *glideVectorThickness = new QDoubleSpinBox(this); |
| 18167 |
glideVectorThickness->setMinimum(0.01); |
| 18168 |
glideVectorThickness->setMaximum(0.3); |
| 18169 |
glideVectorThickness->setValue(chgl->glideVectorThickness); |
| 18170 |
glideVectorThickness->setSingleStep(0.01); |
| 18171 |
|
| 18172 |
connect(glideVectorThickness,SIGNAL(valueChanged(double)),this,SLOT(changeglideVectorThickness(double))); |
| 18173 |
hbl0->addWidget(new QLabel("Inversion center radius",this),6,0,1,3); |
| 18174 |
hbl0->addWidget(invrad,6,3,1,2); |
| 18175 |
hbl0->addWidget(new QLabel("Plane transparence",this),6,5,1,4); |
| 18176 |
hbl0->addWidget(planeTransparence,6,8,1,2); |
| 18177 |
|
| 18178 |
hbl0->addWidget(new QLabel("Plane Frame Thickness",this),7,0,1,3); |
| 18179 |
hbl0->addWidget(planeFrameThinkness,7,3,1,2); |
| 18180 |
hbl0->addWidget(new QLabel("Glide Vector Thickness",this),7,5,1,4); |
| 18181 |
hbl0->addWidget(glideVectorThickness,7,8,1,2); |
| 18182 |
hbl0->addWidget(new QLabel("Axis Thickness",this),8,0,1,3); |
| 18183 |
hbl0->addWidget(axisThickness,8,3,1,2); |
| 18184 |
|
| 18185 |
vbl->addLayout(hbl0); |
| 18186 |
for (int n=0; n<mole.cell.symmops.size(); n++){ |
| 18187 |
int fold=0; |
| 18188 |
V3 axis; |
| 18189 |
QString sname=mole.nameSymmOp(mole.cell.symmops.at(n),fold,axis); |
| 18190 |
V3 p = V3(0,0,0); |
| 18191 |
QList<V3>pts; |
| 18192 |
chgl->mol->specialPts(mole.cell.symmops.at(n),mole.cell.trans.at(n),pts); |
| 18193 |
if (!pts.isEmpty()) p=pts.at(0); |
| 18194 |
pts.clear(); |
| 18195 |
V3 pp = mole.cell.symmops.at(n) * p + mole.cell.trans.at(n); |
| 18196 |
pp.x = pp.x - floor(pp.x+0.01); |
| 18197 |
pp.y = pp.y - floor(pp.y+0.01); |
| 18198 |
pp.z = pp.z - floor(pp.z+0.01); |
| 18199 |
//V3 tfz=(pp-p); |
| 18200 |
//printf("%g %g %g %g %g %g %g %g %g axis %g %g %g\n",pp.x,pp.y,pp.z, p.x,p.y,p.z, tfz.x,tfz.y,tfz.z, axis.x,axis.y,axis.z); |
| 18201 |
double screwy = (fold==-2)?0.0:sqrt(Norm(pp-p)); |
| 18202 |
V3 screw = screwy * axis; |
| 18203 |
|
| 18204 |
screw.x = screw.x - floor(screw.x+0.01); |
| 18205 |
screw.y = screw.y - floor(screw.y+0.01); |
| 18206 |
screw.z = screw.z - floor(screw.z+0.01); |
| 18207 |
V3 glide= V3(0,0,0); |
| 18208 |
if (fold==-2){ |
| 18209 |
glide = mole.cell.symmops.at(n) * mole.cell.trans.at(n); |
| 18210 |
glide = (mole.cell.trans.at(n) + glide) * 0.5; |
| 18211 |
} |
| 18212 |
bool isTrans=(Norm(glide)>0.01)||(Norm(screw)>0.01); |
| 18213 |
QString schraubstock=(isTrans)?QString("(%1,%2,%3)").arg(screw.x+glide.x).arg(screw.y+glide.y).arg(screw.z+glide.z):""; |
| 18214 |
QString shname=chgl->mol->symmcode2human(n); |
| 18215 |
QGroupBox *gpx2 = new QGroupBox(QString("#%1 '%2' %3 %4").arg(n+1).arg(shname).arg(sname).arg(schraubstock),seDlg); |
| 18216 |
gpx2->setCheckable(true); |
| 18217 |
gpx2->setChecked(true); |
| 18218 |
if (fold==1){ |
| 18219 |
gpx2->setEnabled(false); |
| 18220 |
} |
| 18221 |
gpx2->setObjectName(QString("%1=%2").arg(shname).arg(n)); |
| 18222 |
gpx2->setMinimumWidth(380); |
| 18223 |
connect(gpx2,SIGNAL(toggled(bool)),this,SLOT(togSop(bool))); |
| 18224 |
//int colori=26+abs(fold); |
| 18225 |
//colori+=(fold<0)?5:0; |
| 18226 |
//colori+=(isTrans)?10:0; |
| 18227 |
int colorj=abs(fold)-1; |
| 18228 |
colorj+=(fold<0)?5:0; |
| 18229 |
colorj+=(fold==6)?-1:0; |
| 18230 |
colorj+=(fold==-6)?-1:0; |
| 18231 |
colorj+=(isTrans)?9:0; |
| 18232 |
colorj+=((isTrans)&&(fold<0))?-1:0; |
| 18233 |
//printf("colori = %d fold = %d trans = %d\n",colorj,fold,isTrans); |
| 18234 |
QColor c=chgl->mol->symmColors.at(colorj);//QColor::colorNames().at(colori); |
| 18235 |
QPushButton *colbut = new QPushButton(shname, seDlg); |
| 18236 |
colbut->setStyleSheet(QString( |
| 18237 |
"QPushButton {" |
| 18238 |
"border: 1px solid #00ff00;" |
| 18239 |
"border-radius: 3px;" |
| 18240 |
"color: %4;" |
| 18241 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %3, stop: 1 %2);" |
| 18242 |
"}" |
| 18243 |
"QPushButton:hover {" |
| 18244 |
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %1, stop: 1 %2);" |
| 18245 |
"}" |
| 18246 |
"QPushButton:pressed {" |
| 18247 |
" border: none; /* no border for a flat push button */" |
| 18248 |
"}" |
| 18249 |
) |
| 18250 |
.arg(c.name()) |
| 18251 |
.arg(c.darker(50).name()) |
| 18252 |
.arg(c.lighter(100).name()) |
| 18253 |
.arg((c.lightness()<130)?"#ffffff":"#000000")); |
| 18254 |
colbut->setObjectName(QString("color=%1").arg(colorj)); |
| 18255 |
connect(colbut,SIGNAL(pressed()),this,SLOT(sColorDLG())); |
| 18256 |
QHBoxLayout *hbl1 = new QHBoxLayout(); |
| 18257 |
hbl1->addWidget(colbut); |
| 18258 |
gpx2->setLayout(hbl1); |
| 18259 |
vbl->addWidget(gpx2); |
| 18260 |
/* |
| 18261 |
alleboxen.append(boxen); |
| 18262 |
for (int j=0;j<boxen.size();j++){ |
| 18263 |
int idx=1<<j; |
| 18264 |
boxen[j]->setChecked(mole.asymm.at(i).fixFlag&idx); |
| 18265 |
map->setMapping(boxen[j],allIx++); |
| 18266 |
connect(boxen[j], SIGNAL(stateChanged(int)), map, SLOT(map())); |
| 18267 |
} |
| 18268 |
*/ |
| 18269 |
} |
| 18270 |
//connect(map, SIGNAL(mapped(int)), this, SLOT(changeFixes(int))); |
| 18271 |
gpx->setLayout(vbl); |
| 18272 |
QVBoxLayout *la = new QVBoxLayout(); |
| 18273 |
QScrollArea *qsa = new QScrollArea(seDlg); |
| 18274 |
qsa->setWidget(gpx); |
| 18275 |
la->addWidget(qsa); |
| 18276 |
seDlg->setLayout(la); |
| 18277 |
seDlg->show(); |
| 18278 |
printf("SYMM SALA BUMM!\n %d %d %d\n", chgl->mol->axvecs.size(), chgl->mol->invvecs.size(), chgl->mol->ptriangles.size()); |
| 18279 |
chgl->makeSymmetryElements(); |
| 18280 |
chgl->update(); |
| 18281 |
} |
| 18282 |
|
| 18283 |
void Window::fixIt(){ |
| 18284 |
if (mole.asymm.isEmpty()) return; |
| 18285 |
QDialog *fixDlg = new QDialog(this); |
| 18286 |
QGroupBox *gpx =new QGroupBox("Checked parameters will not be refined.",fixDlg); |
| 18287 |
QVBoxLayout *vbl = new QVBoxLayout(); |
| 18288 |
QList<QCheckBox *> alleboxen; |
| 18289 |
QSignalMapper *map = new QSignalMapper(this); |
| 18290 |
int allIx=0; |
| 18291 |
for (int i=0; i<mole.asymm.size(); i++){ |
| 18292 |
allIx=10*i; |
| 18293 |
if (mole.asymm.at(i).an<0) continue; |
| 18294 |
QGroupBox *gpx2 = new QGroupBox(mole.asymm.at(i).Label,fixDlg); |
| 18295 |
QList<QCheckBox *> boxen; |
| 18296 |
gpx2->setAlignment(Qt::AlignRight); |
| 18297 |
QVBoxLayout *v = new QVBoxLayout(gpx2); |
| 18298 |
QHBoxLayout *hbl1 = new QHBoxLayout(); |
| 18299 |
QCheckBox *Xlab = new QCheckBox(QString::number(mole.asymm.at(i).frac.x,'f',6).prepend("X: "),fixDlg); |
| 18300 |
QCheckBox *Ylab = new QCheckBox(QString::number(mole.asymm.at(i).frac.y,'f',6).prepend("Y: "),fixDlg); |
| 18301 |
QCheckBox *Zlab = new QCheckBox(QString::number(mole.asymm.at(i).frac.z,'f',6).prepend("Z: "),fixDlg); |
| 18302 |
QCheckBox *Olab = new QCheckBox(QString::number(mole.asymm.at(i).sof,'f',6).prepend("site occupancy: "),fixDlg); |
| 18303 |
hbl1->addWidget(Xlab); |
| 18304 |
hbl1->addWidget(Ylab); |
| 18305 |
hbl1->addWidget(Zlab); |
| 18306 |
hbl1->addWidget(Olab); |
| 18307 |
boxen.append(Xlab); |
| 18308 |
boxen.append(Ylab); |
| 18309 |
boxen.append(Zlab); |
| 18310 |
boxen.append(Olab); |
| 18311 |
v->addLayout(hbl1); |
| 18312 |
if (!mole.asymm.at(i).isIso) { |
| 18313 |
QHBoxLayout *hbl2 = new QHBoxLayout(); |
| 18314 |
QCheckBox *M11lab = new QCheckBox(QString::number(mole.asymm.at(i).uf.m11,'f',6).prepend("U11: "),fixDlg); |
| 18315 |
QCheckBox *M22lab = new QCheckBox(QString::number(mole.asymm.at(i).uf.m22,'f',6).prepend("U22: "),fixDlg); |
| 18316 |
QCheckBox *M33lab = new QCheckBox(QString::number(mole.asymm.at(i).uf.m33,'f',6).prepend("U33: "),fixDlg); |
| 18317 |
QCheckBox *M23lab = new QCheckBox(QString::number(mole.asymm.at(i).uf.m23,'f',6).prepend("U23: "),fixDlg); |
| 18318 |
QCheckBox *M13lab = new QCheckBox(QString::number(mole.asymm.at(i).uf.m13,'f',6).prepend("U13: "),fixDlg); |
| 18319 |
QCheckBox *M12lab = new QCheckBox(QString::number(mole.asymm.at(i).uf.m12,'f',6).prepend("U12: "),fixDlg); |
| 18320 |
hbl2->addWidget(M11lab); |
| 18321 |
hbl2->addWidget(M22lab); |
| 18322 |
hbl2->addWidget(M33lab); |
| 18323 |
hbl2->addWidget(M23lab); |
| 18324 |
hbl2->addWidget(M13lab); |
| 18325 |
hbl2->addWidget(M12lab); |
| 18326 |
boxen.append(M11lab); |
| 18327 |
boxen.append(M22lab); |
| 18328 |
boxen.append(M33lab); |
| 18329 |
boxen.append(M23lab); |
| 18330 |
boxen.append(M13lab); |
| 18331 |
boxen.append(M12lab); |
| 18332 |
v->addLayout(hbl2); |
| 18333 |
} |
| 18334 |
vbl->addWidget(gpx2); |
| 18335 |
alleboxen.append(boxen); |
| 18336 |
for (int j=0;j<boxen.size();j++){ |
| 18337 |
int idx=1<<j; |
| 18338 |
boxen[j]->setChecked(mole.asymm.at(i).fixFlag&idx); |
| 18339 |
map->setMapping(boxen[j],allIx++); |
| 18340 |
connect(boxen[j], SIGNAL(stateChanged(int)), map, SLOT(map())); |
| 18341 |
} |
| 18342 |
|
| 18343 |
|
| 18344 |
} |
| 18345 |
#if (QT_VERSION >= 0x050f00) |
| 18346 |
//connect(map, SIGNAL(mappedInt(int)), this, SLOT(changeFixes(int))); |
| 18347 |
connect(map, &QSignalMapper::mappedInt, this, &Window::changeFixes); |
| 18348 |
//printf("QT_VERSION %x %s \n",QT_VERSION,(QT_VERSION >= 0x050f00)?"true":"false"); |
| 18349 |
#else |
| 18350 |
connect(map, SIGNAL(mapped(int)), this, SLOT(changeFixes(int))); |
| 18351 |
//printf("Why? QT_VERSION %x %s \n",QT_VERSION,(QT_VERSION >= 0x050f00)?"true":"false"); |
| 18352 |
#endif |
| 18353 |
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel,Qt::Horizontal,fixDlg); |
| 18354 |
connect(bb, SIGNAL(accepted()), fixDlg, SLOT(accept())); |
| 18355 |
connect(bb, SIGNAL(rejected()), fixDlg, SLOT(reject())); |
| 18356 |
gpx->setLayout(vbl); |
| 18357 |
QVBoxLayout *la = new QVBoxLayout(); |
| 18358 |
QScrollArea *qsa = new QScrollArea(fixDlg); |
| 18359 |
qsa->setWidget(gpx); |
| 18360 |
la->addWidget(qsa); |
| 18361 |
la->addWidget(bb); |
| 18362 |
fixDlg->setLayout(la); |
| 18363 |
fixDlg->exec(); |
| 18364 |
fixDlg->deleteLater(); |
| 18365 |
|
| 18366 |
} |
| 18367 |
|
| 18368 |
void Window::changeFixes(int i){ |
| 18369 |
int da=i/10; |
| 18370 |
int blub=i%10; |
| 18371 |
int vor=-1; |
| 18372 |
if (da<mole.asymm.size()){ |
| 18373 |
|
| 18374 |
vor=mole.asymm[da].fixFlag; |
| 18375 |
if (vor&(1<<blub)) { |
| 18376 |
mole.asymm[da].fixFlag-=1<<blub; |
| 18377 |
} else { |
| 18378 |
mole.asymm[da].fixFlag|=1<<blub; |
| 18379 |
} |
| 18380 |
jumpToAtom(da); |
| 18381 |
QTextCursor c = editor->textCursor(); |
| 18382 |
c.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 18383 |
if (c.selectedText().contains("=")) { |
| 18384 |
c.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor); |
| 18385 |
c.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor); |
| 18386 |
} |
| 18387 |
int end= (mole.asymm.at(da).isIso)?4:10; |
| 18388 |
QString sn=c.selectedText(); |
| 18389 |
sn.remove(QRegularExpression(R"(^\S+\s+\d+\s+)")); |
| 18390 |
sn.remove(QRegularExpression(R"([=]\S+\s)",QRegularExpression::MultilineOption|QRegularExpression::DotMatchesEverythingOption)); |
| 18391 |
QStringList snl=sn.split(QRegularExpression(R"(\s+)")); |
| 18392 |
int egal=0; |
| 18393 |
double w[10]; |
| 18394 |
int _m[10]; |
| 18395 |
for (int j=0; j<snl.size();j++){ |
| 18396 |
w[j]=getNumber(snl.at(j).toDouble(),fvar,j,egal); |
| 18397 |
_m[j]=getFvarNr(snl.at(j).toDouble(),fvar); |
| 18398 |
} |
| 18399 |
for (int j=0; j<end; j++){ |
| 18400 |
int tst=1<<j; |
| 18401 |
int pm=(tst&vor)?1:0; |
| 18402 |
int m=(tst&mole.asymm.at(da).fixFlag)?1:0; |
| 18403 |
/* free variables come here ... m*fvarNr*fvarType |
| 18404 |
* |
| 18405 |
* */ |
| 18406 |
if (pm&&m) w[j]=snl.at(j).toDouble();//if fix was there then keep fvar binding. |
| 18407 |
else w[j]+=m*10; |
| 18408 |
//printf("i%d %d %d %f tst %d %f vor%d fix%d %d %d\n",j ,m,_m[j],w[j],tst,snl.at(j).toDouble(),vor,mole.asymm.at(da).fixFlag,da,i); |
| 18409 |
} |
| 18410 |
QString neu=(end==10)?QString("%1 %2 %3 %4 %5 %6 %7 %8 =\n %9 %10 %11 %12") |
| 18411 |
.arg(mole.asymm.at(da).Label.section('_',0,0),-4) |
| 18412 |
.arg(qMax(1,editor->sfac.indexOf(mole.asymm.at(da).an)+1)) |
| 18413 |
.arg(w[0],11,'f',6) |
| 18414 |
.arg(w[1],11,'f',6) |
| 18415 |
.arg(w[2],11,'f',6) |
| 18416 |
.arg(w[3],10,'f',5) |
| 18417 |
.arg(w[4],10,'f',5) |
| 18418 |
.arg(w[5],10,'f',5) |
| 18419 |
.arg(w[6],10,'f',5) |
| 18420 |
.arg(w[7],10,'f',5) |
| 18421 |
.arg(w[8],10,'f',5) |
| 18422 |
.arg(w[9],10,'f',5) |
| 18423 |
:QString("%1 %2 %3 %4 %5 %6 %7") |
| 18424 |
.arg(mole.asymm.at(da).Label.section('_',0,0),-4) |
| 18425 |
.arg(qMax(1,editor->sfac.indexOf(mole.asymm.at(da).an)+1)) |
| 18426 |
.arg(w[0],11,'f',6) |
| 18427 |
.arg(w[1],11,'f',6) |
| 18428 |
.arg(w[2],11,'f',6) |
| 18429 |
.arg(w[3],10,'f',5) |
| 18430 |
.arg(w[4],10,'f',5); |
| 18431 |
c.insertText(neu); |
| 18432 |
mole.showatoms[da].orginalLine=mole.asymm[da].orginalLine=neu; |
| 18433 |
mole.asymm[da].orginalLine.truncate(77); |
| 18434 |
//qDebug()<<da<<mole.asymm.at(da).orginalLine; |
| 18435 |
update(); |
| 18436 |
|
| 18437 |
} |
| 18438 |
|
| 18439 |
|
| 18440 |
} |
| 18441 |
|
| 18442 |
bool Window::maybeSave() { |
| 18443 |
if (!editor->document()->isModified()) return true; |
| 18444 |
QMessageBox::StandardButton ret; |
| 18445 |
ret = QMessageBox::warning(this, tr("Application"), |
| 18446 |
tr("The document has been modified.\n" |
| 18447 |
"Do you want to save your changes?"), |
| 18448 |
QMessageBox::Save | QMessageBox::Discard |
| 18449 |
| QMessageBox::Cancel); |
| 18450 |
if (ret == QMessageBox::Save){ |
| 18451 |
return fileSave(); |
| 18452 |
} |
| 18453 |
else {if (ret == QMessageBox::Cancel) |
| 18454 |
return false; |
| 18455 |
} |
| 18456 |
return true; |
| 18457 |
} |
| 18458 |
|
| 18459 |
bool Window::maybeSave2() { |
| 18460 |
if (!editor->document()->isModified()) return true; |
| 18461 |
if (doNotAnnoyMe) return fileSave(); |
| 18462 |
QMessageBox *box=new QMessageBox(QMessageBox::Question,tr("Application"), |
| 18463 |
tr("The document has been modified.\n" |
| 18464 |
"Do you want to save your changes?"), |
| 18465 |
QMessageBox::Save | QMessageBox::Discard |
| 18466 |
| QMessageBox::Cancel); |
| 18467 |
QPushButton *ischkansonetabeida = box->addButton("Always!",QMessageBox::ActionRole); |
| 18468 |
box->setDefaultButton(QMessageBox::Save); |
| 18469 |
int ret; |
| 18470 |
ret = box->exec(); |
| 18471 |
|
| 18472 |
if (box->clickedButton()==ischkansonetabeida){ |
| 18473 |
doNotAnnoyMe=true; |
| 18474 |
einstellung->beginGroup("DoNotAskFileSave"); |
| 18475 |
einstellung->setValue("DoNotAnnoyMe",doNotAnnoyMe); |
| 18476 |
einstellung->endGroup(); |
| 18477 |
return fileSave(); |
| 18478 |
} |
| 18479 |
if (ret == QMessageBox::Save){ |
| 18480 |
return fileSave(); |
| 18481 |
} |
| 18482 |
else {if (ret == QMessageBox::Cancel) |
| 18483 |
return false; |
| 18484 |
} |
| 18485 |
return true; |
| 18486 |
} |
| 18487 |
|
| 18488 |
QString Window::strippedName(const QString &fullFileName) { |
| 18489 |
return QFileInfo(fullFileName).fileName(); |
| 18490 |
} |
| 18491 |
|
| 18492 |
void Window::updateRecentFileActions() { |
| 18493 |
QSettings *einstellung =new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME, mole.mynewnameis ); |
| 18494 |
einstellung->beginGroup("Files"); |
| 18495 |
QStringList files = einstellung->value("recentFileList").toStringList(); |
| 18496 |
int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); |
| 18497 |
|
| 18498 |
for (int i = 0; i < numRecentFiles; ++i) { |
| 18499 |
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); |
| 18500 |
recentFileActs[i]->setText(text); |
| 18501 |
recentFileActs[i]->setData(files[i]); |
| 18502 |
recentFileActs[i]->setStatusTip(files[i]); |
| 18503 |
recentFileActs[i]->setVisible(true); |
| 18504 |
} |
| 18505 |
for (int j = numRecentFiles; j < MaxRecentFiles; ++j) |
| 18506 |
recentFileActs[j]->setVisible(false); |
| 18507 |
einstellung->endGroup(); |
| 18508 |
delete einstellung; |
| 18509 |
} |
| 18510 |
|
| 18511 |
void Window::linkHelp(){ |
| 18512 |
QMessageBox::about(this, tr("%1-Help").arg(PROGRAM_NAME), |
| 18513 |
tr("<h1>%1-Help</h1><br> The offline help has ben removed. <a href=\"http://shelxle.org/shelx/help/\">Click here for Online Help.</a>\n" |
| 18514 |
).arg(PROGRAM_NAME)); |
| 18515 |
} |
| 18516 |
|
| 18517 |
void Window::aboutXLE(){ |
| 18518 |
QString MEM; |
| 18519 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 18520 |
MEMORYSTATUSEX memory_status; |
| 18521 |
|
| 18522 |
ZeroMemory(&memory_status, sizeof(MEMORYSTATUSEX)); |
| 18523 |
memory_status.dwLength = sizeof(MEMORYSTATUSEX); |
| 18524 |
if (GlobalMemoryStatusEx(&memory_status)) { |
| 18525 |
double total = memory_status.ullTotalPhys; |
| 18526 |
double avail = memory_status.ullAvailPhys; |
| 18527 |
QString tu,au; |
| 18528 |
int it=0,ia=0; |
| 18529 |
while (total>1000.0){ |
| 18530 |
it++; |
| 18531 |
total/=1024.0; |
| 18532 |
} |
| 18533 |
while (avail>1000.0){ |
| 18534 |
ia++; |
| 18535 |
avail/=1024.0; |
| 18536 |
} |
| 18537 |
switch (it){ |
| 18538 |
case 0: tu="B"; break; |
| 18539 |
case 1: tu="kB"; break; |
| 18540 |
case 2: tu="MB"; break; |
| 18541 |
case 3: tu="GB"; break; |
| 18542 |
} |
| 18543 |
switch (ia){ |
| 18544 |
case 0: au="B"; break; |
| 18545 |
case 1: au="kB"; break; |
| 18546 |
case 2: au="MB"; break; |
| 18547 |
case 3: au="GB"; break; |
| 18548 |
} |
| 18549 |
|
| 18550 |
|
| 18551 |
MEM.append(QString("RAM: %1 %4 Available %2 %5 Memory load %3%\n").arg(total,0,'f',2).arg(avail,0,'f',2).arg(memory_status.dwMemoryLoad).arg(tu).arg(au)); |
| 18552 |
} else { |
| 18553 |
MEM.append("Unknown RAM\n"); |
| 18554 |
} |
| 18555 |
#endif |
| 18556 |
QString openGLVersion=QString("OpenGL Version %1").arg((char *)glGetString(GL_VERSION)); |
| 18557 |
int glminor,glmajor; |
| 18558 |
const char *verstring=(char*)glGetString(GL_VERSION); |
| 18559 |
if ((verstring==nullptr)||(sscanf(verstring,"%d.%d",&glmajor,&glminor)!=2)) glminor=glmajor=0; |
| 18560 |
QString GLSLVersion=(glmajor<2)?"Unsupported GLSL Version":QString("GLSL Version %1 (minimum 4.00)").arg((char*)glGetString(GL_SHADING_LANGUAGE_VERSION)); |
| 18561 |
//qDebug() << (QString(qgetenv("PATH")).split(QRegularExpression("[;:]"))); |
| 18562 |
QMessageBox::about(this, tr("About %1").arg(PROGRAM_NAME), |
| 18563 |
QString("<p><b>%1</b> is a tool for <b>SHELX</b> small "\ |
| 18564 |
"molecule refinement. It combines an editor with simple syntax highlighting "\ |
| 18565 |
"with an OpenGL representation of the structure.</p> "\ |
| 18566 |
"<p><img src=\""+theIconPath+"cbh.png\" alt=\"Christian B. Hübschle\">"\ |
| 18567 |
"<img src=\""+theIconPath+"gms.png\" alt=\"George M. Sheldrick\"></p> "\ |
| 18568 |
"<p><b>%1</b> is written by <b>Christian B. Hübschle</b> "\ |
| 18569 |
" at the University of Göttingen. "\ |
| 18570 |
"Some parts of the program are taken from Qt examples, others are from the "\ |
| 18571 |
"<b>SHELX</b> author <b>George M. Sheldrick</b> and/or his group Members</p> "\ |
| 18572 |
"<font color=darkgreen> Please cite: <br>C. B. Hübschle, G. M. Sheldrick and B. Dittrich<br>" |
| 18573 |
"<em>'ShelXle: a Qt graphical user interface for SHELXL'</em><br>" |
| 18574 |
"<em>J. Appl. Cryst.</em> (2011). <b>44</b>, 1281-1284 .</font><br>" |
| 18575 |
"<a href=\"http://dx.doi.org/10.1107/S0021889811043202\">[ doi:10.1107/S0021889811043202 ]</a>" |
| 18576 |
"<p>Please visit the following web sites:<br>" |
| 18577 |
"<a href=\"http://shelx.uni-goettingen.de\"><b>SHELX</b> site</a><p>" |
| 18578 |
"<p><a href=\"http://shelxle.org/shelx/index.php\">" |
| 18579 |
"Dowload new versions from here</a></p>" |
| 18580 |
"<p>This is a %11 bit Version.</p> " |
| 18581 |
"<p>This is Revision <b>%2</b>" |
| 18582 |
//"last build was: <b>%3</b></p> " |
| 18583 |
"<p>The latest Version available is '%6'" |
| 18584 |
"<p>The Version of Qt used is %4. </p> "\ |
| 18585 |
"<p>%5<br>%8<br>%9 </p><p>The settings of this program are stored in: <b>%7</b><p>%10") |
| 18586 |
.arg(PROGRAM_NAME) |
| 18587 |
.arg(Revision) |
| 18588 |
// .arg(datum) |
| 18589 |
.arg(qVersion ()) |
| 18590 |
.arg(openGLVersion) |
| 18591 |
.arg(latestRev) |
| 18592 |
.arg(einstellung->fileName ()) |
| 18593 |
.arg(QString("Graphics card: %1") .arg((char *)glGetString(GL_RENDERER))) |
| 18594 |
.arg(GLSLVersion) |
| 18595 |
.arg(MEM) |
| 18596 |
.arg(BitWidth) |
| 18597 |
); |
| 18598 |
} |
| 18599 |
|
| 18600 |
void Window::hintLhide(){ |
| 18601 |
hintL->hide(); |
| 18602 |
einstellung->beginGroup("SaveHint"); |
| 18603 |
einstellung->setValue("ShowRenameHint",hintL->isVisible()); |
| 18604 |
einstellung->endGroup(); |
| 18605 |
} |
| 18606 |
|
| 18607 |
void Window::symmetryManager(){ |
| 18608 |
prosaTimer.setSingleShot(true); |
| 18609 |
QDialog *sman = new QDialog(this); |
| 18610 |
sman->setWindowTitle("Symmetry Manager"); |
| 18611 |
QGridLayout *lt = new QGridLayout(sman); |
| 18612 |
sman->setMinimumSize(400,300); |
| 18613 |
|
| 18614 |
OrtepCodesbrowser=new QTextBrowser(sman); |
| 18615 |
OrtepCodesbrowser->setOpenLinks(false); |
| 18616 |
OrtepCodesbrowser->setLineWrapMode(QTextEdit::NoWrap); |
| 18617 |
symmIntBx = new QSpinBox(sman); |
| 18618 |
symmIntBx->setMinimum(1); |
| 18619 |
symmIntBx->setMaximum(mole.cell.symmops.size()); |
| 18620 |
|
| 18621 |
symmXBx = new QSpinBox(sman); |
| 18622 |
symmXBx->setMinimum(1); |
| 18623 |
symmXBx->setMaximum(9); |
| 18624 |
symmXBx->setValue(5); |
| 18625 |
|
| 18626 |
symmYBx = new QSpinBox(sman); |
| 18627 |
symmYBx->setMinimum(1); |
| 18628 |
symmYBx->setMaximum(9); |
| 18629 |
symmYBx->setValue(5); |
| 18630 |
|
| 18631 |
symmZBx = new QSpinBox(sman); |
| 18632 |
symmZBx->setMinimum(1); |
| 18633 |
symmZBx->setMaximum(9); |
| 18634 |
symmZBx->setValue(5); |
| 18635 |
|
| 18636 |
|
| 18637 |
symmFrgBx = new QSpinBox(sman); |
| 18638 |
symmFrgBx->setMinimum(1); |
| 18639 |
symmFrgBx->setMaximum(mole.maxmols()); |
| 18640 |
symmFrgBx->setValue(1); |
| 18641 |
prosaSymm = new QLineEdit(); |
| 18642 |
prosaSymm->setText("x,y,z"); |
| 18643 |
connect(prosaSymm,SIGNAL(textEdited(QString)),this,SLOT(updateSM4(QString))); |
| 18644 |
connect(symmIntBx,SIGNAL(valueChanged(int)),this,SLOT(updateSM1())); |
| 18645 |
connect(symmXBx,SIGNAL(valueChanged(int)),this,SLOT(updateSM1())); |
| 18646 |
connect(symmYBx,SIGNAL(valueChanged(int)),this,SLOT(updateSM1())); |
| 18647 |
connect(symmZBx,SIGNAL(valueChanged(int)),this,SLOT(updateSM1())); |
| 18648 |
connect(symmFrgBx,SIGNAL(valueChanged(int)),this,SLOT(updateSM1())); |
| 18649 |
QLabel *unter = new QLabel("_"); |
| 18650 |
QLabel *doppl = new QLabel(":"); |
| 18651 |
shortestDistanceLabel = new QLabel("<p>Shortest distace to asymmetric unit: 0.00 Å</p>"); |
| 18652 |
QPushButton *addSymmOp=new QPushButton("add symmetry to list"); |
| 18653 |
connect(addSymmOp,SIGNAL(clicked()),this,SLOT(updateSM2())); |
| 18654 |
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 18655 |
connect(buttonBox, SIGNAL(accepted()), sman, SLOT(accept())); |
| 18656 |
connect(buttonBox, SIGNAL(rejected()), sman, SLOT(reject())); |
| 18657 |
connect(OrtepCodesbrowser,SIGNAL(anchorClicked( const QUrl &)), this ,SLOT(updateSM3(const QUrl &))); |
| 18658 |
lt->addWidget(new QLabel("List of symmetry in use:"),0,0,1,12,Qt::AlignHCenter); |
| 18659 |
// lt->addWidget(SymmetryCodesbrowser,1,0,1,5); |
| 18660 |
lt->addWidget(OrtepCodesbrowser,1,0,1,12); |
| 18661 |
lt->addWidget(new QLabel("symmetry operation"),2,0,1,5); |
| 18662 |
lt->addWidget(new QLabel("sym No"),2,5,1,1); |
| 18663 |
lt->addWidget(new QLabel("translation"),2,7,1,3,Qt::AlignHCenter); |
| 18664 |
lt->addWidget(new QLabel("fragment"),2,11,1,1); |
| 18665 |
lt->addWidget(prosaSymm,3,0,1,5); |
| 18666 |
lt->addWidget(symmIntBx,3,5,1,1); |
| 18667 |
lt->addWidget(unter,3,6,1,1); |
| 18668 |
lt->addWidget(symmXBx,3,7,1,1); |
| 18669 |
lt->addWidget(symmYBx,3,8,1,1); |
| 18670 |
lt->addWidget(symmZBx,3,9,1,1); |
| 18671 |
lt->addWidget(doppl,3,10,1,1); |
| 18672 |
lt->addWidget(symmFrgBx,3,11,1,1); |
| 18673 |
lt->addWidget(shortestDistanceLabel,4,0,1,9); |
| 18674 |
lt->addWidget(addSymmOp,4,9,1,3); |
| 18675 |
lt->addWidget(buttonBox,10,0,1,12); |
| 18676 |
sman->setLayout(lt); |
| 18677 |
QStringList oldsymm=mole.usedSymmetry; |
| 18678 |
QString text="<table><tr><th>ID</th><th>symmetry op. </th><th style=\"background:#d4d4d4\">internal code</th><th></th><th></th><th>distance to asymmetric unit</th></tr>";; |
| 18679 |
for (int i=0; i<mole.usedSymmetry.size(); i++) |
| 18680 |
text.append(QString("<tr><th>$%6</th><td> %5 </td><th style=\"background:#d4d4d4\"> %1</th> <td><a href=\"%2\">remove</a> </td><td> <a href=\"%4\">edit</a></td><td> %3 Å</td></tr>") |
| 18681 |
.arg(mole.usedSymmetry.at(i)) |
| 18682 |
.arg(i) |
| 18683 |
.arg(mole.shortestDistance(mole.usedSymmetry.at(i)),0,'f',2) |
| 18684 |
.arg(-1-i) |
| 18685 |
.arg(mole.symmcode2human(mole.usedSymmetry.at(i))) |
| 18686 |
.arg(i+1)); |
| 18687 |
text.append("</table>"); |
| 18688 |
OrtepCodesbrowser->setHtml(text); |
| 18689 |
|
| 18690 |
if (sman->exec()==QDialog::Accepted){ |
| 18691 |
|
| 18692 |
mole.showatoms.clear(); |
| 18693 |
mole.showbonds.clear(); |
| 18694 |
mole.showatoms+=mole.asymm; |
| 18695 |
mole.packer(mole.usedSymmetry); |
| 18696 |
mole.showbonds = |
| 18697 |
mole.connecting(mole.showatoms); |
| 18698 |
chgl->mol->selectedatoms.clear(); |
| 18699 |
|
| 18700 |
chgl->updateBondActions(); |
| 18701 |
loadMolInTest(); |
| 18702 |
}else{ |
| 18703 |
mole.usedSymmetry.clear(); |
| 18704 |
mole.usedSymmetry=oldsymm; |
| 18705 |
oldsymm.clear(); |
| 18706 |
|
| 18707 |
mole.showatoms.clear(); |
| 18708 |
|
| 18709 |
mole.showatoms+=mole.asymm; |
| 18710 |
mole.showbonds.clear(); |
| 18711 |
mole.packer(mole.usedSymmetry); |
| 18712 |
mole.showbonds = |
| 18713 |
mole.connecting(mole.showatoms); |
| 18714 |
chgl->mol->selectedatoms.clear(); |
| 18715 |
|
| 18716 |
chgl->updateBondActions(); |
| 18717 |
|
| 18718 |
loadMolInTest(); |
| 18719 |
} |
| 18720 |
; |
| 18721 |
delete buttonBox ; |
| 18722 |
|
| 18723 |
text.clear(); |
| 18724 |
OrtepCodesbrowser->clear(); |
| 18725 |
delete OrtepCodesbrowser; |
| 18726 |
delete symmIntBx; |
| 18727 |
delete symmXBx; |
| 18728 |
delete symmYBx; |
| 18729 |
delete symmZBx; |
| 18730 |
delete doppl; |
| 18731 |
delete unter; |
| 18732 |
delete symmFrgBx; |
| 18733 |
delete shortestDistanceLabel; |
| 18734 |
delete lt; |
| 18735 |
delete sman; |
| 18736 |
|
| 18737 |
chgl->update(); |
| 18738 |
update(); |
| 18739 |
chgl->update(); |
| 18740 |
} |
| 18741 |
|
| 18742 |
void Window::updateSM1(){ |
| 18743 |
if (prosaTimer.isActive()) return; |
| 18744 |
QString t=QString("%1_%2%3%4:%5") |
| 18745 |
.arg(symmIntBx->value()) |
| 18746 |
.arg(symmXBx->value()) |
| 18747 |
.arg(symmYBx->value()) |
| 18748 |
.arg(symmZBx->value()) |
| 18749 |
.arg(symmFrgBx->value()); |
| 18750 |
shortestDistanceLabel->setText(QString("<p>Shortest distace to asymmetric unit: %1 Å</p>").arg( |
| 18751 |
mole.shortestDistance(t),0,'f',2)); |
| 18752 |
prosaSymm->setText(mole.symmcode2human(t)); |
| 18753 |
QPalette p = prosaSymm->palette(); |
| 18754 |
p.setBrush(QPalette::Active,QPalette::Base,Qt::white); |
| 18755 |
prosaSymm->setPalette(p); |
| 18756 |
} |
| 18757 |
|
| 18758 |
void Window::updateSM2(){ |
| 18759 |
QString t=QString("%1_%2%3%4:%5,") |
| 18760 |
.arg(symmIntBx->value()) |
| 18761 |
.arg(symmXBx->value()) |
| 18762 |
.arg(symmYBx->value()) |
| 18763 |
.arg(symmZBx->value()) |
| 18764 |
.arg(symmFrgBx->value()); |
| 18765 |
if (t.startsWith("1_555:1"))return; |
| 18766 |
OrtepCodesbrowser->clear(); |
| 18767 |
if (!mole.usedSymmetry.contains(t)) mole.usedSymmetry.append(t); |
| 18768 |
QString text="<table><tr><th>symmetry op. </th><th style=\"background:#d4d4d4\">internal code</th><th></th><th></th><th>distance to asymmetric unit</th></tr>";; |
| 18769 |
for (int i=0; i<mole.usedSymmetry.size(); i++) |
| 18770 |
text.append(QString("<tr><td>%5 </td><th style=\"background:#d4d4d4\"> %1</th> <td><a href=\"%2\">remove</a> </td><td> <a href=\"%4\">edit</a></td><td> %3 Å</td></tr>") |
| 18771 |
.arg(mole.usedSymmetry.at(i)) |
| 18772 |
.arg(i) |
| 18773 |
.arg(mole.shortestDistance(mole.usedSymmetry.at(i)),0,'f',2) |
| 18774 |
.arg(-1-i) |
| 18775 |
.arg(mole.symmcode2human(mole.usedSymmetry.at(i)))); |
| 18776 |
text.append("</table>"); |
| 18777 |
OrtepCodesbrowser->setHtml(text); |
| 18778 |
|
| 18779 |
} |
| 18780 |
|
| 18781 |
void Window::updateSM3(const QUrl link){ |
| 18782 |
int index = link.toString().toInt(); |
| 18783 |
if (index<0) { |
| 18784 |
index=-index-1; |
| 18785 |
QString t = mole.usedSymmetry.at(index); |
| 18786 |
int s,h,k,l,symmgroup; |
| 18787 |
sscanf(t.toLatin1(),"%d_%1d%1d%1d:%d",&s,&h,&k,&l,&symmgroup); |
| 18788 |
shortestDistanceLabel->setText(QString("<p>Shortest distace to asymmetric unit: %1 Å</p>").arg( |
| 18789 |
mole.shortestDistance(t),0,'f',2)); |
| 18790 |
prosaTimer.stop(); |
| 18791 |
symmIntBx->setValue(s); |
| 18792 |
symmXBx->setValue(h); |
| 18793 |
symmYBx->setValue(k); |
| 18794 |
symmZBx->setValue(l); |
| 18795 |
symmFrgBx->setValue(symmgroup); |
| 18796 |
return; |
| 18797 |
} |
| 18798 |
if (mole.usedSymmetry.size()<=index) return; |
| 18799 |
mole.usedSymmetry.removeAt(index); |
| 18800 |
QString text="<table><tr><th>symmetry op. </th><th style=\"background:#d4d4d4\">internal code</th><th></th><th></th><th>distance to asymmetric unit</th></tr>"; |
| 18801 |
for (int i=0; i<mole.usedSymmetry.size(); i++) |
| 18802 |
text.append(QString("<tr><td>%5 </td><th style=\"background:#d4d4d4\"> %1</th> <td><a href=\"%2\">remove</a> </td><td> <a href=\"%4\">edit</a></td><td> %3 Å</td></tr>") |
| 18803 |
.arg(mole.usedSymmetry.at(i)) |
| 18804 |
.arg(i) |
| 18805 |
.arg(mole.shortestDistance(mole.usedSymmetry.at(i)),0,'f',2) |
| 18806 |
.arg(-1-i) |
| 18807 |
.arg(mole.symmcode2human(mole.usedSymmetry.at(i))) |
| 18808 |
); |
| 18809 |
text.append("</table>"); |
| 18810 |
OrtepCodesbrowser->setHtml(text); |
| 18811 |
|
| 18812 |
} |
| 18813 |
|
| 18814 |
void Window::updateSM4(QString symtxt){ |
| 18815 |
QString t = mole.symmCard2Code(symtxt); |
| 18816 |
QPalette p = prosaSymm->palette(); |
| 18817 |
|
| 18818 |
p.setBrush(QPalette::Active,QPalette::Base,QColor(205,100,100)); |
| 18819 |
if (t.isEmpty()) {prosaSymm->setPalette(p);return;} |
| 18820 |
|
| 18821 |
p.setBrush(QPalette::Active,QPalette::Base,Qt::white); |
| 18822 |
int s,h,k,l,symmgroup; |
| 18823 |
shortestDistanceLabel->setText(QString("<p>Shortest distace to asymmetric unit: %1 Å</p>").arg( |
| 18824 |
mole.shortestDistance(t),0,'f',2)); |
| 18825 |
|
| 18826 |
sscanf(t.toLatin1(),"%d_%1d%1d%1d:%d",&s,&h,&k,&l,&symmgroup); |
| 18827 |
prosaTimer.start(80); |
| 18828 |
symmIntBx->setValue(s); |
| 18829 |
symmXBx->setValue(h); |
| 18830 |
symmYBx->setValue(k); |
| 18831 |
symmZBx->setValue(l); |
| 18832 |
symmFrgBx->setValue(symmgroup); |
| 18833 |
prosaSymm->setPalette(p); |
| 18834 |
update(); |
| 18835 |
} |
| 18836 |
|
| 18837 |
void Window::insertSADI(int selected){ |
| 18838 |
QString buffer = "SADI 0.02 "; |
| 18839 |
if (selected>=mole.asymm.size()) return; |
| 18840 |
QList<int> baerle;// only same sfac type and non H to prevent warnig in lst file. Experts can do what they want if they know what they do by hand |
| 18841 |
for (int nb=1; nb<mole.knoepfe.at(selected).neighbors.size(); nb++){ |
| 18842 |
if ((mole.knoepfe.at(selected).neighbors.at(nb-1)>=mole.asymm.size())||(mole.knoepfe.at(selected).neighbors.at(nb)>=mole.asymm.size())) continue; |
| 18843 |
if ((mole.asymm.at(mole.knoepfe.at(selected).neighbors.at(nb-1)).an>0)&& |
| 18844 |
(mole.asymm.at(mole.knoepfe.at(selected).neighbors.at(nb-1)).an==mole.asymm.at(mole.knoepfe.at(selected).neighbors.at(nb)).an)){ |
| 18845 |
if (!baerle.contains(mole.knoepfe.at(selected).neighbors.at(nb-1))) baerle.append(mole.knoepfe.at(selected).neighbors.at(nb-1)); |
| 18846 |
if (!baerle.contains(mole.knoepfe.at(selected).neighbors.at(nb))) baerle.append(mole.knoepfe.at(selected).neighbors.at(nb)); |
| 18847 |
} |
| 18848 |
} |
| 18849 |
for (int n=0; n < baerle.size(); n++){ |
| 18850 |
MyAtom atom1 = mole.asymm.at(selected); |
| 18851 |
QString resi1 = (atom1.resiNr > 0)?QString("_%1").arg(atom1.resiNr):""; |
| 18852 |
MyAtom atom2 = mole.asymm.at(baerle.at(n)); |
| 18853 |
QString resi2 = (atom2.resiNr > 0)?QString("_%1").arg(atom2.resiNr):""; |
| 18854 |
buffer += atom1.Label.section("_", 0, 0) + resi1 + " " + atom2.Label.section("_", 0, 0) + resi2 + " " ; |
| 18855 |
} |
| 18856 |
if (buffer.size()<12) { |
| 18857 |
return; |
| 18858 |
} |
| 18859 |
QTextDocument *document = editor->document(); |
| 18860 |
QTextCursor cursor = editor->textCursor(); |
| 18861 |
cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); |
| 18862 |
cursor = document->find(unitinst,cursor); |
| 18863 |
cursor.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor); |
| 18864 |
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor); |
| 18865 |
cursor.insertText(DSRGui::textWrap(buffer.simplified()) + "\n"); |
| 18866 |
mole.selectedatoms.clear(); |
| 18867 |
} |
| 18868 |
|
| 18869 |
void Window::raiseTaff(){ |
| 18870 |
tabifyDockWidget(shxOutputDock, infotainmentDock); |
| 18871 |
resid_label->clear(); |
| 18872 |
restr_table->clear(); |
| 18873 |
infotainmentDock->show(); |
| 18874 |
infotainmentDock->raise(); |
| 18875 |
vis_settings->beginGroup("infotaiment"); |
| 18876 |
vis_settings->setValue("info_as_default", true); |
| 18877 |
vis_settings->endGroup(); |
| 18878 |
} |
| 18879 |
|
| 18880 |
void Window::raiseTaz(){ |
| 18881 |
tabifyDockWidget(shxOutputDock, infotainmentDock); |
| 18882 |
shxOutputDock->show(); |
| 18883 |
shxOutputDock->raise(); |
| 18884 |
vis_settings->beginGroup("infotaiment"); |
| 18885 |
vis_settings->setValue("info_as_default", false); |
| 18886 |
vis_settings->endGroup(); |
| 18887 |
} |
| 18888 |
|
| 18889 |
int Window::cifCheckSum(const QString &block){ |
| 18890 |
long long int sum=0; |
| 18891 |
for (int i=0; i<block.size(); i++){ |
| 18892 |
if (static_cast<unsigned char>(block.at(i).toLatin1()) > ' '){ |
| 18893 |
sum+=block.at(i).toLatin1(); |
| 18894 |
} |
| 18895 |
} |
| 18896 |
sum %= 714025; |
| 18897 |
sum *= 1366; |
| 18898 |
sum += 150889; |
| 18899 |
sum %= 714025; |
| 18900 |
sum %= 100000; |
| 18901 |
|
| 18902 |
/* |
| 18903 |
def calc_checksum(input_str: str) -> int: |
| 18904 |
""" |
| 18905 |
Calculates the shelx checksum of a cif file. |
| 18906 |
The original algorithm was posted by Berthold Stöger on the Bruker Users Mailing list. |
| 18907 |
""" |
| 18908 |
crc_sum = 0 |
| 18909 |
try: |
| 18910 |
input_str = input_str.encode('cp1250', 'ignore') |
| 18911 |
except Exception: |
| 18912 |
input_str = input_str.encode('ascii', 'ignore') |
| 18913 |
for char in input_str: |
| 18914 |
# print(char) |
| 18915 |
if char > 32: # ascii 32 is space character |
| 18916 |
crc_sum += char |
| 18917 |
crc_sum %= 714025 |
| 18918 |
crc_sum = crc_sum * 1366 + 150889 |
| 18919 |
crc_sum %= 714025 |
| 18920 |
crc_sum %= 100000 |
| 18921 |
return crc_sum |
| 18922 |
*/ |
| 18923 |
return static_cast<int>(sum); |
| 18924 |
} |
| 18925 |
|
| 18926 |
|
| 18927 |
void Window::shredCIF(){ |
| 18928 |
/* |
| 18929 |
QSettings *shrcifset = new QSettings( QSettings::IniFormat, QSettings::UserScope ,PROGRAM_NAME,mole.mynewnameis ); |
| 18930 |
shrcifset->beginGroup("ShredCIF"); |
| 18931 |
shredCIFPath = shrcifset->value("ShredCIF-PATH","").toString(); |
| 18932 |
shrcifset->endGroup(); |
| 18933 |
//inspired by Daniels 'which' in DSRGUI |
| 18934 |
QStringList foundInPath; |
| 18935 |
foundInPath.clear(); |
| 18936 |
// qDebug()<<shredCIFPath.isEmpty()<<!QFileInfo(shredCIFPath).isExecutable()<<shredCIFPath; |
| 18937 |
if ((shredCIFPath.isEmpty())||(!QFileInfo(shredCIFPath).isExecutable())) { |
| 18938 |
QStringList execlist; |
| 18939 |
QStringList pathList; |
| 18940 |
pathList.clear(); |
| 18941 |
execlist.clear(); |
| 18942 |
pathList = QString(qgetenv("PATH")).split(QRegularExpression("[;:]")); |
| 18943 |
// qDebug()<<pathList; |
| 18944 |
foreach (QString path, pathList) { |
| 18945 |
QString fullpath = path+"/shredcif"; |
| 18946 |
QFileInfo fi(fullpath); |
| 18947 |
if (QFile::exists(fullpath) && (fi.isExecutable())){ |
| 18948 |
foundInPath.append(QDir::cleanPath(fullpath)); |
| 18949 |
}else { |
| 18950 |
fi.setFile(fullpath+".exe"); |
| 18951 |
// qDebug()<<QDir::cleanPath(fullpath+".exe")<<QFile::exists(fullpath+".exe")<<(fi.isExecutable()); |
| 18952 |
if (QFile::exists(fullpath+".exe") && (fi.isExecutable())){ |
| 18953 |
foundInPath.append(QDir::cleanPath(fullpath+".exe")); |
| 18954 |
} |
| 18955 |
} |
| 18956 |
} |
| 18957 |
|
| 18958 |
if (foundInPath.isEmpty()){ |
| 18959 |
//file dialog |
| 18960 |
QString shcf = QFileDialog::getOpenFileName(this, "Where is SHREDCIF? (http://shelx.uni-goettingen.de/download.php)", |
| 18961 |
QString(),QString(),nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 18962 |
//(QWidget *parent = nullptr, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = nullptr, QFileDialog::Options options = Options()) |
| 18963 |
if (shcf.isEmpty()) return; // empty string means probably cancel |
| 18964 |
if (QFileInfo(shcf).isExecutable()) shredCIFPath = shcf; |
| 18965 |
}else { |
| 18966 |
shredCIFPath = foundInPath.first(); |
| 18967 |
} |
| 18968 |
shrcifset->beginGroup("ShredCIF"); |
| 18969 |
shrcifset->setValue("ShredCIF-PATH",shredCIFPath); |
| 18970 |
shrcifset->endGroup(); |
| 18971 |
} |
| 18972 |
// qDebug() << shredCIFPath; |
| 18973 |
// */ |
| 18974 |
|
| 18975 |
QString cif2shred = QFileDialog::getOpenFileName(this, "Open a CIF to shred",dirName,"Crystallographic Information File (*.cif)" |
| 18976 |
,nullptr,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog); |
| 18977 |
if (cif2shred.isEmpty()) return; |
| 18978 |
QString info; |
| 18979 |
QString dn=cif2shred.section('/',0,-2), argument=cif2shred.section('/',-1); |
| 18980 |
QFile ciffi(cif2shred); |
| 18981 |
ciffi.open(QIODevice::ReadOnly|QIODevice::Text); |
| 18982 |
QString strcif = QString(ciffi.readAll()); |
| 18983 |
ciffi.close(); |
| 18984 |
QRegularExpression data_= QRegularExpression("\\bdata_"); |
| 18985 |
QRegularExpression tblocksep = QRegularExpression("\n;\\s*\n"); |
| 18986 |
QRegularExpression tagexpr = QRegularExpression("^\\s*_\\S+"); |
| 18987 |
QRegularExpression incfcs = QRegularExpression("\nloop_\n_shelx_include_file_name\n_shelx_include_file\n_shelx_include_file_checksum\n"); |
| 18988 |
QStringList incfstr = strcif.split(incfcs, skipEmptyParts); |
| 18989 |
//printf("incfstr size %d\n%s\n",incfstr.size(), incfstr.at(1).toStdString().c_str()); |
| 18990 |
if (incfstr.size()>1){ |
| 18991 |
QStringList incpart= incfstr.at(1).split("\n",keepEmptyParts); |
| 18992 |
int textbl = 0; |
| 18993 |
QString incbody; |
| 18994 |
QString _shelx_include_file_name; |
| 18995 |
for (int ip=0; ip<incpart.size(); ip++){ |
| 18996 |
if ((incpart.at(ip).startsWith("loop_"))||(incpart.at(ip).contains(tagexpr))) break; |
| 18997 |
bool semicolon = incpart.at(ip).startsWith(";"); |
| 18998 |
textbl += (semicolon)?1:0; |
| 18999 |
if ((!semicolon)&&((textbl%3)==0)) { |
| 19000 |
_shelx_include_file_name = incpart.at(ip); |
| 19001 |
}else if ((!semicolon)&&((textbl%3)==1)){ |
| 19002 |
incbody+=incpart.at(ip); |
| 19003 |
incbody+="\n"; |
| 19004 |
}else if ((!semicolon)&&((textbl%3)==2)){ |
| 19005 |
int incsum = incpart.at(ip).toInt(); |
| 19006 |
int chksum = cifCheckSum(incbody); |
| 19007 |
// printf("incsum %d = %d ok = %d\n ", incsum, chksum,(incsum==chksum)); |
| 19008 |
if (incsum==chksum){ |
| 19009 |
QString icfn=QString("%1/%2").arg(dn).arg(_shelx_include_file_name); |
| 19010 |
// printf("%s\n",icfn.toStdString().c_str()); |
| 19011 |
QFile icf(icfn); |
| 19012 |
bool canwrite = icf.open(QIODevice::WriteOnly|QIODevice::Text); |
| 19013 |
icf.write(incbody.toLatin1()); |
| 19014 |
icf.close(); |
| 19015 |
info+= QString("<font color=green >Extracted %1 checksum was OK</font> File was %2successfully</font> written.<br>") |
| 19016 |
.arg(icfn).arg(canwrite?"<font color=green >":"<font color=red >un"); |
| 19017 |
} |
| 19018 |
textbl++; |
| 19019 |
incbody.clear(); |
| 19020 |
} |
| 19021 |
|
| 19022 |
} |
| 19023 |
} |
| 19024 |
|
| 19025 |
QStringList blcks = strcif.split(data_,skipEmptyParts); |
| 19026 |
int done=0; |
| 19027 |
QStringList resExportNameList; |
| 19028 |
for (int bi = 0; bi < blcks.size(); bi++){ |
| 19029 |
//printf("blocks %d %s\n",blcks.size(),blcks.at(1).section("\n",0,0).toStdString().c_str()); |
| 19030 |
QString datablock = blcks.at(bi).section("\n",0,0).simplified(); |
| 19031 |
//printf("datablock %s %d %d\n", datablock.toStdString().c_str(), bi, blcks.size()); |
| 19032 |
QStringList textblocks = blcks.at(bi).split(tblocksep, skipEmptyParts); |
| 19033 |
int xlsum = blcks.at(bi).section("_shelx_res_checksum",1,1).section("\n",0,0).toInt(); |
| 19034 |
int hklsum = blcks.at(bi).section("_shelx_hkl_checksum",1,1).section("\n",0,0).toInt(); |
| 19035 |
|
| 19036 |
//printf("textblocks %d\n", textblocks.size()); |
| 19037 |
QString hklExportName = QString("%1/%2_xle.hkl").arg(dn).arg(datablock); |
| 19038 |
QString resExportName = QString("%1/%2_xle.res").arg(dn).arg(datablock); |
| 19039 |
for (int j=0; j<textblocks.size();j++){ |
| 19040 |
int sum = cifCheckSum(textblocks.at(j)); |
| 19041 |
//printf("checksum %d size %d #%d res:%d hkl:%d data:%s\n",sum,textblocks.at(j).size(),j,xlsum,hklsum, datablock.toStdString().c_str()); |
| 19042 |
if (sum==xlsum){ |
| 19043 |
//printf("%s\n",resExportName.toStdString().c_str()); |
| 19044 |
QFile expresf(resExportName); |
| 19045 |
bool canwrite = expresf.open(QIODevice::WriteOnly|QIODevice::Text); |
| 19046 |
expresf.write(textblocks.at(j).toLatin1()); |
| 19047 |
expresf.close(); |
| 19048 |
|
| 19049 |
info+=QString("<font color=green >Extracted %1 checksum was OK</font> File was %2successfully</font> written.<br>") |
| 19050 |
.arg(resExportName).arg(canwrite?"<font color=green >":"<font color=red >un"); |
| 19051 |
resExportNameList.append(resExportName); |
| 19052 |
done++; |
| 19053 |
} |
| 19054 |
if (sum==hklsum){ |
| 19055 |
//printf("%s\n",hklExportName.toStdString().c_str()); |
| 19056 |
QFile exphklf(hklExportName); |
| 19057 |
bool canwrite = exphklf.open(QIODevice::WriteOnly|QIODevice::Text); |
| 19058 |
exphklf.write(textblocks.at(j).toLatin1()); |
| 19059 |
exphklf.close(); |
| 19060 |
info+=QString("<font color=green >Extracted %1 checksum was OK</font> File was %2successfully</font> written.<br>") |
| 19061 |
.arg(hklExportName).arg(canwrite?"<font color=green >":"<font color=red >un"); |
| 19062 |
done++; |
| 19063 |
} |
| 19064 |
} |
| 19065 |
}//bi |
| 19066 |
einstellung->beginGroup("Files"); |
| 19067 |
//einstellung->setValue("lastFile", fileName ); |
| 19068 |
QStringList files = einstellung->value("recentFileList").toStringList(); |
| 19069 |
for (int i = 0; i < resExportNameList.size(); i++){ |
| 19070 |
files.removeAll(resExportNameList.at(i)); //alle identischen "fileName" aus der Liste entfernen |
| 19071 |
files.prepend(resExportNameList.at(i)); // und dann vorne anfuegen... |
| 19072 |
} |
| 19073 |
while (files.size() > MaxRecentFiles) { |
| 19074 |
files.removeLast() ;//hinten abschneiden was laenger als MaxRecentFiles ist |
| 19075 |
} |
| 19076 |
einstellung->setValue("recentFileList", files); |
| 19077 |
foreach (QWidget *widget, QApplication::topLevelWidgets()) { |
| 19078 |
Window *mainWin = qobject_cast<Window *>(widget); |
| 19079 |
if (mainWin) |
| 19080 |
mainWin->updateRecentFileActions(); |
| 19081 |
} |
| 19082 |
einstellung->endGroup(); |
| 19083 |
|
| 19084 |
if (done>=2) { |
| 19085 |
loadFile(resExportNameList.first()); |
| 19086 |
infoKanalNews(info); |
| 19087 |
return; |
| 19088 |
} |
| 19089 |
//if done > 2 then let the user decide what file to load |
| 19090 |
/* |
| 19091 |
QProcess *shred = new QProcess(this); |
| 19092 |
QStringList al; |
| 19093 |
al.append(argument); |
| 19094 |
shred->setWorkingDirectory(dn); // updateXLput() |
| 19095 |
#if (QT_VERSION >= 0x040600) |
| 19096 |
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); |
| 19097 |
shred->setProcessEnvironment(env);//Thanks to Dr. Pavlo Solntsev!! |
| 19098 |
#else |
| 19099 |
QStringList env = QProcess::systemEnvironment(); |
| 19100 |
shred->setEnvironment(env); |
| 19101 |
#endif |
| 19102 |
shred->start(shredCIFPath,al); |
| 19103 |
shred->waitForFinished(5000); |
| 19104 |
QString op= shred->readAllStandardOutput(); |
| 19105 |
QMessageBox::information ( this, "shredcif output", "ShredCIF output:" + op ); |
| 19106 |
//qDebug()<<(!op.contains("checksum O.K.")); |
| 19107 |
if (!op.contains("checksum O.K.")) {qDebug()<<"No res file in cif file found!";return;} |
| 19108 |
QStringList filter; |
| 19109 |
filter << "*.res"; |
| 19110 |
QDir dir(dn); |
| 19111 |
QStringList files = dir.entryList(filter,QDir::Files|QDir::Readable,QDir::Time|QDir::Reversed); |
| 19112 |
//qDebug()<<files; |
| 19113 |
QString fileName=files.last(); |
| 19114 |
if (fileName.isEmpty()) return; |
| 19115 |
//qDebug()<<fileName; |
| 19116 |
QString base = fileName; |
| 19117 |
if (base.length()>4) base.chop(4); |
| 19118 |
QString ase = fileName;//jul 2023 shredcif seam to eat the first letter of its output |
| 19119 |
if (ase.length()>1) ase.remove(0,1); |
| 19120 |
printf("shredcif outout:\n%s\n%s %d res files found.\n", op.toStdString().c_str(), ase.toStdString().c_str(), files.size()); |
| 19121 |
int extractedResFiles = 0; |
| 19122 |
for (int i=0; i< files.size(); i++){ |
| 19123 |
QString nn= files.at(i); |
| 19124 |
nn.remove(0,1); |
| 19125 |
if (op.contains(nn)) { |
| 19126 |
extractedResFiles++; |
| 19127 |
printf("%s (%s)\n", nn.toStdString().c_str(),files.at(i).toStdString().c_str()); |
| 19128 |
} |
| 19129 |
} |
| 19130 |
printf("extractedResFiles %d\n",extractedResFiles); |
| 19131 |
|
| 19132 |
//qDebug()<<base<<op.contains(base)<<op.contains(ase); |
| 19133 |
if ((op.contains(base))||(op.contains(ase))) { |
| 19134 |
printf("load file %s\n",(dn+"/"+fileName).toStdString().c_str()); |
| 19135 |
loadFile(dn+"/"+fileName); |
| 19136 |
} |
| 19137 |
*/ |
| 19138 |
} |
| 19139 |
|
| 19140 |
void Window::showSearch(){ |
| 19141 |
if (editor->uCanSeeMe) editor->showSearch(); |
| 19142 |
if (xlPutor->uCanSeeMe) xlPutor->showSearch(); |
| 19143 |
} |
| 19144 |
|
| 19145 |
void Window::findNext(){ |
| 19146 |
if (editor->uCanSeeMe) editor->findNext(); |
| 19147 |
else if (xlPutor->uCanSeeMe) xlPutor->findNext(); |
| 19148 |
} |
| 19149 |
|
| 19150 |
void Window::findPrev(){ |
| 19151 |
if (editor->uCanSeeMe) editor->findPrev(); |
| 19152 |
else if (xlPutor->uCanSeeMe) xlPutor->findPrev(); |
| 19153 |
} |
| 19154 |
|
| 19155 |
void Window::brwsEPS(){ |
| 19156 |
QString selectedFilter; |
| 19157 |
fxle->contEPSFile->setText(QFileDialog::getSaveFileName(this, tr("Save Contour-Encapsulated PostScript file "), "", |
| 19158 |
"Encapsulated PostScript-Files (*.eps);;" |
| 19159 |
,&selectedFilter,(useNativeDlg->isChecked())?noneopt:QFileDialog::DontUseNativeDialog)); |
| 19160 |
if (!fxle->contEPSFile->text().endsWith(".eps",Qt::CaseInsensitive)) |
| 19161 |
fxle->contEPSFile->setText(fxle->contEPSFile->text()+".eps"); |
| 19162 |
} |
| 19163 |
|
| 19164 |
void Window::nocontourPlot(){ |
| 19165 |
chgl->cont.clear(); |
| 19166 |
chgl->contval.clear(); |
| 19167 |
chgl->cntrPlot->setVisible(false); |
| 19168 |
chgl->nocntrPlot->setVisible(false); |
| 19169 |
chgl->rainbowPlot->setVisible(false); |
| 19170 |
chgl->mol->selectedatoms.clear(); |
| 19171 |
chgl->contDestruct(); |
| 19172 |
chgl->updateBondActions(); |
| 19173 |
update(); |
| 19174 |
chgl->update(); |
| 19175 |
if (tgl){ |
| 19176 |
tgl->ogl->cont.clear(); |
| 19177 |
tgl->ogl->contval.clear(); |
| 19178 |
tgl->ogl->cntrPlot->setVisible(false); |
| 19179 |
tgl->ogl->nocntrPlot->setVisible(false); |
| 19180 |
tgl->ogl->rainbowPlot->setVisible(false); |
| 19181 |
tgl->ogl->updateBondActions(); |
| 19182 |
tgl->ogl->update(); |
| 19183 |
} |
| 19184 |
} |
| 19185 |
void Window::contourPlot(){ |
| 19186 |
if (mole.showatoms.isEmpty()) return; |
| 19187 |
chgl->cntrPlot->setVisible(false); |
| 19188 |
chgl->nocntrPlot->setVisible(true); |
| 19189 |
|
| 19190 |
QDialog *contDlg = new QDialog(this); |
| 19191 |
|
| 19192 |
QLabel *contEPSFileL = new QLabel("Write Encapsulated Postscript file",contDlg); |
| 19193 |
QPushButton *brwsEPS = new QPushButton("Browse",contDlg); |
| 19194 |
connect(brwsEPS,SIGNAL(pressed()),this,SLOT(brwsEPS())); |
| 19195 |
fxle->contEPSFile = new QLineEdit(contDlg); |
| 19196 |
fxle->contEPSFile->setWhatsThis( |
| 19197 |
"<h1>EPS file name</h1>" |
| 19198 |
"If this field is not empty an encapsulated post script file is written to the given path"); |
| 19199 |
QLabel *planeAtomDefL = new QLabel("Define plane by:"); |
| 19200 |
int at1=0,at2=1,at3=2; |
| 19201 |
if (chgl->mol->selectedatoms.size()>2){ |
| 19202 |
at1=chgl->mol->selectedatoms.at(0).style; |
| 19203 |
at2=chgl->mol->selectedatoms.at(1).style; |
| 19204 |
at3=chgl->mol->selectedatoms.at(2).style; |
| 19205 |
} |
| 19206 |
QLineEdit *planeAtomDef = new QLineEdit(QString("%1 %2 %3") |
| 19207 |
.arg(mole.showatoms.at(at1).Label) |
| 19208 |
.arg(mole.showatoms.at(at2).Label) |
| 19209 |
.arg(mole.showatoms.at(at3).Label)); |
| 19210 |
planeAtomDef->setReadOnly(true); |
| 19211 |
planeAtomDef->setEnabled(false); |
| 19212 |
/* |
| 19213 |
cubeGL->moliso->contMapFile->setReadOnly(true); |
| 19214 |
cubeGL->moliso->contMapFile->setEnabled(false); |
| 19215 |
*/ |
| 19216 |
fxle->contourValueEdit = new QLineEdit(contDlg); |
| 19217 |
fxle->contourValueEdit->setText("-1.0 0.0 1.0"); |
| 19218 |
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 19219 |
connect(buttonBox, SIGNAL(accepted()), contDlg, SLOT(accept())); |
| 19220 |
connect(buttonBox, SIGNAL(rejected()), contDlg, SLOT(reject())); |
| 19221 |
QPushButton *edo = new QPushButton("uniform contours",contDlg); |
| 19222 |
cStepBx = new QDoubleSpinBox(contDlg); |
| 19223 |
cStepBx->setPrefix("Step size: "); |
| 19224 |
cStepBx->setMinimum(0.001); |
| 19225 |
cStepBx->setDecimals(3); |
| 19226 |
cStepBx->setValue(0.1); |
| 19227 |
cStepBx->setSingleStep(0.05); |
| 19228 |
fxle->extendUnit = new QCheckBox("Extend over unit cell",contDlg); |
| 19229 |
fxle->cScopeBx = new QDoubleSpinBox(contDlg); |
| 19230 |
fxle->cScopeBx->setMinimum(0.0); |
| 19231 |
fxle->cScopeBx->setDecimals(1); |
| 19232 |
fxle->cScopeBx->setSingleStep(0.5); |
| 19233 |
fxle->heightScale = new QDoubleSpinBox(contDlg); |
| 19234 |
fxle->heightScale->setMinimum(0.0); |
| 19235 |
fxle->heightScale->setDecimals(2); |
| 19236 |
fxle->heightScale->setSingleStep(0.05); |
| 19237 |
fxle->heightScale->setValue(0.0); |
| 19238 |
fxle->heightScale->setPrefix("Height scale: "); |
| 19239 |
QPushButton *eAIM = new QPushButton("+AIM contours",contDlg); |
| 19240 |
eAIM->setWhatsThis( |
| 19241 |
"<h1>Atoms In Molecules(AIM) contours</h1>" |
| 19242 |
"This will add contours at <b>1 × 10<sup>n</sup>,2 × 10<sup>n</sup>,4 × 10<sup>n</sup>,6 × 10<sup>n</sup>and 8 × 10<sup>n</sup></b>. <b>n</b> ranges from -3 to 8."); |
| 19243 |
connect(edo ,SIGNAL(released ()),this,SLOT(everyPointOne())); |
| 19244 |
connect(eAIM,SIGNAL(released ()),this,SLOT(everyAIM())); |
| 19245 |
|
| 19246 |
edo->setWhatsThis( |
| 19247 |
"<h1>uniform contours</h1>" |
| 19248 |
"This will add contours from -10 to 10 in steps with given step size."); |
| 19249 |
|
| 19250 |
fxle->centerIsOn = new QComboBox(contDlg); |
| 19251 |
fxle->centerIsOn ->addItem("first atom",0); |
| 19252 |
fxle->centerIsOn ->addItem("second atom",1); |
| 19253 |
fxle->centerIsOn ->addItem("third atom",2); |
| 19254 |
fxle->centerIsOn ->addItem("center of 3 atoms",3); |
| 19255 |
fxle->centerIsOn->setWhatsThis( |
| 19256 |
"<h1>Center on</h1>" |
| 19257 |
"When an EPS file is exported the center of the plot will be either on one of the selected atoms or the center of these three atoms." |
| 19258 |
); |
| 19259 |
|
| 19260 |
fxle->aspectRatios = new QComboBox(contDlg); |
| 19261 |
fxle->aspectRatios->addItem("4:3",0); |
| 19262 |
fxle->aspectRatios->addItem("16:9",1); |
| 19263 |
fxle->aspectRatios->addItem("1:1",2); |
| 19264 |
fxle->aspectRatios->setCurrentIndex(0); |
| 19265 |
|
| 19266 |
fxle->sourceMap = new QComboBox(contDlg); |
| 19267 |
fxle->sourceMap->addItem("Fo-Fc diffrence map",0); |
| 19268 |
fxle->sourceMap->addItem("Fo map",1); |
| 19269 |
fxle->sourceMap->setWhatsThis( |
| 19270 |
"<h1>Source </h1>" |
| 19271 |
"The contour plot can be based on the Diffrence Fourier Map (Fo-Fc Map) or the map of the observed structure factors with model phases (Fo map)."); |
| 19272 |
|
| 19273 |
QGridLayout *gl = new QGridLayout(contDlg); |
| 19274 |
gl->addWidget(planeAtomDefL, 1, 0, 1, 1); |
| 19275 |
gl->addWidget(planeAtomDef, 1, 1, 1, 1); |
| 19276 |
gl->addWidget(new QLabel("Center on",contDlg), 1, 3, 1, 1); |
| 19277 |
gl->addWidget(fxle->centerIsOn, 1, 4, 1, 1); |
| 19278 |
gl->addWidget(new QLabel("Contour plot is based on:",contDlg), 2, 0, 1, 1); |
| 19279 |
gl->addWidget(fxle->sourceMap,2,1,1,1); |
| 19280 |
gl->addWidget(new QLabel("Contour values",contDlg), 3, 0, 1, 4); |
| 19281 |
gl->addWidget(fxle->contourValueEdit, 4, 0, 1, 5); |
| 19282 |
gl->addWidget(cStepBx ,5,0,1,1); |
| 19283 |
gl->addWidget(edo,5,1,1,1); |
| 19284 |
gl->addWidget(eAIM,5,2,1,1); |
| 19285 |
gl->addWidget(fxle->heightScale,5,3,1,1); |
| 19286 |
gl->addWidget(fxle->extendUnit,5,4,1,1); |
| 19287 |
gl->addWidget(new QLabel("Scope (0 means now restriction)"),6,0,1,1); |
| 19288 |
gl->addWidget(fxle->cScopeBx,6,1,1,1); |
| 19289 |
gl->addWidget(new QLabel("Aspect ratio"),6,3,1,1); |
| 19290 |
gl->addWidget(fxle->aspectRatios,6,4,1,1); |
| 19291 |
|
| 19292 |
gl->addWidget(contEPSFileL, 7, 0, 1, 1); |
| 19293 |
gl->addWidget(fxle->contEPSFile, 7, 1, 1, 3); |
| 19294 |
gl->addWidget(brwsEPS, 7, 4, 1, 1); |
| 19295 |
gl->addWidget(buttonBox, 10, 0, 1, 5); |
| 19296 |
|
| 19297 |
if (contDlg->exec()==QDialog::Accepted){ |
| 19298 |
fxle->makePlane(chgl->cont,at1,at2,at3); |
| 19299 |
chgl->mol->selectedatoms.clear(); |
| 19300 |
chgl->rainbowPlot->setVisible(true); |
| 19301 |
/*showLeg->setChecked ( true ); |
| 19302 |
showLeg->setVisible(true); |
| 19303 |
cubeGL->setLegend(true);*/ |
| 19304 |
chgl->update(); |
| 19305 |
}else{ |
| 19306 |
chgl->mol->selectedatoms.clear(); |
| 19307 |
chgl->updateBondActions(); |
| 19308 |
chgl->cntrPlot->setVisible(false); |
| 19309 |
chgl->nocntrPlot->setVisible(false); |
| 19310 |
chgl->rainbowPlot->setVisible(false); |
| 19311 |
} |
| 19312 |
|
| 19313 |
} |
| 19314 |
|
| 19315 |
void Window::everyPointOne(){ |
| 19316 |
QString cfs; |
| 19317 |
if (cStepBx->value()==0) return; |
| 19318 |
double val=-100*cStepBx->value(); |
| 19319 |
double end=-val; |
| 19320 |
while (val<end) { |
| 19321 |
cfs.append(QString("%1 ").arg(val)); |
| 19322 |
val+=cStepBx->value(); |
| 19323 |
} |
| 19324 |
fxle->contourValueEdit->setText(cfs); |
| 19325 |
update(); |
| 19326 |
} |
| 19327 |
|
| 19328 |
void Window::everyAIM(){ |
| 19329 |
double val=0.001; |
| 19330 |
// double step=fabs(0.001)/5.0f; |
| 19331 |
int i=-3; |
| 19332 |
QString cfs; |
| 19333 |
while (val<1e9) { |
| 19334 |
cfs.append(QString("%1 ").arg(val));//1 |
| 19335 |
val+=1*pow(10.0,i); |
| 19336 |
cfs.append(QString("%1 ").arg(val));//2 |
| 19337 |
val+=2*pow(10.0,i); |
| 19338 |
cfs.append(QString("%1 ").arg(val));//4 |
| 19339 |
val+=2*pow(10.0,i); |
| 19340 |
cfs.append(QString("%1 ").arg(val));//6 |
| 19341 |
val+=2*pow(10.0,i); |
| 19342 |
cfs.append(QString("%1 ").arg(val));//8 |
| 19343 |
val+=2*pow(10.0,i); |
| 19344 |
|
| 19345 |
i++; |
| 19346 |
} |
| 19347 |
|
| 19348 |
fxle->contourValueEdit->setText(cfs); |
| 19349 |
update(); |
| 19350 |
|
| 19351 |
} |
| 19352 |
|
| 19353 |
// K.R. start============================================================ |
| 19354 |
void Window::exportCC(){ |
| 19355 |
|
| 19356 |
#define GAUSS_FILES "gaussian (*.com | *.gjf)" |
| 19357 |
#define XYZ_FILES "xyz (*.xyz)" |
| 19358 |
#define TM_FILES "turbomole (*.coord)" |
| 19359 |
#define XLE_FILES "ShelXle (*.shelxle)" |
| 19360 |
|
| 19361 |
QString selectedFilter; |
| 19362 |
|
| 19363 |
QString qmName = dirName; |
| 19364 |
qmName.replace(resorins,""); |
| 19365 |
QString fn=QFileDialog::getSaveFileName(this, "Export computational chemistry file", qmName, |
| 19366 |
GAUSS_FILES ";;" XYZ_FILES ";;" TM_FILES ";;" XLE_FILES, &selectedFilter); |
| 19367 |
if (fn.isEmpty())return; |
| 19368 |
if (selectedFilter==GAUSS_FILES){ |
| 19369 |
QDialog *dlg = new ExportCCDlg(dirName,chgl->mol,fn); |
| 19370 |
dlg->exec(); |
| 19371 |
} |
| 19372 |
else{ |
| 19373 |
QString headerQM, bodyQM, footerQM, filenameQM; |
| 19374 |
double a0= 1.0 / 0.5291772109; |
| 19375 |
QFile f; |
| 19376 |
f.setFileName(fn); |
| 19377 |
QFileInfo fileInfo(f.fileName()); |
| 19378 |
filenameQM = fileInfo.baseName(); |
| 19379 |
// center of molecule |
| 19380 |
V3 Vo=V3(0,0,0); |
| 19381 |
int visCount=0; |
| 19382 |
for (int i=0; i<mole.showatoms.size();i++) { |
| 19383 |
if (mole.showatoms.at(i).an<0) continue; //ignore none atoms |
| 19384 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 19385 |
if (mole.showatoms.at(i).hidden) continue; |
| 19386 |
visCount++; |
| 19387 |
Vo+=mole.showatoms.at(i).pos; |
| 19388 |
} |
| 19389 |
Vo*=1.0/visCount; |
| 19390 |
|
| 19391 |
|
| 19392 |
// atoms themselves |
| 19393 |
if (selectedFilter == XLE_FILES) { |
| 19394 |
for (int i=0; i< mole.showatoms.size(); i++) |
| 19395 |
bodyQM.append(mole.showatoms.at(i).toAtomString()); |
| 19396 |
|
| 19397 |
}else |
| 19398 |
for (int i=0; i< mole.showatoms.size(); i++){ |
| 19399 |
if (mole.showatoms.at(i).an<0) continue; //ignore none atoms |
| 19400 |
if ((mole.nopm1)&&(mole.showatoms.at(i).symmGroup)&&(mole.showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1) |
| 19401 |
if (mole.showatoms.at(i).hidden) continue; |
| 19402 |
if (selectedFilter == XYZ_FILES) { |
| 19403 |
bodyQM.append(QString("%1 %2 %3 %4\n") |
| 19404 |
.arg(mole.pse(mole.showatoms.at(i).an),-2) |
| 19405 |
.arg(mole.showatoms.at(i).pos.x-Vo.x,13,'f',10) |
| 19406 |
.arg(mole.showatoms.at(i).pos.y-Vo.y,13,'f',10) |
| 19407 |
.arg(mole.showatoms.at(i).pos.z-Vo.z,13,'f',10) ); |
| 19408 |
} |
| 19409 |
else { |
| 19410 |
bodyQM.append(QString(" %2 %3 %4 %1\n") |
| 19411 |
.arg(mole.pse(mole.showatoms.at(i).an).toLower(),-4) |
| 19412 |
.arg((mole.showatoms.at(i).pos.x-Vo.x)*a0,20,'f',14) |
| 19413 |
.arg((mole.showatoms.at(i).pos.y-Vo.y)*a0,20,'f',14) |
| 19414 |
.arg((mole.showatoms.at(i).pos.z-Vo.z)*a0,20,'f',14) ); |
| 19415 |
} |
| 19416 |
} |
| 19417 |
|
| 19418 |
if (selectedFilter == XYZ_FILES) { |
| 19419 |
footerQM.append(QString("\n\n")); |
| 19420 |
} |
| 19421 |
else if (selectedFilter == XLE_FILES) { |
| 19422 |
footerQM.append(QString("\n\n")); |
| 19423 |
} |
| 19424 |
|
| 19425 |
else { |
| 19426 |
footerQM.append(QString("$end\n\n")); |
| 19427 |
} |
| 19428 |
if (selectedFilter == XYZ_FILES) { // ================= XYZ |
| 19429 |
headerQM.append(QString("%1\n").arg(visCount)); |
| 19430 |
headerQM.append(QString("from %1\n").arg(dirName)); |
| 19431 |
|
| 19432 |
} |
| 19433 |
else if (selectedFilter == XLE_FILES) { |
| 19434 |
headerQM.append("@ShelXle file@\n"); |
| 19435 |
} else { |
| 19436 |
headerQM.append(QString("$coord\n")); |
| 19437 |
} |
| 19438 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 19439 |
if (success){ |
| 19440 |
f.write(QString("%1%2%3").arg(headerQM).arg(bodyQM).arg(footerQM).toLatin1()); |
| 19441 |
f.close(); |
| 19442 |
} |
| 19443 |
} |
| 19444 |
} |
| 19445 |
|
| 19446 |
void Window::go2hklf5(){ |
| 19447 |
maybeSave(); |
| 19448 |
if ((hklf5files.isEmpty())||(chgl->mol->asymm.isEmpty())) return; |
| 19449 |
QString dn=dirName.section('/',0,-2); |
| 19450 |
QStringList ins5files,res5files; |
| 19451 |
QString orthisres=""; |
| 19452 |
bool decisionRequired = false; |
| 19453 |
for (int i=0; i< hklf5files.size();i++){ |
| 19454 |
QString hk5=hklf5files.at(i); |
| 19455 |
//printf("=%d/%d %s\n",i,hklf5files.size(),hk5.toStdString().c_str()); |
| 19456 |
QString ins=hk5; |
| 19457 |
QString res=hk5; |
| 19458 |
res.replace(punkthkl,".res"); |
| 19459 |
ins.replace(punkthkl,".ins"); |
| 19460 |
res=QString("%1/%2").arg(dn).arg(res); |
| 19461 |
ins=QString("%1/%2").arg(dn).arg(ins); |
| 19462 |
if (QFile::exists(res)) { |
| 19463 |
//printf("=%d/%d=>> A RES file already exists! %s\n",i,hklf5files.size(),res.toStdString().c_str()); |
| 19464 |
//loadFile(res); |
| 19465 |
//return; |
| 19466 |
decisionRequired = true; |
| 19467 |
res5files.append(res); |
| 19468 |
} else { |
| 19469 |
res5files.append("!"+res); |
| 19470 |
orthisres=res; |
| 19471 |
} |
| 19472 |
if (QFile::exists(ins)) { |
| 19473 |
//printf("==>> A INS file already exists! %s\n",ins.toStdString().c_str()); |
| 19474 |
//loadFile(ins); |
| 19475 |
//return; |
| 19476 |
decisionRequired = true; |
| 19477 |
ins5files.append(ins); |
| 19478 |
}else ins5files.append("!"+ins); |
| 19479 |
} |
| 19480 |
if (decisionRequired){ |
| 19481 |
QDialog *dlg = new QDialog(this); |
| 19482 |
dlg->setWindowTitle("Switch to HKLF 5 refinement"); |
| 19483 |
QGridLayout *gl = new QGridLayout(dlg); |
| 19484 |
gl->addWidget(new QLabel("Switch to HKLF 5 refinement: Your decission is requred.",dlg),0,0,1,12); |
| 19485 |
int column=0; |
| 19486 |
for (int bi=0; bi< hklf5files.size(); bi++){ |
| 19487 |
if (!res5files.at(bi).isEmpty()){ |
| 19488 |
QAction *a = new QAction((res5files.at(bi).startsWith('!'))? |
| 19489 |
QString("%1 does not exist yet") |
| 19490 |
.arg(res5files.at(bi).section('/',-1)): |
| 19491 |
QString("load %1 was modified %2") |
| 19492 |
.arg(res5files.at(bi).section('/',-1)) |
| 19493 |
.arg(QFileInfo(res5files.at(bi)).lastModified().toString()) |
| 19494 |
,dlg); |
| 19495 |
//QString("%1/%2").arg(dn).arg(resfs.at(i)) |
| 19496 |
a->setDisabled(res5files.at(bi).startsWith('!')); |
| 19497 |
a->setData(res5files.at(bi)); |
| 19498 |
connect(a,SIGNAL(triggered()),this,SLOT(loadThisFile())); |
| 19499 |
connect(a,SIGNAL(triggered()),dlg,SLOT(accept())); |
| 19500 |
QToolButton *tbb= new QToolButton(dlg);//17696 |
| 19501 |
tbb->setDefaultAction(a); |
| 19502 |
gl->addWidget(tbb,1,column); |
| 19503 |
} |
| 19504 |
|
| 19505 |
if (!ins5files.at(bi).isEmpty()){ |
| 19506 |
QAction *a = new QAction((ins5files.at(bi).startsWith('!'))? |
| 19507 |
QString("%1 does not exist yet") |
| 19508 |
.arg(ins5files.at(bi).section('/',-1)):QString("load %1 was modified: %2") |
| 19509 |
.arg(ins5files.at(bi).section('/',-1)) |
| 19510 |
.arg(QFileInfo(ins5files.at(bi)).lastModified().toString()) |
| 19511 |
,dlg); |
| 19512 |
//QString("%1/%2").arg(dn).arg(resfs.at(i)) |
| 19513 |
a->setDisabled(ins5files.at(bi).startsWith('!')); |
| 19514 |
a->setData(ins5files.at(bi)); |
| 19515 |
connect(a,SIGNAL(triggered()),this,SLOT(loadThisFile())); |
| 19516 |
connect(a,SIGNAL(triggered()),dlg,SLOT(accept())); |
| 19517 |
QToolButton *tbb= new QToolButton(dlg);//17696 |
| 19518 |
tbb->setDefaultAction(a); |
| 19519 |
gl->addWidget(tbb,2,column); |
| 19520 |
} |
| 19521 |
|
| 19522 |
if (!hklf5files.at(bi).isEmpty()){ |
| 19523 |
QAction *a = new QAction(QString("create res file from current file"),dlg); |
| 19524 |
//QString("%1/%2").arg(dn).arg(resfs.at(i)) |
| 19525 |
QString hk5=hklf5files.at(bi); |
| 19526 |
QString res=hk5; |
| 19527 |
res=res.replace(punkthkl,".res"); |
| 19528 |
res=QString("%1/%2").arg(dn).arg(res); |
| 19529 |
a->setData(res); |
| 19530 |
connect(a,SIGNAL(triggered()),this,SLOT(fileSave4hklf5())); |
| 19531 |
connect(a,SIGNAL(triggered()),dlg,SLOT(accept())); |
| 19532 |
QToolButton *tbb= new QToolButton(dlg);//17696 |
| 19533 |
tbb->setDefaultAction(a); |
| 19534 |
gl->addWidget(tbb,3,column); |
| 19535 |
} |
| 19536 |
column++; |
| 19537 |
} |
| 19538 |
dlg->exec(); |
| 19539 |
return; |
| 19540 |
|
| 19541 |
}else{ |
| 19542 |
printf("go2hklf5()\n"); |
| 19543 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 19544 |
action->setData(orthisres); |
| 19545 |
//fileSave4hklf5(); |
| 19546 |
makeItHKLF5(); |
| 19547 |
} |
| 19548 |
//printf("GOTO HKLF 5 =>> %d %d %d \n",hklf5files.size(),res5files.size(),ins5files.size()); |
| 19549 |
return; |
| 19550 |
} |
| 19551 |
|
| 19552 |
void Window::go2hklf4(){ |
| 19553 |
maybeSave(); |
| 19554 |
QString dn=dirName.section('/',0,-2); |
| 19555 |
QString res4=dirName; |
| 19556 |
res4.replace(QRegularExpression("_5.res$"),"_4.res"); |
| 19557 |
res4.replace(QRegularExpression("_5.ins$"),"_4.res"); |
| 19558 |
if (QFile::exists(res4)) { |
| 19559 |
loadFile(res4); |
| 19560 |
return; |
| 19561 |
}else{ |
| 19562 |
QFile f(res4); |
| 19563 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 19564 |
if (success){ |
| 19565 |
jumpToAtom(0); |
| 19566 |
QTextCursor cursor = editor->textCursor(); |
| 19567 |
editor->searchLE->setText("^BASF"); |
| 19568 |
editor->replace->setText("REM BASF"); |
| 19569 |
editor->wholeLine->setChecked(false); |
| 19570 |
editor->replaceAll(); |
| 19571 |
editor->searchLE->setText("^HKLF"); |
| 19572 |
editor->replace->setText("HKLF 4"); |
| 19573 |
editor->wholeLine->setChecked(true); |
| 19574 |
editor->replaceAll(); |
| 19575 |
f.write(editor->toPlainText().toLatin1()); |
| 19576 |
f.close(); |
| 19577 |
editor->document()->setModified(false); |
| 19578 |
loadFile(res4); |
| 19579 |
} |
| 19580 |
} |
| 19581 |
} |
| 19582 |
|
| 19583 |
void Window::makeItHKLF5(){ |
| 19584 |
|
| 19585 |
QAction *action = qobject_cast<QAction *>(sender()); |
| 19586 |
QString hk5=""; |
| 19587 |
printf("%p %c\n", action,(action)?'y':'n'); |
| 19588 |
if (action) |
| 19589 |
hk5=action->data().toString(); |
| 19590 |
else return; |
| 19591 |
printf("%d %s\n", hk5.isEmpty(),action->objectName().toStdString().c_str()); |
| 19592 |
if (hk5.isEmpty()) return; |
| 19593 |
QString res=hk5; |
| 19594 |
res=res.replace(punkthkl,".res"); |
| 19595 |
QString dn=dirName.section('/',0,-2); |
| 19596 |
QString basfs="BASF 0.51\n"; |
| 19597 |
QStringList filter; |
| 19598 |
filter.append("*.abs"); |
| 19599 |
QStringList files; |
| 19600 |
files = QDir(dn).entryList(filter,QDir::Files,QDir::Time|QDir::Reversed); |
| 19601 |
for (int i=0; i<files.size();i++){ |
| 19602 |
QFile sad(QString("%1/%2").arg(dn).arg(files.at(i))); |
| 19603 |
sad.open(QIODevice::Text|QIODevice::ReadOnly); |
| 19604 |
QString sadstring=sad.readAll(); |
| 19605 |
if ((sadstring.contains(hk5))&&(sadstring.contains("Cycle N(1) Rint(1) N(all) Rint(all) Twin fractions"))){ |
| 19606 |
QString tail=sadstring.section("Cycle N(1) Rint(1) N(all) Rint(all) Twin fractions",-1); |
| 19607 |
QStringList sadlines=tail.split('\n'); |
| 19608 |
for (int j=0; j<sadlines.size(); j++){ |
| 19609 |
QStringList tok=sadlines.at(j).split(leer,skipEmptyParts); |
| 19610 |
if ((tok.size()>6)&&(tok.at(0).toInt()>0)&&(tok.at(6).toDouble()>0.0)){ |
| 19611 |
basfs.clear(); |
| 19612 |
basfs=QString("BASF"); |
| 19613 |
for (int ii=6; ii<tok.size();ii++) basfs.append(QString(" %1").arg(tok.at(ii).toDouble())); |
| 19614 |
} |
| 19615 |
} |
| 19616 |
basfs.append('\n'); |
| 19617 |
} |
| 19618 |
sad.close(); |
| 19619 |
} |
| 19620 |
printf("%d", __LINE__); |
| 19621 |
QFile f(res); |
| 19622 |
bool success = f.open(QIODevice::WriteOnly|QIODevice::Text); |
| 19623 |
if (success){ |
| 19624 |
jumpToAtom(0); |
| 19625 |
QTextCursor cursor = editor->textCursor(); |
| 19626 |
cursor.insertText(basfs); |
| 19627 |
editor->searchLE->setText("^HKLF"); |
| 19628 |
editor->replace->setText("HKLF 5"); |
| 19629 |
editor->wholeLine->setChecked(true); |
| 19630 |
editor->replaceAll(); |
| 19631 |
f.write(editor->toPlainText().toLatin1()); |
| 19632 |
f.close(); |
| 19633 |
editor->document()->setModified(false); |
| 19634 |
loadFile(res); |
| 19635 |
} |
| 19636 |
} |
| 19637 |
|
| 19638 |
bool Window::canWeSqueeze(){ |
| 19639 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 19640 |
QString pwt; |
| 19641 |
int v=0; |
| 19642 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) |
| 19643 |
pwt = QString(qEnvironmentVariable("PWTDIR")); |
| 19644 |
if (pwt.isEmpty()) QString(qgetenv("PWTDIR")); |
| 19645 |
v=1; |
| 19646 |
#else |
| 19647 |
pwt = QString(qgetenv("PWTDIR")); |
| 19648 |
v=2; |
| 19649 |
#endif |
| 19650 |
printf("PWT (%s) %d %d\n",pwt.toStdString().c_str(),QFile::exists(QString("%1/%2").arg(pwt).arg("platon.exe")),v); |
| 19651 |
if (pwt.isEmpty()) { |
| 19652 |
QStringList foundInPath; |
| 19653 |
foundInPath.clear(); |
| 19654 |
QStringList pathList; |
| 19655 |
pathList.clear(); |
| 19656 |
//execlist.clear(); |
| 19657 |
pathList = QString(qgetenv("PATH")).split(QRegularExpression("[;:]")); |
| 19658 |
// qDebug()<<pathList; |
| 19659 |
foreach (QString path, pathList) { |
| 19660 |
QString fullpath = path+"/platon"; |
| 19661 |
QFileInfo fi(fullpath); |
| 19662 |
if (QFile::exists(fullpath) && (fi.isExecutable())){ |
| 19663 |
foundInPath.append(QDir::cleanPath(fullpath)); |
| 19664 |
}else { |
| 19665 |
fi.setFile(fullpath+".exe"); |
| 19666 |
// qDebug()<<QDir::cleanPath(fullpath+".exe")<<QFile::exists(fullpath+".exe")<<(fi.isExecutable()); |
| 19667 |
if (QFile::exists(fullpath+".exe") && (fi.isExecutable())){ |
| 19668 |
foundInPath.append(QDir::cleanPath(fullpath+".exe")); |
| 19669 |
} |
| 19670 |
} |
| 19671 |
} |
| 19672 |
return (!foundInPath.isEmpty()); |
| 19673 |
} |
| 19674 |
//qDebug()<<QString("%1/%2").arg(pwt).arg("platon.exe"); |
| 19675 |
return QFile::exists(QString("%1/%2").arg(pwt).arg("platon.exe")); |
| 19676 |
#else |
| 19677 |
return false; |
| 19678 |
#endif |
| 19679 |
} |
| 19680 |
|
| 19681 |
void Window::runSqueeze(){ |
| 19682 |
if (!canWeSqueeze()) return; |
| 19683 |
QString pwt; |
| 19684 |
#if defined Q_WS_WIN || defined Q_OS_WIN |
| 19685 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) |
| 19686 |
pwt = QString(qEnvironmentVariable("PWTDIR")); |
| 19687 |
#else |
| 19688 |
pwt = QString(qgetenv("PWTDIR")); |
| 19689 |
#endif |
| 19690 |
#endif //win |
| 19691 |
QString pwtplaton; |
| 19692 |
if (pwt.isEmpty()) { |
| 19693 |
|
| 19694 |
QStringList foundInPath; |
| 19695 |
foundInPath.clear(); |
| 19696 |
QStringList pathList; |
| 19697 |
pathList.clear(); |
| 19698 |
//execlist.clear(); |
| 19699 |
pathList = QString(qgetenv("PATH")).split(QRegularExpression("[;:]")); |
| 19700 |
// qDebug()<<pathList; |
| 19701 |
foreach (QString path, pathList) { |
| 19702 |
QString fullpath = path+"/platon"; |
| 19703 |
QFileInfo fi(fullpath); |
| 19704 |
if (QFile::exists(fullpath) && (fi.isExecutable())){ |
| 19705 |
foundInPath.append(QDir::cleanPath(fullpath)); |
| 19706 |
}else { |
| 19707 |
fi.setFile(fullpath+".exe"); |
| 19708 |
// qDebug()<<QDir::cleanPath(fullpath+".exe")<<QFile::exists(fullpath+".exe")<<(fi.isExecutable()); |
| 19709 |
if (QFile::exists(fullpath+".exe") && (fi.isExecutable())){ |
| 19710 |
foundInPath.append(QDir::cleanPath(fullpath+".exe")); |
| 19711 |
} |
| 19712 |
} |
| 19713 |
} |
| 19714 |
if (foundInPath.isEmpty()) return; |
| 19715 |
pwtplaton=foundInPath.first(); |
| 19716 |
}else{ |
| 19717 |
pwtplaton = QString("%1/%2").arg(pwt).arg("platon.exe"); |
| 19718 |
} |
| 19719 |
if (!editor->toPlainText().contains("ACTA")) { |
| 19720 |
qDebug()<<"We need to refine this first with ACTA and LIST 4 instructions"; |
| 19721 |
refineActActa->trigger(); |
| 19722 |
return; |
| 19723 |
} |
| 19724 |
pwtplaton = QString("%1/%2").arg(pwt).arg("platon.exe"); |
| 19725 |
QString dn=dirName.section('/',0,-2); |
| 19726 |
QString cifName=dirName; |
| 19727 |
cifName=cifName.replace(resorins, ".cif").section('/',-1,-1); |
| 19728 |
QStringList al=QString(QString("%1*-q*").arg(cifName)).split("*");//i think * should not be alowed in path names |
| 19729 |
//printf("al => {%s} {%s}\n",al.at(0).toStdString().c_str(),al.at(1).toStdString().c_str()); |
| 19730 |
extraProc = new QProcess(this); |
| 19731 |
extraProc->setWorkingDirectory(dn); // updateXLput() |
| 19732 |
connect(extraProc,SIGNAL(readyReadStandardOutput ()),this,SLOT(updateExtraOutput())); |
| 19733 |
connect(extraProc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateExtraOutput())); |
| 19734 |
connect(extraProc,SIGNAL(error(QProcess::ProcessError)),this,SLOT(updateExtraOutput())); |
| 19735 |
#if (defined Q_WS_WIN || defined Q_OS_WIN) |
| 19736 |
#if (QT_VERSION >= 0x050700) |
| 19737 |
extraProc->setProgram(pwtplaton); |
| 19738 |
extraProc->setArguments(al); |
| 19739 |
extraProc->setWorkingDirectory(dn); |
| 19740 |
extraProc->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) {args->flags &= ~CREATE_NO_WINDOW;}); |
| 19741 |
extraProc->start(pwtplaton,al); |
| 19742 |
#else |
| 19743 |
//extraProc->startDetached(pwtplaton,al,dn); |
| 19744 |
extraProc->start(pwtplaton,al); |
| 19745 |
#endif |
| 19746 |
extraOutPut->setText(QString("|--- Running %1 %2 in %3 ---|\n").arg(pwtplaton).arg(al.join(" ")).arg(dn)); |
| 19747 |
extraOutput->show(); |
| 19748 |
#endif |
| 19749 |
} |
| 19750 |
|
| 19751 |
void Window::getMinMaxSintl(double &smin, double &smax){ |
| 19752 |
smin=1000.0; |
| 19753 |
smax=0.0; |
| 19754 |
QString hklf=dirName; |
| 19755 |
hklf=hklf.replace(resorins,".hkl"); |
| 19756 |
QFile hkl(hklf); |
| 19757 |
if (hkl.open(QFile::ReadOnly|QFile::Text)){ |
| 19758 |
QStringList lines = QString(hkl.readAll()).split('\n'); |
| 19759 |
for (int i=0; i<lines.size(); i++){ |
| 19760 |
QStringList tok = lines.at(i).split(' ', skipEmptyParts); |
| 19761 |
if (tok.size()>3){ |
| 19762 |
V3 H=V3(tok.at(0).toInt(),tok.at(1).toInt(),tok.at(2).toInt()); |
| 19763 |
if (H==V3(0,0,0)) break; |
| 19764 |
double stl=sqrt(H*mole.cell.Gi*H)/2.0; |
| 19765 |
smin=qMin(smin, stl); |
| 19766 |
smax=qMax(smax, stl); |
| 19767 |
} |
| 19768 |
} |
| 19769 |
} |
| 19770 |
hkl.close(); |
| 19771 |
//printf("%f %f\n",smin,smax); |
| 19772 |
} |
| 19773 |
|
| 19774 |
|
| 19775 |
void Window::loadMolInTest(bool fromloadref){ |
| 19776 |
printf("-->(chgl->isReady() %d\n",chgl->isReady()); |
| 19777 |
QElapsedTimer elti; |
| 19778 |
elti.start(); |
| 19779 |
if ((tgl)&&(!chgl->mol->showatoms.isEmpty())){ |
| 19780 |
tgl->ogl->setMainWindow(this); |
| 19781 |
tgl->ogl->shaderInfo = shaderInfo; |
| 19782 |
tgl->ogl->sfacMenu = chgl->sfacMenu; |
| 19783 |
tgl->ogl->makeBonds(chgl->mol->showatoms, chgl->mol->showbonds, chgl->mol->lbonds,chgl->mol->theH_Bonds); |
| 19784 |
tgl->ogl->makeAtoms(chgl->mol->showatoms); |
| 19785 |
tgl->ogl->makeUnitCell(); |
| 19786 |
if (fxle) { |
| 19787 |
//printf("setOGL?\n"); |
| 19788 |
fxle->setOGL(tgl->ogl); |
| 19789 |
tgl->ogl->rainbowPlot = chgl->rainbowPlot; |
| 19790 |
} |
| 19791 |
if (!chgl->fVertexes[0].isEmpty()||!chgl->fVertexes[1].isEmpty()){ |
| 19792 |
/*tgl->ogl->setMapsStuff(chgl->fVertexes, chgl->fNormals, &chgl->lintrans, &chgl->linwidth, |
| 19793 |
&chgl->fopc, &chgl->fomc, &chgl->dipc, &chgl->dimc, |
| 19794 |
chgl->lighting, chgl->niceTrans, chgl->fillMap, chgl->foact, chgl->fofcact |
| 19795 |
); // */ |
| 19796 |
tgl->ogl->setMapsStuff(); |
| 19797 |
fxle->connect(tgl->ogl,SIGNAL(inimibas()),fxle,SLOT(inimap())); |
| 19798 |
fxle->connect(tgl->ogl,SIGNAL(neuemitte(V3)),fxle, SLOT(bewegt(V3))); |
| 19799 |
fxle->connect(tgl->ogl,SIGNAL(diffscroll(int ,int )),fxle,SLOT(change_iso(int ,int ))); |
| 19800 |
connect(chgl,SIGNAL(rebuffer(QVector< QVector< float > > &,QVector< QVector< float > > &)), |
| 19801 |
tgl->ogl,SLOT(makeMaps(QVector< QVector< float > > &,QVector< QVector< float > > &))); |
| 19802 |
//ChGL::rebuffer() |
| 19803 |
} |
| 19804 |
}else if ((chgl->isReady())&&(!chgl->mol->showatoms.isEmpty())){ |
| 19805 |
//printf("not ogl\n"); |
| 19806 |
chgl->setMainWindow(this); |
| 19807 |
chgl->shaderInfo = shaderInfo; |
| 19808 |
//printf("Q? min %g max %g\n",chgl->mol->pmin,chgl->mol->pmax,chgl->qcutoff); |
| 19809 |
if (!fromloadref) chgl->qcutoff=-10; |
| 19810 |
//chgl->sfacMenu = chgl->sfacMenu; |
| 19811 |
qint64 since=elti.elapsed(); |
| 19812 |
chgl->makeBonds(chgl->mol->showatoms, chgl->mol->showbonds, chgl->mol->lbonds,chgl->mol->theH_Bonds); |
| 19813 |
qint64 then=elti.elapsed(); |
| 19814 |
printf("make bonds took %d ms\n",then-since); |
| 19815 |
since=elti.elapsed(); |
| 19816 |
chgl->makeAtoms(chgl->mol->showatoms); |
| 19817 |
then=elti.elapsed(); |
| 19818 |
printf("make atoms took %d ms\n",then-since); |
| 19819 |
since=elti.elapsed(); |
| 19820 |
chgl->makeUnitCell(); |
| 19821 |
then=elti.elapsed(); |
| 19822 |
printf("make unit cell took %d ms\n",then-since); |
| 19823 |
since=elti.elapsed(); |
| 19824 |
//if (fxle) { |
| 19825 |
//printf("setOGL?\n"); |
| 19826 |
//fxle->setOGL(chgl); |
| 19827 |
//chgl->rainbowPlot; |
| 19828 |
//} |
| 19829 |
chgl->updateSceenAtoms(); |
| 19830 |
|
| 19831 |
if (!chgl->fVertexes[0].isEmpty()||!chgl->fVertexes[1].isEmpty()){ |
| 19832 |
/*tgl->ogl->setMapsStuff(chgl->fVertexes, chgl->fNormals, &chgl->lintrans, &chgl->linwidth, |
| 19833 |
&chgl->fopc, &chgl->fomc, &chgl->dipc, &chgl->dimc, |
| 19834 |
chgl->lighting, chgl->niceTrans, chgl->fillMap, chgl->foact, chgl->fofcact |
| 19835 |
); // */ |
| 19836 |
chgl->setMapsStuff(); |
| 19837 |
fxle->connect(chgl,SIGNAL(inimibas()),fxle,SLOT(inimap())); |
| 19838 |
fxle->connect(chgl,SIGNAL(neuemitte(V3)),fxle, SLOT(bewegt(V3))); |
| 19839 |
fxle->connect(chgl,SIGNAL(diffscroll(int ,int )),fxle,SLOT(change_iso(int ,int ))); |
| 19840 |
connect(chgl,SIGNAL(rebuffer(QVector< QVector< float > > &,QVector< QVector< float > > &)), |
| 19841 |
chgl,SLOT(makeMaps(QVector< QVector< float > > &,QVector< QVector< float > > &))); |
| 19842 |
|
| 19843 |
//ChGL::rebuffer() |
| 19844 |
} |
| 19845 |
} |
| 19846 |
printf("gl is ready %d %d %fseconds\n",chgl->isReady(), ((chgl->isReady())&&(!chgl->mol->showatoms.isEmpty())), elti.elapsed()/1000.0); |
| 19847 |
} |
| 19848 |
|
| 19849 |
void Window::testOGL(){ |
| 19850 |
QList<QAction*> acts; |
| 19851 |
QList<QToolButton*> tbs0,tbs1; |
| 19852 |
acts.append(viewMenu->findChildren<QAction*>()); |
| 19853 |
tbs0 = vito->findChildren<QToolButton *>(); |
| 19854 |
for (int i = 0; i < tbs0.size(); i++){ |
| 19855 |
QAction *a =tbs0.at(i)->defaultAction(); |
| 19856 |
if ((a != nullptr) |
| 19857 |
&&(!a->text().isEmpty()) |
| 19858 |
&&(!acts.contains(a)) |
| 19859 |
) acts.append(a); |
| 19860 |
} |
| 19861 |
tbs1 = bottomToolBar->findChildren<QToolButton *>(); |
| 19862 |
for (int i = 0; i < tbs1.size(); i++){ |
| 19863 |
QAction *a =tbs1.at(i)->defaultAction(); |
| 19864 |
if ((a != nullptr) |
| 19865 |
&&(!a->text().isEmpty()) |
| 19866 |
&&(!acts.contains(a)) |
| 19867 |
) acts.append(a); |
| 19868 |
} |
| 19869 |
tgl = new OpenGLTestWidget(chgl->mol, acts, this); |
| 19870 |
tgl->show(); |
| 19871 |
connect(tgl->ogl, SIGNAL(initialized()), this, SLOT(loadMolInTest())); |
| 19872 |
//loadMolInTest(); |
| 19873 |
} |
| 19874 |
// */ |