49 #include <wx/msw/winundef.h>
52 #include <wx/html/helpfrm.h>
53 #include <wx/html/helpctrl.h>
54 #include <wx/fontdlg.h>
55 #include <wx/confbase.h>
56 #include <wx/fileconf.h>
57 #include <wx/filename.h>
58 #include <wx/choicdlg.h>
90 #if defined(__WXGTK__) || defined(__WXMAC__)
91 #include "cn3d42App.xpm"
115 else if (sSet->
IsCDD())
117 else if (sSet->
objects.size() > 0) {
158 wxFrame(
NULL, wxID_HIGHEST + 1, title, pos,
size, wxDEFAULT_FRAME_STYLE),
159 glCanvas(
NULL), cddAnnotateDialog(
NULL), cddDescriptionDialog(
NULL), cddNotesDialog(
NULL),
160 cddRefDialog(
NULL), cddBookRefDialog(
NULL), cddOverview(
NULL),
161 spinIncrement(3.0), helpController(
NULL), helpConfig(
NULL),
162 fileMessagingManager("Cn3D"), fileMessenger(
NULL)
165 animationTimer.SetOwner(
this, MID_ANIMATE);
166 SetSizeHints(150, 150);
167 SetIcon(wxICON(cn3d));
172 menuBar =
new wxMenuBar;
173 fileMenu =
new wxMenu;
174 fileMenu->Append(MID_OPEN,
"&Open\tCtrl+O");
176 fileMenu->Append(MID_NETWORK_OPEN,
"&Network Load\tCtrl+L");
178 fileMenu->Append(MID_NETWORK_OPEN,
"&Network Load\tCtrl+N");
180 fileMenu->Append(MID_SAVE_SAME,
"&Save\tCtrl+S");
181 fileMenu->Append(MID_SAVE_AS,
"Save &As...");
182 fileMenu->Append(MID_PNG,
"&Export PNG");
183 fileMenu->AppendSeparator();
184 fileMenu->Append(MID_REFIT_ALL,
"&Realign Structures");
185 fileMenu->AppendSeparator();
186 fileMenu->Append(MID_PREFERENCES,
"&Preferences...");
187 wxMenu *subMenu =
new wxMenu;
188 subMenu->Append(MID_OPENGL_FONT,
"S&tructure Window");
189 subMenu->Append(MID_SEQUENCE_FONT,
"Se&quence Windows");
190 fileMenu->Append(MID_FONTS,
"Set &Fonts...", subMenu);
191 fileMenu->AppendSeparator();
192 fileMenu->Append(MID_EXIT,
"E&xit");
193 menuBar->Append(fileMenu,
"&File");
196 wxMenu *menu =
new wxMenu;
197 menu->Append(MID_ZOOM_IN,
"Zoom &In\tz");
198 menu->Append(MID_ZOOM_OUT,
"Zoom &Out\tx");
199 menu->Append(MID_RESTORE,
"&Restore");
200 menu->Append(MID_RESET,
"Rese&t");
201 menu->AppendSeparator();
203 menu->Append(MID_NEXT_FRAME,
"&Next Frame\tRight");
204 menu->Append(MID_PREV_FRAME,
"Pre&vious Frame\tLeft");
205 menu->Append(MID_FIRST_FRAME,
"&First Frame\tDown");
206 menu->Append(MID_LAST_FRAME,
"&Last Frame\tUp");
209 menu->Append(MID_NEXT_FRAME,
"&Next Frame");
210 menu->Append(MID_PREV_FRAME,
"Pre&vious Frame");
211 menu->Append(MID_FIRST_FRAME,
"&First Frame");
212 menu->Append(MID_LAST_FRAME,
"&Last Frame");
214 menu->Append(MID_ALL_FRAMES,
"&All Frames\ta");
215 menu->AppendSeparator();
216 subMenu =
new wxMenu;
217 subMenu->Append(MID_PLAY,
"&Play Frames\tp",
"",
true);
218 subMenu->Check(MID_PLAY,
false);
219 subMenu->Append(MID_SPIN,
"Spi&n\tn",
"",
true);
220 subMenu->Check(MID_SPIN,
false);
221 subMenu->Append(MID_STOP,
"&Stop\ts",
"",
true);
222 subMenu->Check(MID_STOP,
true);
223 subMenu->AppendSeparator();
224 subMenu->Append(MID_ANIM_CONTROLS,
"Set Spee&d");
225 menu->Append(MID_ANIMATE,
"Ani&mation", subMenu);
226 menu->AppendSeparator();
227 menu->Append(MID_STEREO,
"St&ereo",
"",
true);
228 menuBar->Append(menu,
"&View");
232 menu->Append(MID_SHOW_HIDE,
"&Pick Structures...");
233 menu->AppendSeparator();
234 menu->Append(MID_SHOW_ALL,
"Show &Everything\te");
235 menu->Append(MID_SHOW_CHAINS,
"Show Aligned C&hains");
236 menu->Append(MID_SHOW_DOMAINS,
"Show Aligned &Domains\td");
237 menu->Append(MID_SHOW_ALIGNED,
"Show &Aligned Residues");
238 subMenu =
new wxMenu;
239 subMenu->Append(MID_SHOW_UNALIGNED_ALL,
"Show &All");
240 subMenu->Append(MID_SHOW_UNALIGNED_ALN_DOMAIN,
"Show in Aligned &Domains");
241 menu->Append(MID_SHOW_UNALIGNED,
"&Unaligned Residues", subMenu);
242 menu->AppendSeparator();
243 menu->Append(MID_SHOW_SELECTED_DOMAINS,
"Show Selected Do&mains");
244 menu->Append(MID_SHOW_SELECTED_RESIDUES,
"Show &Selected Residues");
245 menu->AppendSeparator();
246 menu->Append(MID_DIST_SELECT,
"Select by Dis&tance...");
247 menu->Append(MID_SELECT_CHAIN,
"Toggle &Chain...");
248 menu->Append(MID_SELECT_MOLECULE,
"Select M&olecule...\tm");
249 menuBar->Append(menu,
"Se&lect");
253 menu->Append(MID_EDIT_STYLE,
"Edit &Global Style");
255 favoritesMenu =
new wxMenu;
256 favoritesMenu->Append(MID_ADD_FAVORITE,
"&Add/Replace");
257 favoritesMenu->Append(MID_REMOVE_FAVORITE,
"&Remove");
258 favoritesMenu->Append(MID_FAVORITES_FILE,
"&Change File");
259 favoritesMenu->AppendSeparator();
261 SetupFavoritesMenu();
262 menu->Append(MID_FAVORITES,
"&Favorites", favoritesMenu);
264 subMenu =
new wxMenu;
265 subMenu->Append(MID_WORM,
"&Worms",
"",
true);
266 subMenu->Append(MID_TUBE,
"&Tubes",
"",
true);
267 subMenu->Append(MID_WIRE,
"Wir&e",
"",
true);
268 subMenu->Append(MID_BNS,
"&Ball and Stick",
"",
true);
269 subMenu->Append(MID_SPACE,
"&Space Fill",
"",
true);
270 subMenu->AppendSeparator();
271 subMenu->Append(MID_SC_TOGGLE,
"&Toggle Sidechains");
272 menu->Append(MID_RENDER,
"&Rendering Shortcuts", subMenu);
274 subMenu =
new wxMenu;
275 subMenu->Append(MID_SECSTRUC,
"&Secondary Structure",
"",
true);
276 subMenu->Append(MID_ALIGNED,
"&Aligned",
"",
true);
277 wxMenu *subMenu2 =
new wxMenu;
278 subMenu2->Append(MID_IDENTITY,
"I&dentity",
"",
true);
279 subMenu2->Append(MID_VARIETY,
"&Variety",
"",
true);
280 subMenu2->Append(MID_WGHT_VAR,
"&Weighted Variety",
"",
true);
281 subMenu2->Append(MID_INFO,
"&Information Content",
"",
true);
282 subMenu2->Append(MID_FIT,
"&Fit",
"",
true);
283 subMenu2->Append(MID_BLOCK_FIT,
"&Block Fit",
"",
true);
284 subMenu2->Append(MID_BLOCK_Z_FIT,
"&Normalized Block Fit",
"",
true);
285 subMenu2->Append(MID_BLOCK_ROW_FIT,
"Block &Row Fit",
"",
true);
286 subMenu->Append(MID_CONS,
"Sequence &Conservation", subMenu2);
287 subMenu->Append(MID_OBJECT,
"&Object",
"",
true);
288 subMenu->Append(MID_DOMAIN,
"&Domain",
"",
true);
289 subMenu->Append(MID_MOLECULE,
"&Molecule",
"",
true);
290 subMenu->Append(MID_RESIDUE,
"Res&idue",
"",
true);
291 subMenu->Append(MID_RAINBOW,
"&Rainbow",
"",
true);
292 subMenu->Append(MID_HYDROPHOB,
"&Hydrophobicity",
"",
true);
293 subMenu->Append(MID_CHARGE,
"Char&ge",
"",
true);
294 subMenu->Append(MID_TEMP,
"&Temperature",
"",
true);
295 subMenu->Append(MID_ELEMENT,
"&Element",
"",
true);
296 menu->Append(MID_COLORS,
"&Coloring Shortcuts", subMenu);
298 menu->AppendSeparator();
299 menu->Append(MID_ANNOTATE,
"A&nnotate");
300 menuBar->Append(menu,
"&Style");
303 windowMenu =
new wxMenu;
304 windowMenu->Append(MID_SHOW_SEQ_V,
"Show &Sequence Viewer");
305 windowMenu->Append(MID_SHOW_LOG,
"Show Message &Log");
306 windowMenu->Append(MID_SHOW_LOG_START,
"Show Log on Start&up",
"",
true);
307 bool showLog =
false;
309 windowMenu->Check(MID_SHOW_LOG_START, showLog);
312 menuBar->Append(windowMenu,
"Show ...");
314 menuBar->Append(windowMenu,
"&Window");
321 menu->Append(MID_CDD_OVERVIEW,
"CDD &Overview");
322 menu->AppendSeparator();
323 menu->Append(MID_EDIT_CDD_NAME,
"Edit &Name");
324 menu->Enable(MID_EDIT_CDD_NAME, !readOnly);
325 menu->Append(MID_EDIT_CDD_DESCR,
"Edit &Description");
326 menu->Enable(MID_EDIT_CDD_DESCR, !readOnly);
327 menu->Append(MID_EDIT_CDD_NOTES,
"Edit No&tes");
328 menu->Enable(MID_EDIT_CDD_NOTES, !readOnly);
329 menu->Append(MID_EDIT_CDD_REFERENCES,
"Edit PubMed &References");
331 menu->Append(MID_EDIT_CDD_BOOK_REFERENCES,
"Edit &Book References");
333 menu->Append(MID_ANNOT_CDD,
"Edit &Annotations");
334 menu->Enable(MID_ANNOT_CDD, !readOnly);
335 menu->AppendSeparator();
338 menu->AppendSeparator();
339 menu->Append(MID_CDD_REJECT_SEQ,
"Re&ject Sequence");
340 menu->Enable(MID_CDD_REJECT_SEQ, !readOnly);
341 menu->Append(MID_CDD_SHOW_REJECTS,
"&Show Rejects");
342 menuBar->Append(menu,
"&CDD");
346 menu->Append(MID_HELP_COMMANDS,
"&Commands");
347 menu->Append(MID_ONLINE_HELP,
"Online &Help...");
348 menu->Append(MID_ABOUT,
"&About");
349 menuBar->Append(menu,
"&Help");
352 wxAcceleratorEntry
entries[12];
353 entries[0].Set(wxACCEL_NORMAL, WXK_RIGHT, MID_NEXT_FRAME);
354 entries[1].Set(wxACCEL_NORMAL, WXK_LEFT, MID_PREV_FRAME);
355 entries[2].Set(wxACCEL_NORMAL, WXK_DOWN, MID_FIRST_FRAME);
356 entries[3].Set(wxACCEL_NORMAL, WXK_UP, MID_LAST_FRAME);
357 entries[4].Set(wxACCEL_NORMAL,
'z', MID_ZOOM_IN);
358 entries[5].Set(wxACCEL_NORMAL,
'x', MID_ZOOM_OUT);
359 entries[6].Set(wxACCEL_NORMAL,
'a', MID_ALL_FRAMES);
360 entries[7].Set(wxACCEL_NORMAL,
'p', MID_PLAY);
361 entries[8].Set(wxACCEL_NORMAL,
'n', MID_SPIN);
362 entries[9].Set(wxACCEL_NORMAL,
's', MID_STOP);
363 entries[10].Set(wxACCEL_NORMAL,
'e', MID_SHOW_ALL);
364 entries[11].Set(wxACCEL_NORMAL,
'd', MID_SHOW_DOMAINS);
365 wxAcceleratorTable accel(12,
entries);
366 SetAcceleratorTable(accel);
370 menuBar->EnableTop(menuBar->FindMenu(
"CDD"),
false);
371 menuBar->Check(MID_STEREO,
false);
374 #if defined(__WXMSW__)
375 int *attribList =
NULL;
376 #elif defined(__WXGTK__)
377 int *attribList =
NULL;
378 #elif defined(__WXMAC__)
379 int *attribList =
NULL;
385 glCanvas->SetCurrent();
386 glCanvas->SetGLFontFromRegistry();
452 INFOMSG(
"received command " <<
id <<
" from " << fromApp <<
": " <<
command);
456 string replyData =
"failed to process\n";
463 if (replyData.size() > 0)
464 TRACEMSG(
"data:\n" << replyData.substr(0, replyData.size() - 1));
467 fileMessenger->SendReply(fromApp,
id, replyStatus, replyData);
475 INFOMSG(fromApp <<
": got OKAY from " << fromApp <<
" (command " <<
id <<
"), data: " <<
data);
477 ERRORMSG(fromApp <<
": got ERROR from " << fromApp <<
" (command " <<
id <<
"), data: " <<
data);
484 ERRORMSG(
"SendCommand: no message file active!");
489 static unsigned long nextCommandID = 1;
490 INFOMSG(
"sending command " << nextCommandID+1 <<
" to " << toApp <<
": " <<
command);
497 ERRORMSG(
"Can't send messages when return messaging is off");
515 wxString path = wxString(
GetPrefsDir().c_str()) +
"help_cache";
516 if (!wxDirExists(path)) {
517 INFOMSG(
"trying to create help cache folder " << path.c_str());
522 path = path + wxFILE_SEP_PATH +
"Config";
523 INFOMSG(
"saving help config in " << path.c_str());
524 helpConfig =
new wxFileConfig(
"Cn3D",
"NCBI", path);
528 path = wxString(
GetProgramDir().c_str()) +
"../Resources/cn3d_commands.htb";
530 path = wxString(
GetProgramDir().c_str()) +
"cn3d_commands.htb";
533 ERRORMSG(
"Can't load help book at " << path.c_str());
540 LaunchWebPage(
"https://www.ncbi.nlm.nih.gov/Structure/CN3D/cn3d.shtml");
548 "Produced by the National Center for Biotechnology Information\n"
549 " https://www.ncbi.nlm.nih.gov\n\n"
550 "Please direct all questions and comments to:\n"
551 " info@ncbi.nlm.nih.gov"
553 wxMessageBox(message,
"About Cn3D", wxOK | wxICON_INFORMATION,
this);
564 wxString idStr = wxGetTextFromUser(
"Enter an MMDB molecule ID or PDB chain:",
"Select molecule");
565 if (idStr.size() == 0)
568 bool isNum = idStr.ToULong(&num);
572 ChemicalGraph::MoleculeMap::const_iterator m, me =
575 if ((isNum && m->second->id == (
int)num) ||
579 && idStr.Cmp(m->second->name.c_str()) == 0) ||
582 && m->second->residues.size() == 1
583 && (((wxString) m->second->residues.begin()->second->
584 nameGraph.c_str()).Strip(wxString::both) == idStr)))))
586 if (m->second->sequence) {
589 Molecule::ResidueMap::const_iterator
r, re = m->second->residues.end();
590 for (
r=m->second->residues.begin();
r!=re; ++
r)
598 vector < string >
names;
599 vector < const Molecule * > molecules;
602 ChemicalGraph::MoleculeMap::const_iterator m, me = (*o)->graph->molecules.end();
603 for (m=(*o)->graph->molecules.begin(); m!=me; ++m) {
604 if (m->second->residues.size() > 1) {
605 names.push_back((*o)->GetPDBID() +
'_' + m->second->name);
606 molecules.push_back(m->second);
610 wxArrayString aChoices;
611 for (
unsigned int i=0;
i<
names.size(); ++
i)
612 aChoices.Add(
names[
i].c_str());
613 wxArrayInt selections;
614 int nSelected = wxGetSelectedChoices(selections,
"Choose chain(s) to toggle:",
"Select Chain", aChoices);
617 for (
size_t i=0;
i<selections.GetCount(); ++
i) {
618 const Molecule *molecule = molecules[selections.Item(
i)];
619 Molecule::ResidueMap::const_iterator
r, re = molecule->
residues.end();
627 static double latestCutoff = 5.0;
641 if (dialog.ShowModal() == wxID_OK && dialog.
fpSpinCtrl->GetDouble(&cutoff)) {
642 latestCutoff = cutoff;
652 if (dialog.
m_Other->GetValue())
699 else if (event.GetId() ==
MID_STOP) {
732 string section, faceName;
743 unique_ptr<wxFont> initialFont(wxFont::New(wxString(nativeFont.c_str())));
744 if (!initialFont.get() || !initialFont->Ok())
746 ERRORMSG(
"StructureWindow::OnSetFont() - error setting up initial font");
749 wxFontData initialFontData;
750 initialFontData.SetInitialFont(*initialFont);
753 wxFontDialog dialog(
this, initialFontData);
754 int result = dialog.ShowModal();
760 wxFontData& fontData = dialog.GetFontData();
761 wxFont font = fontData.GetChosenFont();
764 ERRORMSG(
"StructureWindow::OnSetFont() - error setting registry data");
788 file = wxFileSelector(
"Select a file for favorites:",
790 (forRead ? wxFD_OPEN : (wxFD_SAVE | wxFD_OVERWRITE_PROMPT))).c_str();
793 ERRORMSG(
"Error setting favorites file in registry");
803 string favoritesFile;
806 if (wxFile::Exists(favoritesFile.c_str())) {
807 INFOMSG(
"loading favorites from " << favoritesFile);
813 ERRORMSG(
"Error loading from favorites file " << favoritesFile);
816 WARNINGMSG(
"Favorites file does not exist: " << favoritesFile);
826 int choice = wxMessageBox(
"Do you want to save changes to your current Favorites file?",
827 "Save favorites?", wxYES_NO);
828 if (choice == wxYES) {
833 ERRORMSG(
"Error saving Favorites to " << favoritesFile <<
'\n' << err);
846 wxString name = wxGetTextFromUser(
"Enter a name for this style:",
"Input name",
"",
this);
847 if (name.size() == 0)
return;
854 settings =
f->GetPointer();
861 ERRORMSG(
"Already have max # Favorites");
871 ERRORMSG(
"Error converting global style to asn");
881 choices[
i++] = (*f)->GetName().c_str();
882 int picked = wxGetSingleChoiceIndex(
"Choose a style to remove from the Favorites list:",
901 ERRORMSG(
"Error loading Favorites from " << newFavorites.c_str());
932 INFOMSG(
"using favorite: " << (*f)->GetName());
944 switch (event.GetId()) {
972 ERRORMSG(
"Error saving CDD description");
978 TRACEMSG(
"MultiTextDialog destroyed");
1010 option = wxYES_NO | wxYES_DEFAULT | wxICON_EXCLAMATION | wxCENTRE;
1011 if (canCancel)
option |= wxCANCEL;
1013 wxMessageDialog dialog(
NULL,
"Do you want to save your work to a file?",
"",
option);
1014 option = dialog.ShowModal();
1016 if (
option == wxID_CANCEL)
return false;
1019 if (
option == wxID_YES) {
1020 wxCommandEvent event;
1034 a.first->identifier,
b.first->identifier);
1042 this, -1,
"CDD Descriptive Items", wxPoint(200,50));
1084 switch (event.GetId()) {
1091 wxString newName = wxGetTextFromUser(
"Enter or edit the CDD name:",
1093 if (newName.size() > 0) {
1145 GetCurrentMultipleAlignment()->GetSequenceOfRow(0)->identifier;
1147 SequenceSet::SequenceList::const_iterator
1150 if ((*s)->identifier != master) {
1153 bool rejected =
false;
1155 StructureSet::RejectList::const_iterator
r, re = rejects->end();
1156 for (
r=rejects->begin();
r!=re; ++
r) {
1157 CReject_id::TIds::const_iterator
i, ie = (*r)->GetIds().end();
1158 for (
i=(*r)->GetIds().begin();
i!=ie; ++
i) {
1159 if ((*s)->identifier->MatchesSeqId(**
i)) {
1164 if (rejected)
break;
1167 if (rejected)
continue;
1169 wxString description((*s)->identifier->ToString().c_str());
1170 string descr = (*s)->GetDescription();
1171 if (descr.size() > 0)
1172 description += wxString(
" ") + descr.c_str();
1173 seqsDescrs.resize(seqsDescrs.size() + 1);
1174 seqsDescrs.back().first = *s;
1175 seqsDescrs.back().second = description;
1182 wxString *choices =
new wxString[seqsDescrs.size()];
1184 for (choice=0; choice<(
int)seqsDescrs.size(); ++choice) choices[choice] = seqsDescrs[choice].second;
1185 choice = wxGetSingleChoiceIndex(
"Reject which sequence?",
"Reject Sequence",
1186 seqsDescrs.size(), choices,
this);
1188 wxString message =
"Are you sure you want to reject this sequence?\n\n";
1189 message += choices[choice];
1190 message +=
"\n\nIf so, enter a brief reason why:";
1191 wxString reason = wxGetTextFromUser(message,
"Reject Sequence",
"",
this);
1192 if (reason.size() == 0) {
1193 wxMessageBox(
"Reject action cancelled!",
"", wxOK | wxICON_INFORMATION,
this);
1195 int purge = wxMessageBox(
"Do you want to purge all instances of this sequence "
1196 " from the multiple alignment and update list?",
1197 "", wxYES_NO | wxICON_QUESTION,
this);
1200 RejectAndPurgeSequence(seqsDescrs[choice].
first,
WX_TO_STD(reason), purge == wxYES);
1211 switch (event.GetId()) {
1232 switch (event.GetId()) {
1236 vector < string > structureNames;
1237 vector < bool > structureVisibilities;
1239 wxString *titles =
new wxString[structureNames.size()];
1240 for (
unsigned int i=0;
i<structureNames.size(); ++
i) titles[
i] = structureNames[
i].c_str();
1244 this, -1,
"Show/Hide Structures", wxPoint(200, 50));
1287 BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator
b, be =
blocks.end();
1288 int nAligned = 0, nHighlighted = 0;
1290 nAligned += (*b)->width;
1292 for (
unsigned int i=0;
i<(*b)->width; ++
i)
1298 bool highlightedOnly =
false;
1299 if (nHighlighted > 0 && nHighlighted < nAligned) {
1301 message.Printf(
"Do you want to do the alignment using only the %i highlighted+aligned residues (on the master)? "
1302 "Answering 'no' will use all %i aligned residues regardless of highlights.", nHighlighted, nAligned);
1303 int answer = wxMessageBox(message,
"Use highlighted+aligned residues?", wxYES_NO | wxCANCEL | wxICON_QUESTION,
this);
1304 if (answer == wxCANCEL)
1306 highlightedOnly = (answer == wxYES);
1315 #define RENDERING_SHORTCUT(type, menu) \
1316 glCanvas->structureSet->styleManager->SetGlobalRenderingStyle(StyleSettings::type); \
1317 SetRenderingMenuFlag(menu); \
1319 #define COLORING_SHORTCUT(type, menu) \
1320 glCanvas->structureSet->styleManager->SetGlobalColorScheme(StyleSettings::type); \
1321 SetColoringMenuFlag(menu); \
1328 switch (event.GetId()) {
1407 wxString choices[3];
1409 choices[0] =
"Single model";
1411 choices[1] =
"Alpha only";
1413 choices[2] =
"PDB model(s)";
1416 wxSingleChoiceDialog dialog(parent,
"Please select which type of model you'd like to load",
1417 "Select model", 3, choices, (
void **)
NULL, (wxCAPTION | wxSYSTEM_MENU | wxOK | wxCENTRE));
1418 if (dialog.ShowModal() != wxID_OK) {
1419 ERRORMSG(
"Oops, somehow dialog failed to return OK");
1423 return models[dialog.GetSelection()];
1432 if (wxIsAbsolutePath(filename))
1433 userDir =
string(wxPathOnly(filename).c_str()) + wxFILE_SEP_PATH;
1434 else if (wxPathOnly(filename) ==
"")
1448 WARNINGMSG(
"Can't get structure limit from registry");
1456 ERRORMSG(
"Cannot open file '" << filename <<
"' for reading");
1463 *inStream >> firstWord;
1467 asciiMimeFirstWord =
"Ncbi-mime-asn1",
1468 asciiCDDFirstWord =
"Cdd",
1469 asciiBiostrucFirstWord =
"Biostruc";
1470 bool isMime =
false, isCDD =
false, isBiostruc =
false;
1472 if (firstWord == asciiMimeFirstWord) {
1475 }
else if (firstWord == asciiCDDFirstWord) {
1478 }
else if (firstWord == asciiBiostrucFirstWord) {
1486 bool readOK =
false;
1488 if (!isCDD && !isBiostruc) {
1489 TRACEMSG(
"trying to read file '" << filename <<
"' as " <<
1496 *sset =
new StructureSet(mime, structureLimit, renderer);
1498 if (window && (*sset)->IsCDD())
1505 if (!readOK && !isMime && !isBiostruc) {
1506 TRACEMSG(
"trying to read file '" << filename <<
"' as " <<
1513 *sset =
new StructureSet(cdd, structureLimit, renderer);
1519 if (!readOK && !isMime && !isCDD) {
1520 TRACEMSG(
"trying to read file '" << filename <<
"' as " <<
1533 ERRORMSG(
"File not found, not readable, or is not a recognized data type");
1540 *sset =
new StructureSet(mimeData, structureLimit, renderer);
1545 bool foundPreferred =
false;
1546 if (favoriteStyle.size() > 0) {
1551 if ((*f)->GetName() == favoriteStyle) {
1552 INFOMSG(
"using favorite: " << (*f)->GetName());
1553 (*sset)->styleManager->SetGlobalStyle(**
f);
1558 foundPreferred =
true;
1564 if (!foundPreferred) {
1567 if ((*sset)->hasUserStyle) {
1568 TRACEMSG(
"Using global style from incoming data...");
1577 if ((*sset)->alignmentSet) {
1580 if ((*sset)->IsCDD()) {
1605 SetCursor(*wxHOURGLASS_CURSOR);
1627 SetCursor(wxNullCursor);
1632 SetCursor(wxNullCursor);
1633 ERRORMSG(
"StructureWindow::LoadData() - MonitorAlignments() returned error");
1649 SetCursor(wxNullCursor);
1662 const wxString& filestr = wxFileSelector(
"Choose a text or binary ASN1 file to open",
userDir.c_str(),
1663 "",
"",
"All Files|*.*|Cn3D Files (*.cn3)|*.cn3",
1665 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
this);
1667 wxFD_OPEN | wxFD_FILE_MUST_EXIST);
1669 if (!filestr.IsEmpty())
1670 LoadData(filestr.c_str(),
false,
false);
1674 wxString
id = wxGetTextFromUser(
"Please enter a PDB or MMDB id",
"Input id");
1691 wxString dir = wxString(
userDir.c_str()).MakeLower();
1693 if (dir.Contains(
"cache") || dir.Contains(
"temp") || dir.Contains(
"tmp"))
1700 wxString outputFolder = wxString(
userDir.c_str(),
userDir.size() - 1);
1701 wxString outputFilename;
1707 wxFileDialog dialog(
this,
"Choose a filename and type for output", outputFolder,
1713 "All Files|*.*|Binary (*.cn3)|*.cn3|Text (*.cn3)|*.cn3|Text CDD (*.cn3)|*.cn3",
1714 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
1716 if (dialog.ShowModal() == wxID_OK)
1717 outputFilename = dialog.GetPath();
1718 outputBinary = (dialog.GetFilterIndex() == 1);
1719 outputCDD = (dialog.GetFilterIndex() == 3);
1724 if (!outputFilename.IsEmpty()) {
1726 TRACEMSG(
"binary = " << outputBinary <<
", cdd = " << outputCDD);
1727 INFOMSG(
"save file: '" << outputFilename.c_str() <<
"'");
1736 cddName = wxGetTextFromUser(
"Enter a name for this CD",
"Input Name");
1738 ERRORMSG(
"Conversion to Cdd failed");
1744 unsigned int changeFlags;
1748 string data(outputFilename.c_str());
1750 TRACEMSG(
"changeFlags: " << changeFlags);
1752 data +=
"AlignmentChanged\n";
1754 data +=
"RowOrderChanged\n";
1756 data +=
"PSSMChanged\n";
1758 data +=
"DescriptionChanged\n";
1760 data +=
"PendingAlignmentsChanged\n";
1764 #if defined(__WXMAC__) && !defined(__WXOSX_COCOA__)
1767 wxFileName wxfn(outputFilename);
1768 if (wxfn.FileExists())
1769 if (!wxfn.MacSetTypeAndCreator(
'TEXT',
'Cn3D'))
1770 WARNINGMSG(
"Unable to set Mac file type/creator");
1774 if (wxIsAbsolutePath(outputFilename))
1775 userDir =
string(wxPathOnly(outputFilename).c_str()) + wxFILE_SEP_PATH;
1776 else if (wxPathOnly(outputFilename) ==
"")
User-defined methods of the data storage class.
User-defined methods of the data storage class.
void ShowSequenceViewer(bool showNow) const
void RealignAllDependentStructures(bool highlightedOnly) const
const BlockMultipleAlignment * GetCurrentMultipleAlignment(void) const
const Sequence * GetMaster(void) const
std::vector< const UngappedAlignedBlock * > UngappedAlignedBlockList
void GetUngappedAlignedBlocks(UngappedAlignedBlockList *blocks) const
CCn3d_style_settings_set –.
OpenGLRenderer * renderer
void SetGLFontFromRegistry(double fontScale=1.0)
StructureSet * structureSet
void ProcessCommand(const std::string &command, const std::string &dataIn, ncbi::MessageResponder::ReplyStatus *status, std::string *dataOut)
wxCheckBox * m_Nucleotide
ncbi::FloatingPointSpinCtrl * fpSpinCtrl
void SetAllWindowTitles(void) const
void NewSequenceViewerFont(void)
void SequenceWindowsSave(bool prompt)
void RemoveStructureWindow(const StructureWindow *structureWindow)
bool RemoveAllHighlights(bool postRedraws)
void ToggleHighlight(const Molecule *molecule, int residueID, bool scrollViewersTo=false)
void PostRedrawAllStructures(void)
void AddStructureWindow(StructureWindow *window)
void PostRedrawAllSequenceViewers(void)
void AddHighlights(const Sequence *sequence, unsigned int seqIndexFrom, unsigned int seqIndexTo)
void CacheHighlights(void)
static bool CompareIdentifiers(const MoleculeIdentifier *a, const MoleculeIdentifier *b)
bool GetLine(std::string *singleString) const
bool GetLines(TextLines *lines) const
void ShowPreviousFrame(void)
void AttachStructureSet(StructureSet *targetStructureSet)
void ShowFirstFrame(void)
double GetRotateSpeed(void) const
void ChangeView(eViewAdjust control, int dX=0, int dY=0, int X2=0, int Y2=0)
void RestoreSavedView(void)
void EnableStereo(bool enableStereo)
bool HasASNViewSettings(void) const
void ComputeBestView(void)
void ShowDomainsWithHighlights(const StructureSet *set)
void ShowSelectedResidues(const StructureSet *set)
void ShowResidues(const StructureSet *set, bool showAligned)
void ShowAlignedDomains(const StructureSet *set)
void MakeAllVisible(void)
void ShowAlignedChains(const StructureSet *set)
void GetShowHideInfo(std::vector< std::string > *names, std::vector< bool > *visibilities) const
bool IsCDDInMime(void) const
static const unsigned int eRowOrderData
std::vector< std::string > TextLines
const RejectList * GetRejects(void) const
void ShowRejects(void) const
void SelectByDistance(double cutoff, unsigned int options) const
static const unsigned int eAnyAlignmentData
const SequenceSet * sequenceSet
bool SetCDDDescription(const std::string &descr)
static const unsigned int eSelectProtein
static const unsigned int eSelectNucleotide
static const unsigned int eSelectHeterogen
static const unsigned int eCDDData
bool SaveASNData(const char *filename, bool doBinary, unsigned int *changeFlags)
bool SetCDDName(const std::string &name)
bool SetCDDNotes(const TextLines &lines)
bool MonitorAlignments(void) const
AlignmentManager * alignmentManager
ShowHideManager * showHideManager
bool ConvertMimeDataToCDD(const std::string &cddName)
static const unsigned int eUpdateData
const std::string & GetCDDName(void) const
bool HasDataChanged(void) const
static const unsigned int eSelectSolvent
StyleManager * styleManager
static const unsigned int eSelectOtherMoleculesOnly
const std::string & GetCDDDescription(void) const
static const unsigned int ePSSMData
std::list< ncbi::CRef< ncbi::objects::CReject_id > > RejectList
bool GetCDDNotes(TextLines *lines) const
CDDRefDialog * cddRefDialog
bool SaveDialog(bool prompt, bool canCancel)
void OnShowWindow(wxCommandEvent &event)
CDDBookRefDialog * cddBookRefDialog
std::string preferredFavoriteStyle
void ShowCDDReferences(void)
wxTimer fileMessagingTimer
void OnPNG(wxCommandEvent &event)
void OnSetStyle(wxCommandEvent &event)
ncbi::FileMessagingManager fileMessagingManager
void OnShowHide(wxCommandEvent &event)
void OnAlignStructures(wxCommandEvent &event)
void OnAnimationTimer(wxTimerEvent &event)
void OnExit(wxCommandEvent &event)
void ReceivedReply(const std::string &fromApp, unsigned long id, ncbi::MessageResponder::ReplyStatus status, const std::string &data)
void ShowCDDOverview(void)
void SetWindowTitle(void)
void OnCloseWindow(wxCloseEvent &event)
void SetRenderingMenuFlag(int which)
void SendCommand(const std::string &toApp, const std::string &command, const std::string &data)
bool IsFileMessengerActive(void) const
void OnSelectFavorite(wxCommandEvent &event)
void OnFileMessagingTimer(wxTimerEvent &event)
void SetupFavoritesMenu(void)
void OnCDD(wxCommandEvent &event)
void OnPreferences(wxCommandEvent &event)
void DialogTextChanged(const MultiTextDialog *changed)
void ShowCDDBookReferences(void)
void OnHelp(wxCommandEvent &event)
void OnSelect(wxCommandEvent &event)
CommandProcessor * commandProcessor
void OnSave(wxCommandEvent &event)
void SetupFileMessenger(const std::string &messageFilename, const std::string &messageApp, bool readOnly)
void ReceivedCommand(const std::string &fromApp, unsigned long id, const std::string &command, const std::string &data)
MultiTextDialog * cddDescriptionDialog
void OnEditFavorite(wxCommandEvent &event)
void ShowCDDAnnotations(void)
void OnSetFont(wxCommandEvent &event)
wxFileConfig * helpConfig
ncbi::FileMessenger * fileMessenger
wxHtmlHelpController * helpController
void OnOpen(wxCommandEvent &event)
void SetColoringMenuFlag(int which)
void DialogDestroyed(const MultiTextDialog *destroyed)
CDDAnnotateDialog * cddAnnotateDialog
CDDSplashDialog * cddOverview
bool LoadData(const char *filename, bool force, bool noAlignmentWindow, ncbi::objects::CNcbi_mime_asn1 *mimeData=NULL)
void OnAnimate(wxCommandEvent &event)
@ MID_EDIT_CDD_REFERENCES
@ MID_EDIT_CDD_BOOK_REFERENCES
@ MID_SHOW_SELECTED_RESIDUES
@ MID_SHOW_SELECTED_DOMAINS
@ MID_SHOW_UNALIGNED_ALN_DOMAIN
void DestroyNonModalDialogs(void)
void OnAdjustView(wxCommandEvent &event)
void OnSendSelection(wxCommandEvent &event)
MultiTextDialog * cddNotesDialog
std::string messageTargetApp
const StyleSettings & GetGlobalStyle(void) const
bool SetGlobalStyle(const ncbi::objects::CCn3d_style_settings &styleASN)
bool EditUserAnnotations(wxWindow *parent)
bool EditGlobalStyle(wxWindow *parent)
bool CheckGlobalStyleSettings(void)
@ eInformationContentShortcut
@ eSecondaryStructureShortcut
bool SaveSettingsToASN(ncbi::objects::CCn3d_style_settings *styleASN) const
void RaiseLogWindow(void)
bool IsWindowedMode(void)
CNcbi_mime_asn1 * LoadStructureViaCache(const std::string &uid, ncbi::objects::EModel_type modelType, int assemblyId)
bool ExportPNG(Cn3DGLCanvas *glCanvas, OpenGLRenderer *renderer, const string &outputFilename, int outputWidth, int outputHeight, bool interlaced)
Include a standard set of the NCBI C++ Toolkit most basic headers.
static bool ReadASNFromFile(const char *filename, ASNClass *ASNobject, bool isBinary, std::string *err)
static bool WriteASNToFile(const char *filename, const ASNClass &ASNobject, bool isBinary, std::string *err, ncbi::EFixNonPrint fixNonPrint=ncbi::eFNP_Default)
CNcbi_mime_asn1 * CreateMimeFromBiostruc(const string &filename, EModel_type model)
static const struct name_t names[]
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
@ eDiag_Info
Informational message.
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
EModel_type
Access to EModel_type's attributes (values, names) as defined in spec.
@ eModel_type_ncbi_all_atom
@ eModel_type_ncbi_backbone
void SetName(const TName &value)
Assign a value to Name data member.
const Tdata & Get(void) const
Get the member data.
void Reset(void)
Reset data member.
Tdata & Set(void)
Assign a value to data member.
unsigned int
A callback function used to compare two keys in a database.
Messenger * GlobalMessenger(void)
const TYPE & Get(const CNamedParameterList *param)
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines: CTimeFormat - storage class for time format.
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
EVT_MENU_RANGE(MID_SHOW_TITLES, MID_HIDE_TITLES, ViewerWindowBase::OnTitleView) EVT_MENU_RANGE(MID_ENABLE_EDIT
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
static DP_BlockInfo * blocks
#define RENDERING_SHORTCUT(type, menu)
static CCn3d_style_settings_set favoriteStyles
static void SetWorkingTitle(StructureSet *sSet)
pair< const Sequence *, wxString > SeqAndDescr
static bool CompareSequencesByIdentifier(const SeqAndDescr &a, const SeqAndDescr &b)
static void SaveFavorites(void)
static string currentFile
static bool LoadFavorites(void)
#define COLORING_SHORTCUT(type, menu)
static bool currentFileIsBinary
static string GetFavoritesFile(bool forRead)
bool LoadDataOnly(StructureSet **sset, OpenGLRenderer *renderer, const char *filename, CNcbi_mime_asn1 *mimeData, const string &favoriteStyle, EModel_type model, StructureWindow *window)
const string & GetUserDir(void)
const string & GetWorkingFilename(void)
vector< SeqAndDescr > SeqAndDescrList
static bool favoriteStylesChanged
static EModel_type GetModelTypeFromUser(wxWindow *parent)
const string & GetWorkingTitle(void)
static string workingTitle
static void SetTitle(CRef< CSeq_entry > entry, string title)
static wxAcceleratorEntry entries[3]