test_arg_dialog.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:9k
- /*
- * ===========================================================================
- * PRODUCTION $Log: test_arg_dialog.cpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 20:45:01 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.16
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: test_arg_dialog.cpp,v 1000.2 2004/06/01 20:45:01 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:
- * Test application for plugins
- */
- #include <ncbi_pch.hpp>
- #include <corelib/ncbiapp.hpp>
- #include <corelib/ncbiargs.hpp>
- #include <corelib/ncbienv.hpp>
- #include <corelib/ncbireg.hpp>
- #include <gui/core/idocument.hpp>
- #include <gui/core/plugin_arg_dialog.hpp>
- #include <gui/core/plugin_exception.hpp>
- #include <gui/core/selection_buffer.hpp>
- #include <gui/plugin/PluginArgSet.hpp>
- #include <objects/seq/Bioseq.hpp>
- #include <serial/objostr.hpp>
- #include <serial/serial.hpp>
- USING_NCBI_SCOPE;
- USING_SCOPE(objects);
- //
- // a test exception class
- //
- class CPluginTestException : EXCEPTION_VIRTUAL_BASE public CException
- {
- public:
- // Enumerated list of document management errors
- enum EErrCode {
- eTestFailed
- };
- // Translate the specific error code into a string representations of
- // that error code.
- virtual const char* GetErrCodeString(void) const
- {
- switch (GetErrCode()) {
- case eTestFailed: return "eTestFailed";
- default: return CException::GetErrCodeString();
- }
- }
- NCBI_EXCEPTION_DEFAULT(CPluginTestException, CException);
- };
- class CPluginTestApp : public CNcbiApplication
- {
- public:
- CPluginTestApp();
- private:
- int m_Plugins;
- virtual void Init(void);
- virtual int Run(void);
- virtual void Exit(void);
- };
- CPluginTestApp::CPluginTestApp()
- : m_Plugins(0)
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // Init test for all different types of arguments
- void CPluginTestApp::Init(void)
- {
- // Create command-line argument descriptions class
- auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
- // Specify USAGE context
- arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
- "Plug-in test application");
- // Setup arg.descriptions for this application
- SetupArgDescriptions(arg_desc.release());
- }
- int CPluginTestApp::Run(void)
- {
- //
- // create a dummy set of arguments for which a dialog box will be created
- //
- CPluginArgSet args;
- args.AddArgument("bioseq", "Bioseq to blast", CBioseq::GetTypeInfo());
- CPluginArg& arg =
- args.AddArgument("req-type", "Request type", CPluginArg::eString);
- arg.SetLong_desc("This is the tooltipnspreading gleefully over "
- "many linesnDoes it work?");
- args.SetConstraint("req-type",
- ((*CPluginValueConstraint::CreateSet()),
- "finish-params", "get-databases", "get-matrices",
- "get-search-results", "get-sequences",
- "queue-search"));
- args.AddDefaultArgument("subject", "Database for search",
- CPluginArg::eString, "nr");
- args.SetConstraint("subject",
- ((*CPluginValueConstraint::CreateSet()),
- "nr", "est", "est_human", "est_mouse", "est_others",
- "gss", "htgs", "pat", "pdb", "month", "alu_repeats",
- "dbsts", "chromosome", "wgs"));
- args.AddArgument("service", "BLAST service", CPluginArg::eString);
- args.SetConstraint("service",
- ((*CPluginValueConstraint::CreateSet()),
- "plain", "psiblast", "phiblast", "rpsblast",
- "megablast", "vecscreen"));
- args.AddArgument("program", "BLAST program", CPluginArg::eString);
- args.SetConstraint("program",
- ((*CPluginValueConstraint::CreateSet()),
- "blastn", "blastp", "blastx", "tblastn",
- "tblastx"));
- args.AddArgument("file1", "Input file", CPluginArg::eString);
- args.AddArgument("threshold", "Threshold", CPluginArg::eDouble);
- args.AddDefaultArgument("def1", "Default Factor",
- CPluginArg::eInteger, "10000");
- args.AddOptionalArgument("opt1", "Twiddle Factor",
- CPluginArg::eDouble);
- args.AddOptionalArgument("opt2", "Fudge Factor",
- CPluginArg::eInteger);
- args.AddDefaultArgument("Optflag", "Option Flag",
- CPluginArg::eBoolean, "false");
- args.AddDefaultArgument("Defflag", "Default Flag",
- CPluginArg::eBoolean, "true");
- args.AddArgument("Inflag", "Input Flag", CPluginArg::eBoolean);
- args.AddDefaultArgument("Outflag", "Output Flag",
- CPluginArg::eBoolean, "false");
- args.AddDefaultArgument("Upflag", "Up Flag",
- CPluginArg::eBoolean, "true");
- args.AddDefaultArgument("Downflag", "Down Flag",
- CPluginArg::eBoolean, "false");
- CPluginHandle h;
- TConstScopedObjects selection;
- CPluginArgDialog dlg(h, args, selection);
- dlg.Size(500, 300);
- if (dlg.ShowModal() != eCancel) {
- cerr << "ok chosen, will process..." << endl;
- CObjectOStream* os = CObjectOStream::Open(eSerial_AsnText, cout);
- *os << args;
- } else {
- cerr << "cancel chosen, no processing done." << endl;
- }
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Cleanup
- void CPluginTestApp::Exit(void)
- {
- SetDiagStream(0);
- }
- /////////////////////////////////////////////////////////////////////////////
- // MAIN
- int main(int argc, const char* argv[])
- {
- // Execute main application function
- return CPluginTestApp().AppMain(argc, argv, 0, eDS_Default, 0);
- }
- /*
- * ===========================================================================
- * $Log: test_arg_dialog.cpp,v $
- * Revision 1000.2 2004/06/01 20:45:01 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.16
- *
- * Revision 1.16 2004/05/21 22:27:41 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.15 2004/04/07 12:49:34 dicuccio
- * Use TConstScopedObjects instead of CSelectionBuffer::TSelItems
- *
- * Revision 1.14 2003/10/24 02:13:15 ucko
- * Fix for new CPluginArgDialog interface
- *
- * Revision 1.13 2003/10/07 17:26:15 dicuccio
- * FIxed for URL -> Value conversion
- *
- * Revision 1.12 2003/09/29 15:42:05 dicuccio
- * Deprecated gui/scope.hpp. Merged gui/core/types.hpp into gui/types.hpp
- *
- * Revision 1.11 2003/09/04 14:01:52 dicuccio
- * Introduce IDocument and IView as abstract base classes for CDocument and
- * CView
- *
- * Revision 1.10 2003/07/17 11:59:50 friedman
- * Include CSelectionBuffer::TSelList for SertArgs. Test Boolesn/Flag dialog
- * widgets.
- *
- * Revision 1.9 2003/07/16 15:22:36 dicuccio
- * Implemented tool tips for arguments
- *
- * Revision 1.8 2003/06/20 14:47:41 dicuccio
- * Revised handling of plugin registration (moved GetInfo() out of plugin
- * factory and into each handler as a static function)
- *
- * Revision 1.7 2003/05/19 13:36:00 dicuccio
- * Moved gui/core/plugin/ -> gui/plugin/. Merged gui/core/algo, gui/core/doc/,
- * and gui/core/view/ into one library (gui/core/)
- *
- * Revision 1.6 2003/05/09 16:49:01 dicuccio
- * Added explicit check so that default set-constraint arguments will have their
- * values shown
- *
- * Revision 1.5 2003/04/25 14:15:24 dicuccio
- * Fix compilation errors resulting from changes to plugin API
- *
- * Revision 1.4 2003/04/21 15:13:15 dicuccio
- * Added real-life test arguments
- *
- * Revision 1.3 2003/04/16 11:39:50 dicuccio
- * Added torture-test menu with many entries
- *
- * Revision 1.2 2003/03/28 19:20:19 dicuccio
- * Added default argument for testing
- *
- * Revision 1.1 2003/03/20 19:57:28 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */