reference_editor.cpp
来自「ncbi源码」· C++ 代码 · 共 737 行 · 第 1/2 页
CPP
737 行
/* * =========================================================================== * PRODUCTION $Log: reference_editor.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 21:02:25 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * PRODUCTION * =========================================================================== *//* * =========================================================================== * * 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: Lou Friedman * * File Description: * Implementaion of CReferenceEntryForm reference editing * */#include <ncbi_pch.hpp>#include "reference_editor.hpp"#include "auth_form.hpp"#include <gui/dialogs/entry_form/table.hpp>#include <corelib/ncbistre.hpp>#include <serial/iterator.hpp>#include <objects/general/Object_id.hpp>#include <objects/general/Date.hpp>#include <objects/general/Date_std.hpp>#include <objects/general/Person_id.hpp>#include <objects/general/Name_std.hpp>#include <objects/seq/Pubdesc.hpp>#include <objects/seq/Seq_inst.hpp>#include <objects/pub/Pub.hpp>#include <objects/pub/Pub_equiv.hpp>#include <objects/biblio/Cit_art.hpp>#include <objects/biblio/Cit_book.hpp>#include <objects/biblio/Cit_gen.hpp>#include <objects/biblio/Cit_jour.hpp>#include <objects/biblio/Cit_let.hpp>#include <objects/biblio/Cit_pat.hpp>#include <objects/biblio/Cit_proc.hpp>#include <objects/biblio/Cit_sub.hpp>#include <objects/biblio/Imprint.hpp>#include <objects/biblio/PubMedId.hpp>#include <objects/biblio/Auth_list.hpp>#include <objects/biblio/Author.hpp>#include <objects/biblio/Title.hpp>#include "paragraph.hpp"BEGIN_NCBI_SCOPEUSING_SCOPE(objects);SEditorFlatPub::SEditorFlatPub (CPubdesc* pub) : m_Pubdesc(0), m_Pub(0), m_CitType(CPub::e_not_set), m_PubClass(ePubClass_not_set), m_Medline_entry(0), m_PubMedId(0), m_Pub_equiv(0), m_Auth_list(0), m_Imprint(0), m_Title(0), m_Meeting(0), m_Date(0), m_FromAuth_list(0), m_FromImprint(0), m_FromTitle(0), m_Muid(0), m_Pmid(0){ m_Pubdesc = pub; m_Pub = NULL; NON_CONST_ITERATE (CPub_equiv::Tdata, it, pub->SetPub().Set()) { x_Init (**it); }}void SEditorFlatPub::x_Init (CPub& pub) { m_CitType = pub.Which(); switch (m_CitType) { case CPub::e_Gen: {{ m_Pub = &pub; CCit_gen& cit = pub.SetGen(); if (cit.IsSetCit()) { if (NStr::CompareNocase(cit.GetCit(), "unpublished") == 0) { m_PubClass = eUnpub; } else if (NStr::CompareNocase(cit.GetCit(), "Online Publication") == 0 || NStr::CompareNocase(cit.GetCit(), "Published Only in DataBase") == 0) { m_PubClass = eOnline; } else { // Assumed to be a journal publication m_PubClass = eJournal; } } if (cit.IsSetAuthors()) m_Auth_list = &cit.SetAuthors(); if (cit.IsSetDate()) m_Date = &cit.SetDate(); break; }} case CPub::e_Sub: {{ CCit_sub& cit = pub.SetSub(); m_Auth_list = &cit.SetAuthors(); if (cit.IsSetImp()) { m_Date = &cit.SetImp().SetDate(); } else { if (cit.IsSetDate()) m_Date = &cit.SetDate(); } m_Pub = &pub; m_PubClass = eUnpub; break; }} case CPub::e_Medline: break; case CPub::e_Muid: m_Muid = pub.GetMuid(); break; case CPub::e_Article: {{ CCit_art& cit = pub.SetArticle(); if (cit.IsSetAuthors()) m_Auth_list = &cit.SetAuthors(); if (cit.IsSetTitle()) m_Title = &cit.SetTitle(); m_Pub = &pub; CCit_art::C_From& from = cit.SetFrom(); if (from.IsJournal()) { CCit_jour& from_cit = from.SetJournal(); m_PubClass = eJournal; m_Imprint = &from_cit.SetImp(); m_FromTitle = &from_cit.SetTitle(); } else if (from.IsBook()) { CCit_book& from_cit = from.SetBook(); m_PubClass = eBookChapter; m_Imprint = &from_cit.SetImp(); m_FromTitle = &from_cit.SetTitle(); m_FromAuth_list = &from_cit.SetAuthors(); } else if (from.IsProc()) { CCit_proc& from_cit = from.SetProc(); m_PubClass = eProcChapter; m_Meeting = &from_cit.SetMeet(); CCit_book& citbook = from_cit.SetBook(); m_Imprint = &citbook.SetImp(); m_FromTitle = &citbook.SetTitle(); m_FromAuth_list = &citbook.SetAuthors(); } else { } break; }} case CPub::e_Journal: {{ CCit_jour& cit = pub.SetJournal(); m_Imprint = &cit.SetImp(); m_Title = &cit.SetTitle(); m_Pub = &pub; m_PubClass = eJournal; }} case CPub::e_Book: {{ CCit_book& cit = pub.SetBook(); m_Imprint = &cit.SetImp(); m_Title = &cit.SetTitle(); m_Auth_list = &cit.SetAuthors(); m_Pub = &pub; m_PubClass = eBook; break; }} case CPub::e_Proc: {{ CCit_proc& cit = pub.SetProc(); m_Meeting = &cit.SetMeet(); CCit_book& citbook = cit.SetBook(); m_Imprint = &citbook.SetImp(); m_Title = &citbook.SetTitle(); m_Auth_list = &citbook.SetAuthors(); m_Pub = &pub; m_PubClass = eProc; break; }} case CPub::e_Patent: break; case CPub::e_Man: break; case CPub::e_Equiv:#if 0 ITERATE (CPub_equiv::Tdata, it, pub.GetEquiv().Get()) { x_Init(**it, ctx); }#endif break; case CPub::e_Pmid: {{ m_Pmid = pub.GetPmid().Get(); break; }} default: break; } // switch if (m_Date == 0 && m_Imprint) { m_Date = & m_Imprint->SetDate(); }}SEditorFlatPub::EPubStatus SEditorFlatPub::GetPubStatus (){ if (m_CitType == CPub::e_Sub) { return SEditorFlatPub::eUnpublished; } if (m_CitType == CPub::e_Gen) { const CCit_gen& g = m_Pub->GetGen(); if (g.IsSetCit() && NStr::CompareNocase(g.GetCit(), "unpublished") == 0) { return SEditorFlatPub::eUnpublished; } else { return SEditorFlatPub::ePublished; } } if (m_Imprint && m_Imprint->IsSetPrepub()) { if (m_Imprint->GetPrepub() == CImprint::ePrepub_submitted) { return SEditorFlatPub::eUnpublished; } else if (m_Imprint->GetPrepub() == CImprint::ePrepub_in_press) { return SEditorFlatPub::eIn_press; } } return SEditorFlatPub::ePublished;}// Menu DeclarationsSMenuEntryInfo RefStatusEntries [] = { { "Unpublished", SEditorFlatPub::eUnpublished, &CReferenceEntryForm::DeactivateRefClassMenu }, { "In Press", SEditorFlatPub::eIn_press, &CReferenceEntryForm::ActivateRefClassMenu }, { "Published", SEditorFlatPub::ePublished, &CReferenceEntryForm::ActivateRefClassMenu }, { 0, 0 }};CEntryFormMenu SRefStatusMenu(RefStatusEntries);// user data is set to 1. This indicates a redraw should// be called in the cb_UnpubUI and cb_PubUI call backs.SMenuEntryInfo RefClassEntries [] = { { " ", SEditorFlatPub::eUnpub, &CReferenceEntryForm::cb_UnpubUI, (void*)1 }, { "Journal", SEditorFlatPub::eJournal, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { "Book Chapter", SEditorFlatPub::eBookChapter, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { "Book", SEditorFlatPub::eBook, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { "Thesis / Monograph", SEditorFlatPub::eThesis, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { "Proceedings Chapter", SEditorFlatPub::eProcChapter, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { "Proceedings", SEditorFlatPub::eProc, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { "Patent", SEditorFlatPub::ePatent, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { "Online Publication", SEditorFlatPub::eOnline, &CReferenceEntryForm::cb_PubUI, (void*)1 }, { 0, 0 }};CEntryFormMenu SRefClassMenu(RefClassEntries);SMenuEntryInfo RefScopeEntries [] = { { "Refers to the entire sequence", 0 }, { "Refers to part of the sequence", 0 }, { "Cites a feature on the sequence", 0 }, { 0, 0 }};CEntryFormMenu SRefScopeMenu(RefScopeEntries);CReferenceEntryForm::CReferenceEntryForm(CParagraph* p) : CGenbankEntryForm(p), m_FlatPub (const_cast<CPubdesc*> ((CPubdesc*) p->topic())) { CPubdesc* pubdesc = const_cast<CPubdesc*> (dynamic_cast<const CPubdesc*> (p->topic())); SEditorFlatPub flat_pub (pubdesc); SetTitle("Reference"); auto_ptr<CEntryFormTable> t (new CEntryFormTable(GetFormWidget()->GetFormWidth(), 5)); t->AddTitleRow ("Publication Type"); m_Status = t->AddMenuRow("Status", SRefStatusMenu, SRefStatusMenu.FindEntry (m_FlatPub.GetPubStatus()), this); m_Class = t->AddMenuRow("Class", SRefClassMenu, SRefClassMenu.FindEntry (m_FlatPub.m_PubClass), this); m_Scope = t->AddMenuRow("Scope", SRefScopeMenu, 0); t->End(); AddEditWidget(t.release()); if (m_Status->value() == 0) { DeactivateRefClassMenu(m_Status, 0); } int ref_class = m_Class->value(); if (m_Class->menu()[ref_class].callback()) { // user data is 0 to so that a Show will // not be issued (look in cb_PubUI and cb_UnpubUI) m_Class->menu()[ref_class].do_callback(m_Class, (void *)0); }}CReferenceEntryForm::~CReferenceEntryForm(){}void CReferenceEntryForm::DeactivateRefClassMenu(Fl_Widget* w, void *u){ CReferenceEntryForm* ref = (CReferenceEntryForm*) w->user_data(); Fl_Choice* ref_class = ref->m_Class; for (int i = 1; ref_class->text(i); i++) { ref_class->mode(i, FL_MENU_INACTIVE); } // Set the Ref Class to blank ref_class->value(0); // Issue the callback for a Ref Class change if (ref_class->menu()[0].callback()) { // user data is 1 to so that a Show will // be issued (look in cb_PubUI and cb_UnpubUI)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?