⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 structure_window.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* * =========================================================================== * PRODUCTION $Log: structure_window.cpp,v $ * PRODUCTION Revision 1000.3  2004/06/01 18:29:33  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.33 * PRODUCTION * =========================================================================== *//*  $Id: structure_window.cpp,v 1000.3 2004/06/01 18:29:33 gouriano Exp $* ===========================================================================**                            PUBLIC DOMAIN NOTICE*               National Center for Biotechnology Information**  This software/database is a "United States Government Work" under the*  terms of the United States Copyright Act.  It was written as part of*  the author's official duties as a United States Government employee and*  thus cannot be copyrighted.  This software/database is freely available*  to the public for use. The National Library of Medicine and the U.S.*  Government have not placed any restriction on its use or reproduction.**  Although all reasonable efforts have been taken to ensure the accuracy*  and reliability of the software and data, the NLM and the U.S.*  Government do not and cannot warrant the performance or results that*  may be obtained by using this software or data. The NLM and the U.S.*  Government disclaim all warranties, express or implied, including*  warranties of performance, merchantability or fitness for any particular*  purpose.**  Please cite the author in any work or product based on this material.** ===========================================================================** Authors:  Paul Thiessen** File Description:*      structure window object for Cn3D** ===========================================================================*/#ifdef _MSC_VER#pragma warning(disable:4018)   // disable signed/unsigned mismatch warning in MSVC#endif#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <corelib/ncbitime.hpp> // avoids some 'CurrentTime' conflict later on...#include <objects/ncbimime/Ncbi_mime_asn1.hpp>#include <objects/cdd/Cdd.hpp>#include <objects/mmdb2/Model_type.hpp>#include <algorithm>#include <memory>#ifdef __WXMSW__#include <windows.h>#include <wx/msw/winundef.h>#endif#include <wx/wx.h>#include <wx/html/helpfrm.h>#include <wx/html/helpctrl.h>#include <wx/fontdlg.h>#include <wx/confbase.h>#include <wx/fileconf.h>#include <wx/filename.h>#include <wx/choicdlg.h>#include "asn_reader.hpp"#include "cn3d_glcanvas.hpp"#include "structure_window.hpp"#include "structure_set.hpp"#include "opengl_renderer.hpp"#include "style_manager.hpp"#include "messenger.hpp"#include "chemical_graph.hpp"#include "alignment_manager.hpp"#include "show_hide_manager.hpp"#include "show_hide_dialog.hpp"#include "cn3d_tools.hpp"#include "cdd_annot_dialog.hpp"#include "preferences_dialog.hpp"#include "cdd_ref_dialog.hpp"#include "cdd_book_ref_dialog.hpp"#include "cn3d_png.hpp"#include "wx_tools.hpp"#include "block_multiple_alignment.hpp"#include "sequence_set.hpp"#include "molecule_identifier.hpp"#include "cdd_splash_dialog.hpp"#include "command_processor.hpp"#include "animation_controls.hpp"#include "cn3d_cache.hpp"// the application icon (under Windows it is in resources)#if defined(__WXGTK__) || defined(__WXMAC__)    #include "cn3d.xpm"#endif#include <ncbienv.h>USING_NCBI_SCOPE;USING_SCOPE(objects);BEGIN_SCOPE(Cn3D)// global stringsstatic string    userDir,        // directory of latest user-selected file    currentFile;    // name of current working fileconst string& GetUserDir(void) { return userDir; }const string& GetWorkingFilename(void) { return currentFile; }// global working titlestatic string workingTitle;const string& GetWorkingTitle(void) { return workingTitle; }static void SetWorkingTitle(StructureSet *sSet){    if (sSet->IsCDDInMime() && sSet->GetCDDName().size() > 0)        workingTitle = sSet->GetCDDName();      // for CDD's sent by server    else if (sSet->IsCDD())        workingTitle = GetWorkingFilename();    // for CDD's edited by curators    else if (sSet->objects.size() > 0) {        workingTitle = sSet->objects.front()->pdbID;        if (sSet->objects.size() > 1)            workingTitle += " neighbors";    } else        workingTitle = GetWorkingFilename();}// favorites stuffstatic bool favoriteStylesChanged = false;static CCn3d_style_settings_set favoriteStyles;static bool LoadFavorites(void);static void SaveFavorites(void);BEGIN_EVENT_TABLE(StructureWindow, wxFrame)    EVT_CLOSE     (                                         StructureWindow::OnCloseWindow)    EVT_MENU      (MID_EXIT,                                StructureWindow::OnExit)    EVT_MENU_RANGE(MID_OPEN, MID_NETWORK_OPEN,              StructureWindow::OnOpen)    EVT_MENU_RANGE(MID_SAVE_SAME, MID_SAVE_AS,              StructureWindow::OnSave)    EVT_MENU      (MID_PNG,                                 StructureWindow::OnPNG)    EVT_MENU_RANGE(MID_ZOOM_IN,  MID_STEREO,                StructureWindow::OnAdjustView)    EVT_MENU_RANGE(MID_SHOW_HIDE,  MID_SELECT_MOLECULE,     StructureWindow::OnShowHide)    EVT_MENU_RANGE(MID_DIST_SELECT_RESIDUES, MID_DIST_SELECT_OTHER_ALL, StructureWindow::OnDistanceSelect)    EVT_MENU      (MID_REFIT_ALL,                           StructureWindow::OnAlignStructures)    EVT_MENU_RANGE(MID_EDIT_STYLE, MID_ANNOTATE,            StructureWindow::OnSetStyle)    EVT_MENU_RANGE(MID_ADD_FAVORITE, MID_FAVORITES_FILE,    StructureWindow::OnEditFavorite)    EVT_MENU_RANGE(MID_FAVORITES_BEGIN, MID_FAVORITES_END,  StructureWindow::OnSelectFavorite)    EVT_MENU_RANGE(MID_SHOW_LOG,   MID_SHOW_SEQ_V,          StructureWindow::OnShowWindow)    EVT_MENU_RANGE(MID_CDD_OVERVIEW, MID_CDD_SHOW_REJECTS,  StructureWindow::OnCDD)    EVT_MENU      (MID_PREFERENCES,                         StructureWindow::OnPreferences)    EVT_MENU_RANGE(MID_OPENGL_FONT, MID_SEQUENCE_FONT,      StructureWindow::OnSetFont)    EVT_MENU_RANGE(MID_PLAY, MID_ANIM_CONTROLS,             StructureWindow::OnAnimate)    EVT_MENU_RANGE(MID_HELP_COMMANDS, MID_ONLINE_HELP,      StructureWindow::OnHelp)    EVT_MENU      (MID_ABOUT,                               StructureWindow::OnHelp)    EVT_TIMER     (MID_ANIMATE,                             StructureWindow::OnAnimationTimer)    EVT_TIMER     (MID_MESSAGING,                           StructureWindow::OnFileMessagingTimer)    EVT_MENU      (MID_SEND_SELECTION,                      StructureWindow::OnSendSelection)END_EVENT_TABLE()StructureWindow::StructureWindow(const wxString& title, const wxPoint& pos, const wxSize& size) :    wxFrame(NULL, wxID_HIGHEST + 1, title, pos, size, wxDEFAULT_FRAME_STYLE | wxTHICK_FRAME),    glCanvas(NULL), cddAnnotateDialog(NULL), cddDescriptionDialog(NULL), cddNotesDialog(NULL),    cddRefDialog(NULL), cddBookRefDialog(NULL), helpController(NULL), helpConfig(NULL),    cddOverview(NULL), fileMessagingManager("Cn3D"), fileMessenger(NULL), spinIncrement(3.0){    GlobalMessenger()->AddStructureWindow(this);    animationTimer.SetOwner(this, MID_ANIMATE);    SetSizeHints(150, 150); // min size    SetIcon(wxICON(cn3d));    commandProcessor = new CommandProcessor(this);    // File menu    menuBar = new wxMenuBar;    fileMenu = new wxMenu;    fileMenu->Append(MID_OPEN, "&Open\tCtrl+O");    fileMenu->Append(MID_NETWORK_OPEN, "&Network Load\tCtrl+N");    fileMenu->Append(MID_SAVE_SAME, "&Save\tCtrl+S");    fileMenu->Append(MID_SAVE_AS, "Save &As...");    fileMenu->Append(MID_PNG, "&Export PNG");    fileMenu->AppendSeparator();    fileMenu->Append(MID_REFIT_ALL, "&Realign Structures");    fileMenu->AppendSeparator();    fileMenu->Append(MID_PREFERENCES, "&Preferences...");    wxMenu *subMenu = new wxMenu;    subMenu->Append(MID_OPENGL_FONT, "S&tructure Window");    subMenu->Append(MID_SEQUENCE_FONT, "Se&quence Windows");    fileMenu->Append(MID_FONTS, "Set &Fonts...", subMenu);    fileMenu->AppendSeparator();    fileMenu->Append(MID_EXIT, "E&xit");    menuBar->Append(fileMenu, "&File");    // View menu    wxMenu *menu = new wxMenu;    menu->Append(MID_ZOOM_IN, "Zoom &In\tz");    menu->Append(MID_ZOOM_OUT, "Zoom &Out\tx");    menu->Append(MID_RESTORE, "&Restore");    menu->Append(MID_RESET, "Rese&t");    menu->AppendSeparator();#ifdef __WXMSW__    menu->Append(MID_NEXT_FRAME, "&Next Frame\tRight");    menu->Append(MID_PREV_FRAME, "Pre&vious Frame\tLeft");    menu->Append(MID_FIRST_FRAME, "&First Frame\tDown");    menu->Append(MID_LAST_FRAME, "&Last Frame\tUp");#else    // other platforms don't like to display these long accelerator names    menu->Append(MID_NEXT_FRAME, "&Next Frame");    menu->Append(MID_PREV_FRAME, "Pre&vious Frame");    menu->Append(MID_FIRST_FRAME, "&First Frame");    menu->Append(MID_LAST_FRAME, "&Last Frame");#endif    menu->Append(MID_ALL_FRAMES, "&All Frames\ta");    menu->AppendSeparator();    subMenu = new wxMenu;    subMenu->Append(MID_PLAY, "&Play Frames\tp", "", true);    subMenu->Check(MID_PLAY, false);    subMenu->Append(MID_SPIN, "Spi&n\tn", "", true);    subMenu->Check(MID_SPIN, false);    subMenu->Append(MID_STOP, "&Stop\ts", "", true);    subMenu->Check(MID_STOP, true);    subMenu->AppendSeparator();    subMenu->Append(MID_ANIM_CONTROLS, "Set Spee&d");    menu->Append(MID_ANIMATE, "Ani&mation", subMenu);    menu->AppendSeparator();    menu->Append(MID_STEREO, "St&ereo", "", true);    menuBar->Append(menu, "&View");    // Show-Hide menu    menu = new wxMenu;    menu->Append(MID_SHOW_HIDE, "&Pick Structures...");    menu->AppendSeparator();    menu->Append(MID_SHOW_ALL, "Show &Everything\te");    menu->Append(MID_SHOW_DOMAINS, "Show Aligned &Domains\td");    menu->Append(MID_SHOW_ALIGNED, "Show &Aligned Residues");    menu->Append(MID_SHOW_SELECTED_RESIDUES, "Show &Selected Residues");    menu->Append(MID_SHOW_SELECTED_DOMAINS, "Show Selected Do&mains");    subMenu = new wxMenu;    subMenu->Append(MID_SHOW_UNALIGNED_ALL, "Show &All");    subMenu->Append(MID_SHOW_UNALIGNED_ALN_DOMAIN, "Show in Aligned &Domains");    menu->Append(MID_SHOW_UNALIGNED, "&Unaligned Residues", subMenu);    menu->AppendSeparator();    subMenu = new wxMenu;    subMenu->Append(MID_DIST_SELECT_RESIDUES, "&Residues Only");    subMenu->Append(MID_DIST_SELECT_ALL, "&All Molecules");    subMenu->Append(MID_DIST_SELECT_OTHER_RESIDUES, "&Other Residues");    subMenu->Append(MID_DIST_SELECT_OTHER_ALL, "Other &Molecules");    menu->Append(MID_DIST_SELECT, "Select by Dis&tance...", subMenu);    menu->Append(MID_SELECT_MOLECULE, "Select Molecule...\tm");    menuBar->Append(menu, "Show/&Hide");    // Style menu    menu = new wxMenu;    menu->Append(MID_EDIT_STYLE, "Edit &Global Style");    // favorites    favoritesMenu = new wxMenu;    favoritesMenu->Append(MID_ADD_FAVORITE, "&Add/Replace");    favoritesMenu->Append(MID_REMOVE_FAVORITE, "&Remove");    favoritesMenu->Append(MID_FAVORITES_FILE, "&Change File");    favoritesMenu->AppendSeparator();    LoadFavorites();    SetupFavoritesMenu();    menu->Append(MID_FAVORITES, "&Favorites", favoritesMenu);    // rendering shortcuts    subMenu = new wxMenu;    subMenu->Append(MID_WORM, "&Worms", "", true);    subMenu->Append(MID_TUBE, "&Tubes", "", true);    subMenu->Append(MID_WIRE, "Wir&e", "", true);    subMenu->Append(MID_BNS, "&Ball and Stick", "", true);    subMenu->Append(MID_SPACE, "&Space Fill", "", true);    subMenu->AppendSeparator();    subMenu->Append(MID_SC_TOGGLE, "&Toggle Sidechains");    menu->Append(MID_RENDER, "&Rendering Shortcuts", subMenu);    // coloring shortcuts    subMenu = new wxMenu;    subMenu->Append(MID_SECSTRUC, "&Secondary Structure", "", true);    subMenu->Append(MID_ALIGNED, "&Aligned", "", true);    wxMenu *subMenu2 = new wxMenu;    subMenu2->Append(MID_IDENTITY, "I&dentity", "", true);    subMenu2->Append(MID_VARIETY, "&Variety", "", true);    subMenu2->Append(MID_WGHT_VAR, "&Weighted Variety", "", true);    subMenu2->Append(MID_INFO, "&Information Content", "", true);    subMenu2->Append(MID_FIT, "&Fit", "", true);    subMenu2->Append(MID_BLOCK_FIT, "&Block Fit", "", true);    subMenu2->Append(MID_BLOCK_Z_FIT, "&Normalized Block Fit", "", true);    subMenu2->Append(MID_BLOCK_ROW_FIT, "Block &Row Fit", "", true);    subMenu->Append(MID_CONS, "Sequence &Conservation", subMenu2);    subMenu->Append(MID_OBJECT, "&Object", "", true);    subMenu->Append(MID_DOMAIN, "&Domain", "", true);    subMenu->Append(MID_MOLECULE, "&Molecule", "", true);    subMenu->Append(MID_RAINBOW, "&Rainbow", "", true);    subMenu->Append(MID_HYDROPHOB, "&Hydrophobicity", "", true);    subMenu->Append(MID_CHARGE, "Char&ge", "", true);    subMenu->Append(MID_TEMP, "&Temperature", "", true);    subMenu->Append(MID_ELEMENT, "&Element", "", true);    menu->Append(MID_COLORS, "&Coloring Shortcuts", subMenu);    //annotate    menu->AppendSeparator();    menu->Append(MID_ANNOTATE, "A&nnotate");    menuBar->Append(menu, "&Style");    // Window menu    windowMenu = new wxMenu;    windowMenu->Append(MID_SHOW_SEQ_V, "Show &Sequence Viewer");    windowMenu->Append(MID_SHOW_LOG, "Show Message &Log");    windowMenu->Append(MID_SHOW_LOG_START, "Show Log on Start&up", "", true);    bool showLog = false;    RegistryGetBoolean(REG_CONFIG_SECTION, REG_SHOW_LOG_ON_START, &showLog);    windowMenu->Check(MID_SHOW_LOG_START, showLog);    menuBar->Append(windowMenu, "&Window");    // CDD menu    bool readOnly;    RegistryGetBoolean(REG_ADVANCED_SECTION, REG_CDD_ANNOT_READONLY, &readOnly);    menu = new wxMenu;    menu->Append(MID_CDD_OVERVIEW, "CDD &Overview");    menu->AppendSeparator();    menu->Append(MID_EDIT_CDD_NAME, "Edit &Name");    menu->Enable(MID_EDIT_CDD_NAME, !readOnly);    menu->Append(MID_EDIT_CDD_DESCR, "Edit &Description");    menu->Enable(MID_EDIT_CDD_DESCR, !readOnly);    menu->Append(MID_EDIT_CDD_NOTES, "Edit No&tes");    menu->Enable(MID_EDIT_CDD_NOTES, !readOnly);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -