filter_dlg.cpp
来自「ncbi源码」· C++ 代码 · 共 341 行
CPP
341 行
/* * =========================================================================== * PRODUCTION $Log: filter_dlg.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 21:00:39 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * PRODUCTION * =========================================================================== *//* $Id: filter_dlg.cpp,v 1000.2 2004/06/01 21:00:39 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: Mike DiCuccio * * File Description: * */#include <ncbi_pch.hpp>#include "filter_dlg.hpp"#include "feat_table.hpp"BEGIN_NCBI_SCOPE#include "filter_dlg_.cpp"CFilterDlg::CFilterDlg() : m_Filters(NULL){ m_Window.reset(x_CreateWindow()); // fill in our column types m_Column->add("(column)", 0, NULL, reinterpret_cast<void*> (CFeatTable::eNone)); m_Column->add("Title", 0, NULL, reinterpret_cast<void*>(CFeatTable::eTitle)); m_Column->add("Type", 0, NULL, reinterpret_cast<void*>(CFeatTable::eType)); m_Column->add("From", 0, NULL, reinterpret_cast<void*>(CFeatTable::eFrom)); m_Column->add("To", 0, NULL, reinterpret_cast<void*>(CFeatTable::eTo)); /** m_Column->add("Intervals", 0, NULL, reinterpret_cast<void*>(CFeatTable::eIntervals)); **/ m_Column->add("Strand", 0, NULL, reinterpret_cast<void*>(CFeatTable::eStrand)); m_Column->value(0); // fill in the modes of operation m_Mode->add("(mode)", 0, NULL, reinterpret_cast<void*>(CFilter::ePass)); m_Mode->add("contains", 0, NULL, reinterpret_cast<void*>(CFilter::eContains)); m_Mode->add("doesn't contain", 0, NULL, reinterpret_cast<void*>(CFilter::eDoesntContain)); m_Mode->add("equals", 0, NULL, reinterpret_cast<void*>(CFilter::eEquals)); m_Mode->add("doesn't equal", 0, NULL, reinterpret_cast<void*>(CFilter::eDoesntEqual)); m_Mode->add("is less than", 0, NULL, reinterpret_cast<void*>(CFilter::eLess)); m_Mode->add("is greater than", 0, NULL, reinterpret_cast<void*>(CFilter::eGreater)); m_Mode->add("is less than or equal to", 0, NULL, reinterpret_cast<void*>(CFilter::eLessEquals)); m_Mode->add("is greater than or equal to", 0, NULL, reinterpret_cast<void*>(CFilter::eGreaterEquals)); m_Mode->value(0);}EDialogReturnValue CFilterDlg::Show(){ if ( !m_Window.get() ) { return eCancel; } m_RetVal = eCancel; m_Window->show(); while (m_Window->shown()) { Fl::wait(); } return m_RetVal;}void CFilterDlg::SetFilters(CFilterSet* filters){ m_Filters = filters;}void CFilterDlg::x_OnOK(){ m_Window->hide(); m_RetVal = eOK;}void CFilterDlg::x_OnDeleteCurrent(){ // if no selections, bail int pos = m_FilterList->value(); CFilter* filter = reinterpret_cast<CFilter*> (m_FilterList->data(pos)); if (pos == 0 || !filter ) { return; } m_Filters->Remove(filter); m_FilterList->remove(pos); x_UpdateSelected();}void CFilterDlg::x_OnEnableCurrent(){}void CFilterDlg::x_OnAdd(){ if ( !m_Filters ) { return; } // create a new dummy filter static int counter; string name = "New Filter #" + NStr::IntToString(++counter); CRef<CFilter> filter(new CFilter(name, -1, CFilter::ePass, "")); m_Filters->Add(filter.Release()); x_Update();}void CFilterDlg::x_Update(){ x_UpdateList(); x_UpdateSelected();}void CFilterDlg::x_UpdateList(){ // reset the browser list m_FilterList->clear(); if (m_Filters) { ITERATE (CFilterSet::TFilters, iter, m_Filters->GetFilters()) { const CFilter* filter = iter->GetPointer(); void* data = reinterpret_cast<void*> (const_cast<CFilter*>(filter)); m_FilterList->add((*iter)->GetName().c_str(), data); } } m_FilterList->redraw();}void CFilterDlg::x_UpdateSelected(){ int pos = m_FilterList->value(); // reset all items to a known position m_FilterName->value(""); m_FilterData->value(""); m_Column->value(0); m_Mode->value(0); // if no selections, continue const CFilter* filter = reinterpret_cast<CFilter*> (m_FilterList->data(pos)); if (pos == 0 || !filter ) { //m_Window->redraw(); return; } // fill the text components m_FilterName->value(filter->GetName().c_str()); m_FilterData->value(filter->GetData().c_str()); // select the correct column { const Fl_Menu_Item* items = m_Column->menu(); for (int i = 0; i < m_Column->size(); ++i) { if (reinterpret_cast<size_t> (items[i].user_data()) == filter->GetColumn()) { m_Column->value(i); break; } } } // select the correct filter mode { const Fl_Menu_Item* items = m_Mode->menu(); for (int i = 0; i < m_Mode->size(); ++i) { int mode = reinterpret_cast<size_t>(items[i].user_data()); if (mode == filter->GetMode()) { m_Mode->value(i); break; } } }}void CFilterDlg::x_OnChangeColumn(){ // if no selections, bail int pos = m_FilterList->value(); CFilter* filter = reinterpret_cast<CFilter*> (m_FilterList->data(pos)); if (pos == 0 || !filter ) { return; } int col = reinterpret_cast<size_t>(m_Column->mvalue()->user_data()); filter->SetColumn(col);}void CFilterDlg::x_OnChangeMode(){ // if no selections, bail int pos = m_FilterList->value(); CFilter* filter = reinterpret_cast<CFilter*> (m_FilterList->data(pos)); if (pos == 0 || !filter ) { return; } CFilter::EMode mode = static_cast<CFilter::EMode> (reinterpret_cast<size_t>(m_Mode->mvalue()->user_data())); filter->SetMode(mode);}void CFilterDlg::x_OnChangeData(){ // if no selections, bail int pos = m_FilterList->value(); CFilter* filter = reinterpret_cast<CFilter*> (m_FilterList->data(pos)); if (pos == 0 || !filter ) { return; } filter->SetData(m_FilterData->value());}void CFilterDlg::x_OnChangeName(){ // if no selections, bail int pos = m_FilterList->value(); CFilter* filter = reinterpret_cast<CFilter*> (m_FilterList->data(pos)); if (pos == 0 || !filter ) { return; } filter->SetName(m_FilterName->value()); if (filter->GetName().empty()) { m_FilterList->text(pos, "(no name)"); } else { m_FilterList->text(pos, m_FilterName->value()); }}END_NCBI_SCOPE/* * =========================================================================== * $Log: filter_dlg.cpp,v $ * Revision 1000.2 2004/06/01 21:00:39 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * * Revision 1.9 2004/05/21 22:27:49 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.8 2004/01/06 20:16:20 dicuccio * Dropped intervals list (temporarily) - it crowds the view * * Revision 1.7 2003/04/29 14:56:16 dicuccio * Reworked FLUID-generated code: better memory management, more explicit control * over the constructor * * Revision 1.6 2003/03/11 15:23:30 kuznets * iterate -> ITERATE * * Revision 1.5 2003/01/13 13:10:09 dicuccio * Namespace clean-up. Retired namespace gui -> converted all to namespace ncbi. * Moved all FLUID-generated code into namespace ncbi. * * Revision 1.4 2003/01/10 20:57:08 ucko * Adjusted casts to fix compilation under at least WorkShop in 64-bit mode. * (int isn't always as wide as void*, but size_t should be.) * * Revision 1.3 2003/01/09 13:51:24 dicuccio * Convert all explicit casts -> reinterpret_cast<> / const_cast<> * * Revision 1.2 2003/01/08 14:58:47 dicuccio * Major overhaul. Added column selection dialog to base class - moved out of * this class. Added ability to sort columns based on menu selections. Added * ability to filter features based on a wide range of criteria. * * Revision 1.1 2002/12/30 18:49:41 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?