taxplot3d_widget.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:10k
- /*
- * ===========================================================================
- * PRODUCTION $Log: taxplot3d_widget.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:13:47 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: taxplot3d_widget.cpp,v 1000.1 2004/06/01 21:13:47 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: Vladimir Tereshkov
- *
- * File Description:
- * Taxplot 3-dimensional widget
- */
- #include <ncbi_pch.hpp>
- #include <gui/opengl/glfont.hpp>
- #include <gui/graph/igraph_utils.hpp>
- #include <gui/widgets/taxplot3d/taxplot3d_widget.hpp>
- #include <gui/types.hpp>
- #include <FL/Fl.H>
- #include "taxplot3d_pane.hpp"
- BEGIN_NCBI_SCOPE
- Fl_Menu_Item pulldown[] = {
- {"&View",0,0,0,FL_SUBMENU},
- {"Perspective", 0, 0, (void*)CMD_PERSP_PROJECTION},
- {"Orthographic (XY)", 0, 0, (void*)CMD_ORTOXY_PROJECTION},
- {"Orthographic (YZ)", 0, 0, (void*)CMD_ORTOYZ_PROJECTION},
- {"Orthographic (XZ)", 0, 0, (void*)CMD_ORTOXZ_PROJECTION},
- {0},
- {"&Objects",0,0,0,FL_SUBMENU},
- {"Show",0,0,0,FL_SUBMENU},
- {"Axes", 0, 0, (void*)CMD_VIEW_AXES, FL_MENU_TOGGLE|FL_MENU_VALUE},
- {"Grid", 0, 0, (void*)CMD_VIEW_GRID, FL_MENU_TOGGLE|FL_MENU_VALUE},
- {"Arrows", 0, 0, (void*)CMD_VIEW_ARROWS, FL_MENU_TOGGLE|FL_MENU_VALUE},
- {"Labels", 0, 0, (void*)CMD_VIEW_LABELS, FL_MENU_TOGGLE|FL_MENU_VALUE},
- {"Scale", 0, 0, (void*)CMD_VIEW_SCALE, FL_MENU_TOGGLE|FL_MENU_VALUE},
- {0},
- {"Shape",0,0,0,FL_SUBMENU},
- {"Sphere", 0,0, (void*)CMD_SHAPE_SPHERE, FL_MENU_RADIO|FL_MENU_VALUE},
- {"Cube", 0,0, (void*)CMD_SHAPE_CUBE, FL_MENU_RADIO},
- {"Cross", 0,0, (void*)CMD_SHAPE_CROSS, FL_MENU_RADIO},
- {0},
- {0},
- {"&Pivot Point", 0,0,0,FL_SUBMENU},
- {"&Position",0,0,0, FL_SUBMENU},
- {"Floating",0,0, (void*)CMD_PIVOT_FLOATING, FL_MENU_RADIO|FL_MENU_VALUE},
- {"Fixed",0,0, (void*)CMD_PIVOT_FIXED, FL_MENU_RADIO},
- {0},
- {"&Attach to selected object",0,0, (void*)CMD_PIVOT_ATTACHED, FL_MENU_TOGGLE|FL_MENU_VALUE},
- {0},
- {"Color scheme", 0,0,0,FL_SUBMENU|FL_MENU_DIVIDER},
- {"Scheme 1", 0, 0, (void*)CMD_COLOR_SCHEME1, FL_MENU_RADIO},
- {"Scheme 2", 0, 0, (void*)CMD_COLOR_SCHEME2, FL_MENU_RADIO},
- {"Scheme 3", 0, 0, (void*)CMD_COLOR_SCHEME3, FL_MENU_RADIO},
- {0},
- {"&Refresh",0,0,(void*)CMD_REFRESH_VIEW},
- {0}
- };
- void cb_Popup(Fl_Widget * widget, void * data)
- {
- Fl_Menu_* mw = (Fl_Menu_*)widget;
- const Fl_Menu_Item* m = mw->mvalue();
- switch (m->argument()){
- case CMD_REFRESH_VIEW:
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_PERSP_PROJECTION:
- ((CTaxplot3dWidget*)data)->SetViewMode(CTaxplot3dPanel::eCamera);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_ORTOXY_PROJECTION:
- ((CTaxplot3dWidget*)data)->SetViewMode(CTaxplot3dPanel::eViewZ);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_ORTOYZ_PROJECTION:
- ((CTaxplot3dWidget*)data)->SetViewMode(CTaxplot3dPanel::eViewX);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_ORTOXZ_PROJECTION:
- ((CTaxplot3dWidget*)data)->SetViewMode(CTaxplot3dPanel::eViewY);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_VIEW_AXES:
- ((CTaxplot3dWidget*)data)->getPanel()->setVisible(CTaxplot3dPanel::eAxes, !((CTaxplot3dWidget*)data)->getPanel()->getVisible(CTaxplot3dPanel::eAxes));
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_VIEW_GRID:
- ((CTaxplot3dWidget*)data)->getPanel()->setVisible(CTaxplot3dPanel::eGrid, !((CTaxplot3dWidget*)data)->getPanel()->getVisible(CTaxplot3dPanel::eGrid));
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_VIEW_ARROWS:
- ((CTaxplot3dWidget*)data)->getPanel()->setVisible(CTaxplot3dPanel::eArrows, !((CTaxplot3dWidget*)data)->getPanel()->getVisible(CTaxplot3dPanel::eArrows));
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_VIEW_LABELS:
- ((CTaxplot3dWidget*)data)->getPanel()->setVisible(CTaxplot3dPanel::eLabels, !((CTaxplot3dWidget*)data)->getPanel()->getVisible(CTaxplot3dPanel::eLabels));
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_VIEW_SCALE:
- ((CTaxplot3dWidget*)data)->getPanel()->setVisible(CTaxplot3dPanel::eScale, !((CTaxplot3dWidget*)data)->getPanel()->getVisible(CTaxplot3dPanel::eScale));
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- break;
- case CMD_SHAPE_SPHERE:
- ((CTaxplot3dWidget*)data)->getPanel()->setPrimitiveShape(CTaxplot3dPanel::eSphere);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_SHAPE_CUBE:
- ((CTaxplot3dWidget*)data)->getPanel()->setPrimitiveShape(CTaxplot3dPanel::eCube);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_SHAPE_CROSS:
- ((CTaxplot3dWidget*)data)->getPanel()->setPrimitiveShape(CTaxplot3dPanel::eCross);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_PIVOT_FLOATING:
- ((CTaxplot3dWidget*)data)->getPanel()->setPivotPoint(CTaxplot3dPanel::eFloating);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_PIVOT_FIXED:
- ((CTaxplot3dWidget*)data)->getPanel()->setPivotPoint(CTaxplot3dPanel::eFixed);
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- break;
- case CMD_PIVOT_ATTACHED:
- ((CTaxplot3dWidget*)data)->getPanel()->setPivotAttach(!((CTaxplot3dWidget*)data)->getPanel()->getPivotAttach());
- ((CTaxplot3dWidget*)data)->SlowRedraw();
- break;
- case CMD_COLOR_SCHEME1:
- case CMD_COLOR_SCHEME2:
- case CMD_COLOR_SCHEME3:
- break;
- }
- }
- CTaxplot3dWidget::CTaxplot3dWidget(int x, int y, int w, int h,
- const char* label)
- : Fl_Group(x, y, w, h, label)
- {
- m_3DPanel = new CTaxplot3dPanel(x, y, w, h, label);
- m_3DPanel->box(FL_DOWN_BOX);
- m_3DPanel->labeltype(FL_NORMAL_LABEL);
- m_3DPanel->align(FL_ALIGN_CLIP);
- Fl_Group::current()->resizable(m_3DPanel);
- end();
- m_Event.StandardConfig();
-
- }
- CTaxplot3dWidget::~CTaxplot3dWidget()
- {
- if (m_3DPanel) delete m_3DPanel;
- }
- void CTaxplot3dWidget::SetDataSource(CTaxplot3dDataSource * ds)
- {
- m_3DPanel->SetDataSource(ds);
- }
- void CTaxplot3dWidget::SetViewMode(int mode)
- {
- m_3DPanel->setViewMode(static_cast<CTaxplot3dPanel::EViewMode>(mode));
- }
- void CTaxplot3dWidget::SlowRedraw(void)
- {
- m_3DPanel->slowRedraw();
- }
- int CTaxplot3dWidget::handle(int event)
- {
- m_Event.OnFLTKEvent(event);
- switch(event) {
- case FL_RELEASE: {
- if(m_Event.GetGUISignal() == CGUIEvent::ePopupSignal) {
- fl_cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE);
-
- Fl_Menu_Button popup(x(), y(), w(), h(), NULL);
- popup.type(Fl_Menu_Button::POPUP3);
- popup.box(FL_NO_BOX);
- popup.menu(pulldown);
- popup.callback(cb_Popup, (void*)this);
- popup.popup();
- /*
- CMenuItem* root = new CMenuItem("root");
- root->AddSubItem("1", 2);
- root->AddSubItem("2", 2);
- root->AddSubItem("3", 2);
- CPopupMenu Popup(x(), y(), w(), h());
-
- Fl_Group::add(&Popup);
-
- //Popup.SetCmdTarget(this);
- Popup.SetItems(root);
- Popup.popup();
-
- Fl_Group::remove(Popup);
- */
-
- }
- }
- }
- Fl_Group::handle(event);
- return 1; // event handled
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: taxplot3d_widget.cpp,v $
- * Revision 1000.1 2004/06/01 21:13:47 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- *
- * Revision 1.7 2004/05/21 22:27:55 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.6 2004/03/11 17:54:04 dicuccio
- * Deprecated typedefs TDimension, TPosition
- *
- * Revision 1.5 2004/01/28 17:39:42 tereshko
- * Fixed popup menu
- *
- * Revision 1.4 2004/01/28 16:13:47 tereshko
- * Eliminated padding to work correctly with CSplitter
- *
- * Revision 1.3 2004/01/15 13:04:44 ucko
- * Tweak to work on 64-bit systems.
- *
- * Revision 1.2 2004/01/14 16:39:23 tereshko
- * Minor changes due to integration with Taxplot viewer
- *
- * Revision 1.1 2004/01/05 16:20:50 tereshko
- * Initial revision
- *
- * ===========================================================================
- */