diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp index 97f2fb87f5..2af43c3169 100644 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp +++ b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp @@ -1,104 +1,104 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include // berry Includes #include #include #include "mitkIDataStorageService.h" #include "mitkDataStorageEditorInput.h" #include "mitkRenderingManager.h" #include "mitkProperties.h" #include "mitkNodePredicateData.h" #include "mitkNodePredicateNot.h" #include "mitkNodePredicateProperty.h" #include "mitkProgressBar.h" QmitkDnDFrameWidget::QmitkDnDFrameWidget(QWidget *parent) : QWidget(parent) { setAcceptDrops(true); } void QmitkDnDFrameWidget::dragEnterEvent( QDragEnterEvent *event ) { // accept drags event->accept(); } void QmitkDnDFrameWidget::dropEvent( QDropEvent * event ) { //open dragged files mitk::IDataStorageService::Pointer service = berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); mitk::DataStorage::Pointer ds; if (service.IsNotNull()) ds = service->GetActiveDataStorage()->GetDataStorage(); else return; QList fileNames = event->mimeData()->urls(); bool dsmodified = false; for (QList::Iterator fileName = fileNames.begin(); fileName != fileNames.end(); ++fileName) { mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); try { - nodeReader->SetFileName(fileName->toLocalFile().toLatin1().data()); + nodeReader->SetFileName(fileName->toLocalFile().toStdString()); if(event->dropAction()==Qt::LinkAction) nodeReader->SetImageSerie(true); nodeReader->Update(); for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) { mitk::DataNode::Pointer node; node = nodeReader->GetOutput(i); if ( node->GetData() != NULL ) { ds->Add(node); dsmodified = true; } } } catch(...) { } } if(dsmodified) { // get all nodes that have not set "includeInBoundingBox" to false mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" , mitk::BoolProperty::New(false))); mitk::DataStorage::SetOfObjects::ConstPointer rs = ds->GetSubset(pred); // calculate bounding geometry of these nodes mitk::TimeSlicedGeometry::Pointer bounds = ds->ComputeBoundingGeometry3D(rs); // initialize the views to the bounding geometry mitk::RenderingManager::GetInstance()->InitializeViews(bounds); } -} \ No newline at end of file +} diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.cpp index c9832ceaa2..c9724631c6 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.cpp @@ -1,208 +1,208 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ Version: $Revision: 21070 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkExtFileOpenAction.h" #include #include #include #include "mitkCoreObjectFactory.h" #include "mitkSceneIO.h" #include "mitkProgressBar.h" #include #include #include #include #include #include #include #include "mitkProperties.h" #include "mitkNodePredicateData.h" #include "mitkNodePredicateNot.h" #include "mitkNodePredicateProperty.h" #include "QmitkStdMultiWidgetEditor.h" QmitkExtFileOpenAction::QmitkExtFileOpenAction(berry::IWorkbenchWindow::Pointer window) : QAction(0) { this->init(window); } QmitkExtFileOpenAction::QmitkExtFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window) : QAction(0) { this->setIcon(icon); this->init(window); } void QmitkExtFileOpenAction::init(berry::IWorkbenchWindow::Pointer window) { m_Window = window; this->setParent(static_cast(m_Window->GetShell()->GetControl())); this->setText("&Open..."); this->setToolTip("Open data files (images, surfaces,...) and project files (.mitk)"); berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); m_GeneralPreferencesNode = prefService->GetSystemPreferences()->Node("/General"); this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); } void QmitkExtFileOpenAction::Run() { /** * @brief stores the last path of last opened file */ static QString m_LastPath; if(m_GeneralPreferencesNode.Lock().IsNotNull()) { if(m_LastPath.isEmpty()) m_LastPath = QString::fromStdString(m_GeneralPreferencesNode.Lock()->Get("LastFileOpenPath", "")); } //QFileDialog dialog(static_cast(m_Window->GetShell()->GetControl())); //dialog.setFileMode(QFileDialog::ExistingFiles); //QStringList filters; //filters << "Images (*.pic *.pic.gz *.vti *.dcm *.nhdr *.nrrd *.mhd)" // << "Surfaces (*.stl *.vtk *.vtp)" // << "MITK Pointset (*.mps)" // << "All Files (*.*)"; //dialog.setFilters(filters); std::stringstream ss; ss << mitk::CoreObjectFactory::GetInstance()->GetFileExtensions(); std::string fileExtensions = ss.str(); fileExtensions.append(";;MITK Scene Files (*.mitk)"); fileExtensions.insert( fileExtensions.find("all (") + 5, "*.mitk " ); QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Open", m_LastPath, fileExtensions.c_str() ); //if (dialog.exec()) // fileNames = dialog.selectedFiles(); if (fileNames.empty()) return; // check if there is an open perspective, if not open the default perspective if (m_Window->GetActivePage().IsNull()) { std::string defaultPerspId = m_Window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective(); m_Window->GetWorkbench()->ShowPerspective(defaultPerspId, m_Window); } QFileInfo info(fileNames.at(0)); m_LastPath = info.filePath(); if(m_GeneralPreferencesNode.Lock().IsNotNull()) { m_GeneralPreferencesNode.Lock()->Put("LastFileOpenPath", m_LastPath.toStdString()); m_GeneralPreferencesNode.Lock()->Flush(); } mitk::DataStorageEditorInput::Pointer editorInput; mitk::DataStorage::Pointer dataStorage; QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->GetActiveEditor(); if (editor.Cast().IsNull()) { editorInput = new mitk::DataStorageEditorInput(); dataStorage = editorInput->GetDataStorageReference()->GetDataStorage(); } else { multiWidgetEditor = editor.Cast(); dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); } if (multiWidgetEditor.IsNull()) { berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); multiWidgetEditor = editor.Cast(); } else { multiWidgetEditor->GetStdMultiWidget()->RequestUpdate(); } bool dsmodified = false; for (QStringList::Iterator fileName = fileNames.begin(); fileName != fileNames.end(); ++fileName) { if ( fileName->right(5) == ".mitk" ) { mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); bool clearDataStorageFirst(false); mitk::ProgressBar::GetInstance()->AddStepsToDo(2); dataStorage = sceneIO->LoadScene( fileName->toLocal8Bit().constData(), dataStorage, clearDataStorageFirst ); dsmodified = true; mitk::ProgressBar::GetInstance()->Progress(2); } else { mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); try { - nodeReader->SetFileName(fileName->toLocal8Bit().data()); + nodeReader->SetFileName(fileName->toStdString()); nodeReader->Update(); for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) { mitk::DataNode::Pointer node; node = nodeReader->GetOutput(i); if ( node->GetData() != NULL ) { dataStorage->Add(node); dsmodified = true; } } } catch(...) { } } } if(dsmodified) { // get all nodes that have not set "includeInBoundingBox" to false mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" , mitk::BoolProperty::New(false))); mitk::DataStorage::SetOfObjects::ConstPointer rs = dataStorage->GetSubset(pred); // calculate bounding geometry of these nodes mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); // initialize the views to the bounding geometry mitk::RenderingManager::GetInstance()->InitializeViews(bounds); } }