~ubuntu-branches/ubuntu/trusty/ginkgocadx/trusty

« back to all changes in this revision

Viewing changes to src/visualizator/visualizator/wxvtk/previewpanelvisualizator.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-07-21 11:58:53 UTC
  • mfrom: (7.2.1 sid)
  • Revision ID: package-import@ubuntu.com-20130721115853-44e7n1xujqglu78e
Tags: 3.4.0.928.29+dfsg-1
* New upstream release [July 2013]
  + new B-D: "libjsoncpp-dev".
  + new patch "unbundle-libjsoncpp.patch" to avoid building bundled
    "libjsoncpp-dev".
  + new patch "fix-wx.patch" to avoid FTBFS due to missing
    "-lwx_gtk2u_html-2.8".
* Removed unnecessary versioned Build-Depends.
* Removed obsolete lintian override.
* Reference get-orig-source implementation for orig.tar clean-up and
  DFSG-repackaging.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <api/controllers/ihistorycontroller.h>
19
19
#include <visualizator/wxvtk/gvistacompleja.h>
20
20
#include <api/dicom/dcmdictionary.h>
21
 
#include <api/internationalization/internationalization.h>
 
21
#include <api/internationalization/internationalization.h>
 
22
#include <eventos/scgenerated.h>
 
23
#include <api/controllers/ieventscontroller.h>
 
24
#include <api/ivista.h>
 
25
#include <resources/ginkgoresourcesmanager.h>
 
26
#include <main/gui/pacsupload/pacsuploaddialog.h>
 
27
#include <main/controllers/commandcontroller.h>
 
28
#include <commands/sendpacscommand.h>
22
29
 
23
30
#include "previewpanelvisualizator.h"
24
31
 
 
32
#define PACS_UPLOAD 2
 
33
 
25
34
namespace GNKVisualizator {
26
35
        namespace GUI {
27
36
                //////////////////////BEGIN D&D/////////////////////////
68
77
                        return SetData(len, buf);
69
78
                }
70
79
                //////////////////////END D&D/////////////////////////
71
 
 
 
80
                
72
81
 
73
82
                class IPreviewNodeVisualizator : public GNC::GUI::IPreviewNode
74
83
                {
87
96
                        }
88
97
                };
89
98
 
 
99
                //////////////////////BEGIN MENU/////////////////////////
 
100
                class EXTAPI wxLeafPanelDefaultHandler: public wxEvtHandler
 
101
                {
 
102
                        public:
 
103
                                wxLeafPanelDefaultHandler(wxEvtHandler* pParent, GVistaCompleja* view, long seriesPk): m_pParent(pParent),
 
104
                                        GView(view),
 
105
                                        SeriesPk(seriesPk)
 
106
                                {
 
107
                                        // Connect Events
 
108
                                        m_pParent->Connect(PACS_UPLOAD, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( wxLeafPanelDefaultHandler::OnPacsUpload),NULL,this);
 
109
                                }
 
110
                                virtual ~wxLeafPanelDefaultHandler()
 
111
                                {
 
112
                                        m_pParent->Disconnect(PACS_UPLOAD, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( wxLeafPanelDefaultHandler::OnPacsUpload),NULL,this);
 
113
                                }
 
114
 
 
115
                                virtual void OnPacsUpload(wxCommandEvent& event)
 
116
                                {
 
117
                                        std::list<long> viewSeries;
 
118
                                        viewSeries.insert(viewSeries.begin(), GView->GetView()->GetEstudio()->OpenedSeries.begin(), GView->GetView()->GetEstudio()->OpenedSeries.end());
 
119
                                        std::list<long> selectedSeries;
 
120
                                        selectedSeries.push_back(SeriesPk);
 
121
 
 
122
                                        GNC::GUI::PACSUploadDialog dlg(GView->GetView()->GetWindow(), viewSeries, selectedSeries);
 
123
 
 
124
                                        if (dlg.ShowModal() == wxID_OK) {
 
125
                                                std::list<long> listOfSeries;
 
126
                                                listOfSeries = dlg.GetSelectedSeries();
 
127
                                                if (!listOfSeries.empty()) {
 
128
                                                        GADAPI::SendPACSCommand* pCmd = new GADAPI::SendPACSCommand(dlg.GetSelectedServer(), "", listOfSeries);
 
129
                                                        GNC::GCS::ICommandController::Instance()->ProcessAsync(_Std("Uploading to the PACS ..."),pCmd, NULL);
 
130
                                                }
 
131
                                        }
 
132
                                }
 
133
 
 
134
                        protected:
 
135
                                GVistaCompleja* GView;
 
136
                                long SeriesPk;
 
137
                                wxEvtHandler* m_pParent;
 
138
                };
 
139
                //////////////////////END MENU/////////////////////////
 
140
 
90
141
                class IPreviewLeafVisualizator : public GNC::GUI::IPreviewLeaf
91
142
                {
92
143
                public:
97
148
                        }
98
149
                        virtual void OnShowMenu(wxWindow* pParent)
99
150
                        {
 
151
                                wxMenu popupMenu;
 
152
                                wxMenuItem* pItem = popupMenu.Append(PACS_UPLOAD, _("Upload series to PACS..."));
 
153
                                #ifdef __WXMSW__
 
154
                                pItem->SetBitmaps(GinkgoResourcesManager::MenuIcons::GetIcoSendToPACS());
 
155
                                #else
 
156
                                pItem->SetBitmap(GinkgoResourcesManager::MenuIcons::GetIcoSendToPACS());
 
157
                                #endif          
 
158
                                wxLeafPanelDefaultHandler menuHandler(pParent, VisualizatorView, seriesPk);
 
159
                                pParent->PopupMenu(&popupMenu);
100
160
                        }
101
161
                        virtual void OnPreviewDClick(wxWindow* pParent)
102
162
                        {
118
178
}
119
179
 
120
180
 
121
 
GNKVisualizator::GUI::PreviewPanelVisualizator::PreviewPanelVisualizator(GNC::GCS::IVista* pView, wxWindow* pParent) : GNC::GUI::PreviewPanel(pView, pParent)
 
181
GNKVisualizator::GUI::PreviewPanelVisualizator::PreviewPanelVisualizator(GNC::GCS::IVista* pView, GVistaCompleja* pParent) : GNC::GUI::PreviewPanel(pView, pParent)
122
182
{
123
183
        pRoot = NULL;
 
184
        GNC::GCS::IEventsController::Instance()->Registrar(this, GNC::GCS::Events::SCGeneratedEvent(m_pView));
124
185
}
125
186
 
126
187
GNKVisualizator::GUI::PreviewPanelVisualizator::~PreviewPanelVisualizator()
131
192
}
132
193
 
133
194
 
134
 
void GNKVisualizator::GUI::PreviewPanelVisualizator::LoadModel(GVistaCompleja* pParent, GNC::GCS::Ptr<GNKVisualizator::VisualizatorStudy>& pStudy)
 
195
void GNKVisualizator::GUI::PreviewPanelVisualizator::LoadModel()
135
196
{
136
197
        if (pRoot != NULL) {
137
198
                delete pRoot;   
138
199
        }
 
200
 
 
201
        GNC::GCS::Ptr<GNC::GCS::IStudyContext>& pStudy = m_pView->GetEstudio();
 
202
        GVistaCompleja* GView = dynamic_cast<GVistaCompleja*>(GetParent());
 
203
 
139
204
        pRoot = new GNKVisualizator::GUI::IPreviewNodeVisualizator(std::string(wxString::Format(_("%d series"), pStudy->OpenedSeries.size()).ToUTF8()));
140
205
        for (std::vector<long>::iterator it = pStudy->OpenedSeries.begin(); it != pStudy->OpenedSeries.end(); ++it)
141
206
        {
143
208
                GNC::GCS::IHistoryController::FileModel fileModel = GNC::GCS::IHistoryController::Instance()->GetFrameOfReference((*it));
144
209
                std::ostringstream ostr;
145
210
                ostr << seriesModel.series_modality << " (" << seriesModel.num_instances << ")";
146
 
                GNC::GUI::IPreviewLeaf* pLeaf = new GNKVisualizator::GUI::IPreviewLeafVisualizator(pParent, (*it), seriesModel.series_desc, ostr.str());
 
211
                GNC::GUI::IPreviewLeaf* pLeaf = new GNKVisualizator::GUI::IPreviewLeafVisualizator(GView, (*it), seriesModel.series_desc, ostr.str());
147
212
                pLeaf->SetFilePk(fileModel.pk);
148
213
                pRoot->AddChild(pLeaf);
149
214
        }
150
215
        GNC::GUI::PreviewPanel::LoadModel(pRoot);
151
216
}
152
217
 
 
218
 
 
219
 
 
220
void GNKVisualizator::GUI::PreviewPanelVisualizator::ProcesarEvento(GNC::GCS::Events::IEvent* evt)
 
221
{
 
222
        GNC::GUI::PreviewPanel::ProcesarEvento(evt);
 
223
 
 
224
        switch(evt->GetCodigoEvento()) {
 
225
                case ginkgoEVT_Core_SCGenerated:
 
226
                        {
 
227
                                GNC::GCS::Events::SCGeneratedEvent* pSCGenEvt = dynamic_cast<GNC::GCS::Events::SCGeneratedEvent*>(evt);
 
228
                                if(pSCGenEvt != NULL) {
 
229
                                        GNC::GCS::Ptr<GNC::GCS::IStudyContext>& pStudy = m_pView->GetEstudio();
 
230
                                        for (std::list<long>::const_iterator itNew = pSCGenEvt->GetSeriesId().begin(); itNew != pSCGenEvt->GetSeriesId().end(); ++itNew) {
 
231
                                                bool newSeries = true;
 
232
                                                for (std::vector<long>::const_iterator itOpened = pStudy->OpenedSeries.begin();  itOpened != pStudy->OpenedSeries.end(); ++itOpened) {
 
233
                                                        if ((*itOpened) == (*itNew)) {
 
234
                                                                newSeries = false;
 
235
                                                                break;
 
236
                                                        }
 
237
                                                }
 
238
                                                if (newSeries) {
 
239
                                                        pStudy->OpenedSeries.push_back((*itNew));
 
240
                                                }
 
241
                                        }
 
242
                                        LoadModel();
 
243
                                }
 
244
                        }
 
245
                        break;
 
246
        }
 
247
}
 
248