~ubuntu-branches/ubuntu/utopic/ginkgocadx/utopic-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/gui/configuration/hangingprotocolconfigurationpanel.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2014-01-09 07:37:09 UTC
  • mfrom: (1.2.3)
  • Revision ID: package-import@ubuntu.com-20140109073709-rpuh5x3p3finvtze
Tags: 3.6.0.1228.33+dfsg-1
New upstream release [December 2013]

Show diffs side-by-side

added added

removed removed

Lines of Context:
598
598
                                        GNC::GCS::ModoControlador::T_HangingProtocolSupportLevel hangingSupportLevel;
599
599
                                };//end StudyWindow
600
600
 
601
 
                        class ModalityPanel: public ModalityPanelBase
602
 
                        {
603
 
                        public:
604
 
                                class AddWindowLevelDialog: public AddWLDialogBase
605
 
                                {
606
 
                                public:
607
 
                                        AddWindowLevelDialog(ModalityPanel* pParent): AddWLDialogBase(pParent),
608
 
                                                Parent(pParent), 
609
 
                                                EditMode(false)
610
 
                                        {
611
 
                                        }
612
 
 
613
 
                                        AddWindowLevelDialog(ModalityPanel* pParent, const wxString& label, const wxString& window, const wxString& level): 
614
 
                                                AddWLDialogBase(pParent),
615
 
                                                Parent(pParent),
616
 
                                                EditMode(true)
617
 
                                        {
618
 
                                                m_pLabel->SetValue(label);
619
 
                                                m_pWindow->SetValue(window);
620
 
                                                m_pLevel->SetValue(level);
621
 
                                        }
622
 
 
623
 
                                        virtual bool Validate()
624
 
                                        {
625
 
                                                if (m_pLabel->GetValue().empty() || m_pWindow->GetValue().empty() || m_pLevel->GetValue().empty()) {
626
 
                                                        wxMessageBox(_("You must fill in all fields"),_("Info"),wxOK | wxICON_INFORMATION, this);
627
 
                                                        return false;
628
 
                                                } else {
629
 
                                                        double window, level;
630
 
                                                        if (m_pWindow->GetValue().ToDouble(&window) && m_pLevel->GetValue().ToDouble(&level)) {
631
 
                                                                if (!EditMode && Parent->m_pDefaultWindowLevel->FindString(m_pLabel->GetValue()) > 0) {
632
 
                                                                        wxMessageBox(_("Window/level label in use"),_("Info"),wxOK | wxICON_INFORMATION, this);
633
 
                                                                        return false;
634
 
                                                                }
635
 
                                                                return true;
636
 
                                                        } else {
637
 
                                                                wxMessageBox(_("Fill in valid numbers in window and level fields."),_("Info"),wxOK | wxICON_INFORMATION, this);
638
 
                                                                return false;
639
 
                                                        }
640
 
                                                }
641
 
                                        }
642
 
 
643
 
                                        ModalityPanel* Parent;
644
 
                                        bool EditMode;
645
 
                                };
646
 
 
647
 
 
648
 
                                ModalityPanel(wxWindow* pParent, const GNC::GCS::Ptr<GNC::GCS::DefaultModalitySettings>& lo): ModalityPanelBase(pParent),
649
 
                                                modSettings(lo)
650
 
                                {
651
 
                                }
652
 
 
653
 
                                void InitPanels()
654
 
                                {
655
 
                                        
656
 
                                        wxTreeItemId idRoot = m_pWLList->AddRoot(wxT("Root"));
657
 
                                        for (GNC::GCS::DefaultModalitySettings::TListOfWLSettings::const_iterator it = modSettings->getWLSettings().begin(); it != modSettings->getWLSettings().end(); ++it)
658
 
                                        {
659
 
                                                wxTreeItemId idItem = m_pWLList->AppendItem(m_pWLList->GetRootItem(),wxString::FromUTF8((*it)->getLabel().c_str()));
660
 
                                                m_pWLList->SetItemText(idItem, COL_WINDOW_ID, wxString::Format(wxT("%.2lf"), (*it)->getWindow()));
661
 
                                                m_pWLList->SetItemText(idItem, COL_LEVEL_ID, wxString::Format(wxT("%.2lf"), (*it)->getLevel()));
662
 
                                        }
663
 
                                        RebuildComboWL();
664
 
                                        m_pChoiceInterpolate->Append(_("Nearest neighbour"));
665
 
                                        m_pChoiceInterpolate->Append(_("Linear"));
666
 
                                        m_pChoiceInterpolate->Append(_("Cubic"));
667
 
                                        if (modSettings->getInterpolationMode() == GNC::GCS::DefaultModalitySettings::TIM_NEAREST_NEIGHBOUR) {
668
 
                                                m_pChoiceInterpolate->Select(0);
669
 
                                        } else if (modSettings->getInterpolationMode() == GNC::GCS::DefaultModalitySettings::TIM_LINEAR) {
670
 
                                                m_pChoiceInterpolate->Select(1);
671
 
                                        }  else if (modSettings->getInterpolationMode() == GNC::GCS::DefaultModalitySettings::TIM_CUBIC) {
672
 
                                                m_pChoiceInterpolate->Select(2);
673
 
                                        }
674
 
                                }
675
 
 
676
 
                                void RebuildComboWL()
677
 
                                {
678
 
                                        m_pDefaultWindowLevel->Clear();
679
 
                                        m_pDefaultWindowLevel->Append(wxString::FromUTF8(GNC::GCS::DefaultModalitySettings::getDefaultWindowLevelLabel().c_str()));
680
 
                                        m_pDefaultWindowLevel->Append(wxString::FromUTF8(GNC::GCS::DefaultModalitySettings::getAutocalculateWindowLevelLabel().c_str()));
681
 
                                        m_pDefaultWindowLevel->Select(0);
682
 
                                        if (modSettings->getInitialWindowLevelLabel() == GNC::GCS::DefaultModalitySettings::getAutocalculateWindowLevelLabel()) {
683
 
                                                m_pDefaultWindowLevel->Select(1);
684
 
                                        }
685
 
                                        for (GNC::GCS::DefaultModalitySettings::TListOfWLSettings::const_iterator it = modSettings->getWLSettings().begin(); it != modSettings->getWLSettings().end(); ++it)
686
 
                                        {
687
 
                                                int item = m_pDefaultWindowLevel->Append(wxString::FromUTF8((*it)->getLabel().c_str()));
688
 
                                                if ((*it)->getLabel() == modSettings->getInitialWindowLevelLabel()) {
689
 
                                                        m_pDefaultWindowLevel->Select (item); 
690
 
                                                }
691
 
                                        }
692
 
                                }
693
 
 
694
 
                                const std::string& getModalityName() 
695
 
                                {
696
 
                                        return modSettings->getModality();
697
 
                                }
698
 
 
699
 
                                virtual void OnAddWL(wxCommandEvent& /*evt*/) 
700
 
                                {
701
 
                                        AddWindowLevelDialog dlg(this);
702
 
                                        if (dlg.ShowModal() == wxID_OK) {
703
 
                                                m_pDefaultWindowLevel->Append(dlg.m_pLabel->GetValue());
704
 
 
705
 
                                                wxTreeItemId idItem = m_pWLList->AppendItem(m_pWLList->GetRootItem(),dlg.m_pLabel->GetValue());
706
 
                                                m_pWLList->SetItemText(idItem, COL_WINDOW_ID, dlg.m_pWindow->GetValue());
707
 
                                                m_pWLList->SetItemText(idItem, COL_LEVEL_ID, dlg.m_pLevel->GetValue());
708
 
                                        }
709
 
                                }
710
 
 
711
 
                                virtual void OnEditWL(wxCommandEvent& /*evt*/) 
712
 
                                {
713
 
                                        wxTreeItemId item = m_pWLList->GetSelection();
714
 
                                        if (item.IsOk()) {
715
 
                                                wxString oldLabel = m_pWLList->GetItemText(item, COL_LABEL_ID);
716
 
                                                wxString oldWindow = m_pWLList->GetItemText(item, COL_WINDOW_ID);
717
 
                                                wxString oldLevel = m_pWLList->GetItemText(item, COL_LEVEL_ID);
718
 
                                                AddWindowLevelDialog dlg(this, oldLabel, oldWindow, oldLevel);
719
 
                                                if (dlg.ShowModal() == wxID_OK) {
720
 
                                                        int comboItem = m_pDefaultWindowLevel->FindString(oldLabel);
721
 
                                                        if (comboItem > 0) {
722
 
                                                                m_pDefaultWindowLevel->SetString(comboItem, dlg.m_pLabel->GetValue());
723
 
                                                        }
724
 
                                                        m_pWLList->SetItemText(item, COL_LABEL_ID, dlg.m_pLabel->GetValue());
725
 
                                                        m_pWLList->SetItemText(item, COL_WINDOW_ID, dlg.m_pWindow->GetValue());
726
 
                                                        m_pWLList->SetItemText(item, COL_LEVEL_ID, dlg.m_pLevel->GetValue());
727
 
                                                }
728
 
                                        }
729
 
                                }
730
 
 
731
 
                                virtual void OnDeleteWL(wxCommandEvent& /*evt*/)
732
 
                                {
733
 
                                        wxTreeItemId item = m_pWLList->GetSelection();
734
 
                                        if (item.IsOk()) {
735
 
                                                int answer = wxMessageBox(_("Do you confirm the removal of the preset?"), _("Data modified"), wxYES_NO | wxCANCEL, this);
736
 
                                                if(answer == wxYES){
737
 
                                                        wxString oldLabel = m_pWLList->GetItemText(item, COL_LABEL_ID);
738
 
                                                        int comboItem = m_pDefaultWindowLevel->FindString(oldLabel);
739
 
                                                        if (comboItem > 0) {
740
 
                                                                m_pDefaultWindowLevel->Delete(comboItem);
741
 
                                                                if (m_pDefaultWindowLevel->GetSelection() < 0) {
742
 
                                                                        m_pDefaultWindowLevel->Select(0);
743
 
                                                                }
744
 
                                                        }
745
 
                                                        m_pWLList->Delete(item);
746
 
                                                }
747
 
                                        }
748
 
                                }
749
 
 
750
 
                                GNC::GCS::Ptr<GNC::GCS::DefaultModalitySettings> GetSettings()
751
 
                                {
752
 
                                        modSettings->clearWindowLevels();
753
 
                                        modSettings->setInitialWindowLevelLabel(std::string(m_pDefaultWindowLevel->GetString(m_pDefaultWindowLevel->GetSelection()).ToUTF8()));
754
 
 
755
 
                                        wxTreeItemIdValue cookie;
756
 
                                        for (wxTreeItemId item = m_pWLList->GetFirstChild(m_pWLList->GetRootItem(), cookie); item.IsOk(); item = m_pWLList->GetNextChild(m_pWLList->GetRootItem(), cookie))
757
 
                                        {
758
 
                                                double window;
759
 
                                                double level;
760
 
                                                if (m_pWLList->GetItemText(item, COL_WINDOW_ID).ToDouble(&window) && m_pWLList->GetItemText(item, COL_LEVEL_ID).ToDouble(&level)) {
761
 
                                                        GNC::GCS::Ptr<GNC::GCS::WindowLevelSetting> wlSettings(new GNC::GCS::WindowLevelSetting(window, level, std::string(m_pWLList->GetItemText(item, COL_LABEL_ID).ToUTF8())));
762
 
                                                        modSettings->addWindowLevel(wlSettings);
763
 
                                                }
764
 
                                        }
765
 
 
766
 
                                        modSettings->setInterpolationMode((GNC::GCS::DefaultModalitySettings::TInterpolationMode)m_pChoiceInterpolate->GetSelection());
767
 
                                        return modSettings;
768
 
                                }
769
 
 
770
 
                                GNC::GCS::Ptr<GNC::GCS::DefaultModalitySettings> modSettings;
771
 
                        };
 
601
                        
772
602
                public:
773
603
                        EditHangingProtocolDialog(wxWindow* pParent): EditHangingProtocolDialogBase(pParent)
774
604
                        {       
810
640
 
811
641
                        void InitPanels()
812
642
                        {
813
 
                                m_currentModality = NULL;
814
 
 
815
643
                                editStudyCriteriaPanel = new EditCriteriaPanel(m_pGeneralPanel);
816
644
                                m_pSizerStudyCriteria->Add(editStudyCriteriaPanel, 1, wxEXPAND|wxALL, 5);
817
645
 
840
668
                                m_textName->SetValue(wxString::FromUTF8(hangingProtocol->getName().c_str()));
841
669
                                this->editStudyCriteriaPanel->loadMatcher(hangingProtocol->getStudyMatcher());  
842
670
 
843
 
                                //default modality settings...
844
 
                                wxTreeItemId root = m_pTreeNavigation->AddRoot(_("Modalities"));
845
 
                                for (GNC::GCS::HangingProtocol::TMapOfModalitySettings::const_iterator it = hangingProtocol->getModalitySettingsMap().begin(); it != hangingProtocol->getModalitySettingsMap().end(); ++it)
846
 
                                {
847
 
                                        if ((*it).second.IsValid()) {
848
 
                                                ModalityPanel * mp = new ModalityPanel(m_pModalityPanel, (*it).second);
849
 
                                                wxTreeItemId id = m_pTreeNavigation->AppendItem(root, wxString::FromUTF8(mp->getModalityName().c_str()));
850
 
                                                modalityBrowser[id.m_pItem] = mp;
851
 
                                                mp->InitPanels();
852
 
                                                mp->Hide();
853
 
                                                m_pSizerModalities->Add(mp, 1, wxEXPAND|wxALL, 5);
854
 
                                                m_pModalityPanel->Layout();
855
 
                                        }
856
 
                                }
857
 
                                wxTreeItemIdValue cookie;
858
 
                                m_pTreeNavigation->SelectItem(m_pTreeNavigation->GetFirstChild(root, cookie));
859
 
                                LoadCurrent();
860
 
                                //
861
 
 
862
671
                                m_pNoteBookWindows->Layout();
863
672
                                m_pGeneralPanel->Layout();
864
673
                                m_pMainNoteBook->Layout();
882
691
                                                }
883
692
                                        }
884
693
                                }
885
 
                                this->hangingProtocol->clearModalitySettings();
886
 
                                for (wxWindowList::iterator it = m_pModalityPanel->GetChildren().begin(); it != m_pModalityPanel->GetChildren().end(); ++it) {
887
 
                                        ModalityPanel* mp = dynamic_cast<ModalityPanel*>((*it));
888
 
                                        if (mp != NULL) {
889
 
                                                GNC::GCS::Ptr<GNC::GCS::DefaultModalitySettings> settings = mp->GetSettings();
890
 
                                                if (settings.IsValid()) {
891
 
                                                        this->hangingProtocol->addModalitySettings(settings);
892
 
                                                }
893
 
                                        }
894
 
                                }
895
694
                                return this->hangingProtocol;
896
695
                        }
897
696
 
898
697
 
899
698
                protected:
900
 
                        void OnNavigationChanged(wxTreeEvent &){
901
 
                                LoadCurrent();
902
 
                        }
903
 
 
904
 
                        void LoadCurrent() 
905
 
                        {
906
 
                                wxTreeItemId id = m_pTreeNavigation->GetSelection();
907
 
                                if (id.IsOk()) {
908
 
                                        if(modalityBrowser.find(id.m_pItem) != modalityBrowser.end()){
909
 
                                                ModalityPanel* pCurrent = modalityBrowser[id.m_pItem];
910
 
                                                if( pCurrent!=NULL && pCurrent!=m_currentModality){
911
 
                                                        m_pTitledPanelModalities->Freeze();
912
 
                                                        if(m_currentModality!=NULL){
913
 
                                                                m_currentModality->Hide();
914
 
                                                        }
915
 
                                                        m_currentModality = pCurrent;
916
 
                                                        wxString modName = wxString::Format(_("%s settings"),wxString::FromUTF8(pCurrent->getModalityName().c_str()).c_str());
917
 
                                                        m_pTitledPanelModalities->SetToolTip(modName);
918
 
                                                        m_currentModality->Show();
919
 
                                                        m_pModalityPanel->SetScrollbars(20, 20, 50, 50, 0, 0, false);
920
 
                                                        m_pModalityPanel->AdjustScrollbars();
921
 
                                                        m_pTitledPanelModalities->Layout();
922
 
                                                        m_pTitledPanelModalities->Thaw();                                       
923
 
                                                }
924
 
                                        }
925
 
                                }
926
 
                        }                       
927
699
 
928
700
                        virtual void OnPageChanging( wxAuiNotebookEvent& event ) 
929
701
                        {
962
734
                        GNC::GCS::ModoControlador::T_HangingProtocolSupportLevel hangingSupportLevel;
963
735
                        EditCriteriaPanel* editStudyCriteriaPanel;      
964
736
                        GNC::GCS::Ptr<GNC::GCS::HangingProtocol> hangingProtocol;       
965
 
                        typedef std::map<wxTreeItemIdValue ,ModalityPanel*> TModalityMap;
966
 
                        TModalityMap modalityBrowser;
967
 
                        ModalityPanel* m_currentModality;
968
737
                };
969
738
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
970
739
                class wxTreeItemDataProtocols: public wxTreeItemData