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

📄 style_dialog.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* * =========================================================================== * PRODUCTION $Log: style_dialog.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 18:29:38  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.27 * PRODUCTION * =========================================================================== *//*  $Id: style_dialog.cpp,v 1000.2 2004/06/01 18:29:38 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:*      dialog for setting styles** ===========================================================================*/#ifdef _MSC_VER#pragma warning(disable:4018)   // disable signed/unsigned mismatch warning in MSVC#endif#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include "style_dialog.hpp"#include "style_manager.hpp"#include "cn3d_tools.hpp"#include "structure_set.hpp"#include "messenger.hpp"#include "wx_tools.hpp"#include <wx/colordlg.h>////////////////////////////////////////////////////////////////////////////////////////////////// The following is taken unmodified from wxDesigner's C++ header from render_settings.wdr////////////////////////////////////////////////////////////////////////////////////////////////#include <wx/image.h>#include <wx/statline.h>#include <wx/spinbutt.h>#include <wx/spinctrl.h>#include <wx/splitter.h>#include <wx/listctrl.h>#include <wx/treectrl.h>#include <wx/notebook.h>// Declare window functions#define ID_NOTEBOOK 10000#define ID_DONE 10001#define ID_CANCEL 10002#define ID_TEXT 10003#define ID_ALWAYS_APPLY 10004#define ID_APPLY 10005wxSizer *LayoutNotebook( wxPanel *parent, bool call_fit = TRUE, bool set_sizer = TRUE );#define ID_PBB_SHOW 10006#define ID_PBB_RENDER 10007#define ID_PBB_COLOR 10008#define ID_PBB_USER 10009#define ID_PSIDE_SHOW 10010#define ID_PSIDE_RENDER 10011#define ID_PSIDE_COLOR 10012#define ID_PSIDE_USER 10013#define ID_NUC_SHOW 10014#define ID_NUC_RENDER 10015#define ID_NUC_COLOR 10016#define ID_NUC_USER 10017#define ID_NSIDE_SHOW 10018#define ID_NSIDE_RENDER 10019#define ID_NSIDE_COLOR 10020#define ID_NSIDE_USER 10021#define ID_HET_SHOW 10022#define ID_HET_RENDER 10023#define ID_HET_COLOR 10024#define ID_HET_USER 10025#define ID_SOLV_SHOW 10026#define ID_SOLV_RENDER 10027#define ID_SOLV_COLOR 10028#define ID_SOLV_USER 10029#define ID_CONN_SHOW 10030#define ID_CONN_RENDER 10031#define ID_CONN_COLOR 10032#define ID_CONN_USER 10033#define ID_HELX_SHOW 10034#define ID_HELX_RENDER 10035#define ID_HELX_COLOR 10036#define ID_HELX_USER 10037#define ID_STRN_SHOW 10038#define ID_STRN_RENDER 10039#define ID_STRN_COLOR 10040#define ID_STRN_USER 10041#define ID_VSS_SHOW 10042#define ID_VSS_USER 10043#define ID_HYD_SHOW 10044#define ID_BG_USER 10045wxSizer *LayoutSettingsPage( wxPanel *parent, bool call_fit = TRUE, bool set_sizer = TRUE );#define ID_TEXTCTRL 10046#define ID_SPINBUTTON 10047wxSizer *LayoutDetailsPage( wxPanel *parent, bool call_fit = TRUE, bool set_sizer = TRUE );#define ID_S_PROT 10048#define ID_S_NUC 10049#define ID_C_PROT_TYPE 10050#define ID_C_NUC_TYPE 10051#define ID_C_PROT_NUM 10052#define ID_C_NUC_NUM 10053#define ID_K_PROT_CONTRAST 10054#define ID_K_NUC_CONTRAST 10055#define ID_K_PROT_TERM 10056#define ID_K_NUC_TERM 10057#define ID_LINE 10058#define ID_K_ION 10059wxSizer *LayoutLabelsPage( wxPanel *parent, bool call_fit = TRUE, bool set_sizer = TRUE );////////////////////////////////////////////////////////////////////////////////////////////////// a bit of a kludge - but necessary to be able to use most of the wxDesigner code as isstatic Cn3D::FloatingPointSpinCtrl *gfpSpaceFill, *gfpBallRadius, *gfpStickRadius, *gfpTubeRadius,    *gfpTubeWormRadius, *gfpHelixRadius, *gfpStrandWidth, *gfpStrandThickness;USING_NCBI_SCOPE;BEGIN_SCOPE(Cn3D)TypeStringAssociator < StyleSettings::eBackboneType > StyleDialog::BackboneTypeStrings;TypeStringAssociator < StyleSettings::eDrawingStyle > StyleDialog::DrawingStyleStrings;TypeStringAssociator < StyleSettings::eColorScheme > StyleDialog::ColorSchemeStrings;TypeStringAssociator < StyleSettings::eLabelType > StyleDialog::LabelTypeStrings;TypeStringAssociator < StyleSettings::eNumberType > StyleDialog::NumberTypeStrings;BEGIN_EVENT_TABLE(StyleDialog, wxDialog)    EVT_CLOSE       (       StyleDialog::OnCloseWindow)    EVT_CHOICE      (-1,    StyleDialog::OnChange)    EVT_CHECKBOX    (-1,    StyleDialog::OnChange)    EVT_SPINCTRL    (-1,    StyleDialog::OnChange)    EVT_BUTTON      (-1,    StyleDialog::OnButton)    // generated when {Integer,FloatingPoint}SpinCtrl changes    EVT_COMMAND     (-1, WX_TOOLS_NOTIFY_CHANGED, StyleDialog::OnChange)END_EVENT_TABLE()StyleDialog::StyleDialog(wxWindow* parent, StyleSettings *settingsToEdit, const StructureSet *set) :    wxDialog(parent, -1, "Style Options", wxPoint(400, 100), wxDefaultSize,        wxCAPTION | wxSYSTEM_MENU), // not resizable    editedSettings(settingsToEdit), originalSettings(*settingsToEdit),    structureSet(set), changedSinceApply(false), changedEver(false){    // setup maps for associating style types with strings    SetupStyleStrings();    // construct the panel    wxPanel *panel = new wxPanel(this, -1);    wxSizer *topSizer = LayoutNotebook(panel, false);    // hook in the stuff that the wxDesigner-based code (LayoutPage2()) created    fpSpaceFill = gfpSpaceFill;    fpBallRadius = gfpBallRadius;    fpStickRadius = gfpStickRadius;    fpTubeRadius = gfpTubeRadius;    fpTubeWormRadius = gfpTubeWormRadius;    fpHelixRadius = gfpHelixRadius;    fpStrandWidth = gfpStrandWidth;    fpStrandThickness = gfpStrandThickness;    // set defaults    SetControls(*editedSettings);    // call sizer stuff    topSizer->Fit(this);    topSizer->Fit(panel);    topSizer->SetSizeHints(this);}StyleDialog::~StyleDialog(void){    delete fpSpaceFill;    delete fpBallRadius;    delete fpStickRadius;    delete fpTubeRadius;    delete fpTubeWormRadius;    delete fpHelixRadius;    delete fpStrandWidth;    delete fpStrandThickness;}void StyleDialog::SetupStyleStrings(void){    if (BackboneTypeStrings.Size() == 0) {        BackboneTypeStrings.Associate(StyleSettings::eOff, "None");        BackboneTypeStrings.Associate(StyleSettings::eTrace, "Trace");        BackboneTypeStrings.Associate(StyleSettings::ePartial, "Partial");        BackboneTypeStrings.Associate(StyleSettings::eComplete, "Complete");        DrawingStyleStrings.Associate(StyleSettings::eWire, "Wire");        DrawingStyleStrings.Associate(StyleSettings::eTubes, "Tubes");        DrawingStyleStrings.Associate(StyleSettings::eBallAndStick, "Ball and Stick");        DrawingStyleStrings.Associate(StyleSettings::eSpaceFill, "Space Fill");        DrawingStyleStrings.Associate(StyleSettings::eWireWorm, "Wire Worm");        DrawingStyleStrings.Associate(StyleSettings::eTubeWorm, "Tube Worm");        DrawingStyleStrings.Associate(StyleSettings::eWithArrows, "With Arrows");        DrawingStyleStrings.Associate(StyleSettings::eWithoutArrows, "Without Arrows");        ColorSchemeStrings.Associate(StyleSettings::eElement, "Element");        ColorSchemeStrings.Associate(StyleSettings::eObject, "Object");        ColorSchemeStrings.Associate(StyleSettings::eMolecule, "Molecule");        ColorSchemeStrings.Associate(StyleSettings::eDomain, "Domain");        ColorSchemeStrings.Associate(StyleSettings::eSecondaryStructure, "Secondary Structure");        ColorSchemeStrings.Associate(StyleSettings::eUserSelect, "User Selection");        ColorSchemeStrings.Associate(StyleSettings::eAligned, "Aligned");        ColorSchemeStrings.Associate(StyleSettings::eIdentity, "Identity");        ColorSchemeStrings.Associate(StyleSettings::eVariety, "Variety");        ColorSchemeStrings.Associate(StyleSettings::eWeightedVariety, "Weighted Variety");        ColorSchemeStrings.Associate(StyleSettings::eInformationContent, "Information Content");        ColorSchemeStrings.Associate(StyleSettings::eFit, "Fit");        ColorSchemeStrings.Associate(StyleSettings::eBlockFit, "Block Fit");        ColorSchemeStrings.Associate(StyleSettings::eBlockZFit, "Normalized Block Fit");        ColorSchemeStrings.Associate(StyleSettings::eBlockRowFit, "Block Row Fit");        ColorSchemeStrings.Associate(StyleSettings::eTemperature, "Temperature");        ColorSchemeStrings.Associate(StyleSettings::eHydrophobicity, "Hydrophobicity");        ColorSchemeStrings.Associate(StyleSettings::eRainbow, "Rainbow");        ColorSchemeStrings.Associate(StyleSettings::eCharge, "Charge");        LabelTypeStrings.Associate(StyleSettings::eOneLetter, "One Letter");        LabelTypeStrings.Associate(StyleSettings::eThreeLetter, "Three Letter");        NumberTypeStrings.Associate(StyleSettings::eNoNumbers, "None");        NumberTypeStrings.Associate(StyleSettings::eSequentialNumbering, "Sequential");        NumberTypeStrings.Associate(StyleSettings::ePDBNumbering, "From PDB");    }}static bool ConvertColor(const wxColour& wxcol, Vector *vec){    vec->Set(((double) wxcol.Red())/255.0, ((double) wxcol.Green())/255.0, ((double) wxcol.Blue())/255.0);    return true;}bool StyleDialog::GetBackboneStyle(StyleSettings::BackboneStyle *bbStyle,    int showID, int renderID, int colorID, int userID){    wxChoice *choice;    wxButton *button;    return (        (choice = wxDynamicCast(FindWindow(showID), wxChoice)) != NULL &&        BackboneTypeStrings.Get(choice->GetStringSelection().c_str(), &(bbStyle->type)) &&        (choice = wxDynamicCast(FindWindow(renderID), wxChoice)) != NULL &&        DrawingStyleStrings.Get(choice->GetStringSelection().c_str(), &(bbStyle->style)) &&        (choice = wxDynamicCast(FindWindow(colorID), wxChoice)) != NULL &&        ColorSchemeStrings.Get(choice->GetStringSelection().c_str(), &(bbStyle->colorScheme)) &&        (button = wxDynamicCast(FindWindow(userID), wxButton)) != NULL &&        ConvertColor(button->GetBackgroundColour(), &(bbStyle->userColor))    );}static bool GetChecked(wxCheckBox *checkbox, bool *isChecked){    if (!checkbox) return false;    *isChecked = checkbox->GetValue();    return true;}bool StyleDialog::GetGeneralStyle(StyleSettings::GeneralStyle *gStyle,    int showID, int renderID, int colorID, int userID){    wxCheckBox *checkbox;    wxChoice *choice;    wxButton *button;    return (        (checkbox = wxDynamicCast(FindWindow(showID), wxCheckBox)) != NULL &&        GetChecked(checkbox, &(gStyle->isOn)) &&        (choice = wxDynamicCast(FindWindow(renderID), wxChoice)) != NULL &&        DrawingStyleStrings.Get(choice->GetStringSelection().c_str(), &(gStyle->style)) &&        (choice = wxDynamicCast(FindWindow(colorID), wxChoice)) != NULL &&        ColorSchemeStrings.Get(choice->GetStringSelection().c_str(), &(gStyle->colorScheme)) &&        (button = wxDynamicCast(FindWindow(userID), wxButton)) != NULL &&        ConvertColor(button->GetBackgroundColour(), &(gStyle->userColor))    );}static bool GetInteger(wxSpinCtrl *spinctrl, int *value){    if (!spinctrl) return false;    *value = spinctrl->GetValue();    return true;}bool StyleDialog::GetLabelStyle(StyleSettings::LabelStyle *lStyle,    int spacingID, int typeID, int numberingID, int terminiID, int whiteID){    wxSpinCtrl *spinctrl;    wxChoice *choice;    wxCheckBox *checkbox;    return (        (spinctrl = wxDynamicCast(FindWindow(spacingID), wxSpinCtrl)) != NULL &&        GetInteger(spinctrl, &(lStyle->spacing)) &&        (choice = wxDynamicCast(FindWindow(typeID), wxChoice)) != NULL &&        LabelTypeStrings.Get(choice->GetStringSelection().c_str(), &(lStyle->type)) &&        (choice = wxDynamicCast(FindWindow(numberingID), wxChoice)) != NULL &&        NumberTypeStrings.Get(choice->GetStringSelection().c_str(), &(lStyle->numbering)) &&        (checkbox = wxDynamicCast(FindWindow(terminiID), wxCheckBox)) != NULL &&        GetChecked(checkbox, &(lStyle->terminiOn)) &&        (checkbox = wxDynamicCast(FindWindow(whiteID), wxCheckBox)) != NULL &&        GetChecked(checkbox, &(lStyle->white))    );}bool StyleDialog::GetValues(StyleSettings *settings){    wxCheckBox *checkbox;    wxButton *button;    bool okay = (        settings != NULL &&        GetBackboneStyle(&(settings->proteinBackbone),            ID_PBB_SHOW, ID_PBB_RENDER, ID_PBB_COLOR, ID_PBB_USER) &&        GetGeneralStyle(&(settings->proteinSidechains),            ID_PSIDE_SHOW, ID_PSIDE_RENDER, ID_PSIDE_COLOR, ID_PSIDE_USER) &&        GetBackboneStyle(&(settings->nucleotideBackbone),            ID_NUC_SHOW, ID_NUC_RENDER, ID_NUC_COLOR, ID_NUC_USER) &&        GetGeneralStyle(&(settings->nucleotideSidechains),            ID_NSIDE_SHOW, ID_NSIDE_RENDER, ID_NSIDE_COLOR, ID_NSIDE_USER) &&        GetGeneralStyle(&(settings->heterogens),            ID_HET_SHOW, ID_HET_RENDER, ID_HET_COLOR, ID_HET_USER) &&        GetGeneralStyle(&(settings->solvents),            ID_SOLV_SHOW, ID_SOLV_RENDER, ID_SOLV_COLOR, ID_SOLV_USER) &&        GetGeneralStyle(&(settings->connections),

⌨️ 快捷键说明

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