// safe calls to the complete chain // berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); // to cover for all possible cases of closed pages etc. static void SafeHandleNavigatorView(QString view_query_name) { berry::IWorkbench* wbench = berry::PlatformUI::GetWorkbench(); if( wbench == nullptr ) return; berry::IWorkbenchWindow::Pointer wbench_window = wbench->GetActiveWorkbenchWindow(); if( wbench_window.IsNull() ) return; berry::IWorkbenchPage::Pointer wbench_page = wbench_window->GetActivePage(); if( wbench_page.IsNull() ) return; auto wbench_view = wbench_page->FindView( view_query_name ); if( wbench_view.IsNotNull() ) { bool isViewVisible = wbench_page->IsPartVisible( wbench_view ); if( isViewVisible ) { wbench_page->HideView( wbench_view ); return; } } wbench_page->ShowView( view_query_name ); }
void GetBounds(ELEMTYPE a_min[NUMDIMS], ELEMTYPE a_max[NUMDIMS]) { ASSERT(IsNotNull()); StackElement& curTos = m_stack[m_tos - 1]; Branch& curBranch = curTos.m_node->m_branch[curTos.m_branchIndex]; for (int index = 0; index < NUMDIMS; ++index) { a_min[index] = curBranch.m_rect.m_min[index]; a_max[index] = curBranch.m_rect.m_max[index]; } }
bool CurveFile::LoadCurvesFromFile() { currentCurveData = 0; // std::cout << fileName << std::endl; if (IsNotNull(fileName) && textCurveData.ReadFromFile(fileName)) { currentCurveData = &textCurveData; return true; } return false; }
void nsCollect::ProcessData::DoDelete(char* delfName) { if (IsNotNull(delfName)) { GenAppInfoMsg("Deleting file", delfName); #ifdef _WIN32 DeleteFile(delfName); #else remove(delfName); #endif } }
//#PUBLIC SETTER void QmitkDataStorageComboBox::SetDataStorage(mitk::DataStorage *_DataStorage) { auto dataStorage = m_DataStorage.Lock(); // reset only if datastorage really changed if (dataStorage.GetPointer() != _DataStorage) { // if there was an old storage, remove listeners if (dataStorage.IsNotNull()) { dataStorage->AddNodeEvent.RemoveListener( mitk::MessageDelegate1<QmitkDataStorageComboBox, const mitk::DataNode *>(this, &QmitkDataStorageComboBox::AddNode)); dataStorage->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1<QmitkDataStorageComboBox, const mitk::DataNode *>( this, &QmitkDataStorageComboBox::RemoveNode)); } // set new storage m_DataStorage = _DataStorage; // if there is a new storage, add listeners if (!m_DataStorage.IsExpired()) { dataStorage = m_DataStorage.Lock(); dataStorage->AddNodeEvent.AddListener( mitk::MessageDelegate1<QmitkDataStorageComboBox, const mitk::DataNode *>(this, &QmitkDataStorageComboBox::AddNode)); dataStorage->RemoveNodeEvent.AddListener( mitk::MessageDelegate1<QmitkDataStorageComboBox, const mitk::DataNode *>( this, &QmitkDataStorageComboBox::RemoveNode)); } // reset predicate to reset the combobox this->Reset(); } }
MATHBASE_API void _JordanGauss( CDSRMMatrix<CDSRReal> *pA, CDSRMVector<CDSRReal> *pB, CDSRMVector<CDSRReal> *pX ) { if( pA->n_row() != pA->n_column() ) throw "The matrix is not square"; if( pA->n_row() != (long) pB->size() ) throw "Internal problem - sizes of the source and destination matrix are not equal"; long i, j, k; CDSRReal value; CDSRMMatrix<CDSRReal> matrix( (*pA) ); CDSRMVector<CDSRReal> vector( (*pB) ); pX->resize( pB->size() ); for( i = 0; i < pA->n_row(); i++ ) { if( IsNull( matrix( i, i ) ) ) throw "SLAE cannot be solved by this method or matrix is singular"; for( k = i; k < pA->n_row(); k++ ) { value = matrix( k, i ); if( IsNotNull( value ) && IsNotOne( value ) ) { vector[ k ] /= value; for( j = i + 1; j < pA->n_row(); j++ ) matrix( k, j ) /= value; matrix( k, i ) = 1.0; } } for( k = i + 1; k < pA->n_row(); k++ ) { value = matrix( k, i ); if( IsNotNull( value ) ) { vector[ k ] -= vector[ i ]; for( j = i + 1; j < pA->n_row(); j++ ) matrix( k, j ) -= matrix( i, j ); matrix( k, i ) = 0.0; } } } for( i = pA->n_row() - 1; i > 0; i-- ) { for( k = 0; k < i + 1; k++ ) { value = matrix( k, i ); if( IsNotNull( value ) && IsNotOne( value ) ) { vector[ k ] /= value; for( j = k; j < i; j++ ) matrix( k, j ) /= value; } } for( k = 0; k < i; k++ ) { value = matrix( k, i ); if( IsNotNull( value ) ) { vector[ k ] -= vector[ i ]; matrix( k, i ) = 0.0; } } } vector[ 0 ] /= matrix( 0, 0 ); matrix( 0, 0 ) = 1.0; for( i = 0 ; i < pA->n_row(); i++ ) ( *pX )[ i ] = vector[ i ]; }
MATHBASE_API void _JordanGaussCR( CDSRMMatrix<CDSRReal> *pA, CDSRMVector<CDSRReal> *pB, CDSRMVector<CDSRReal> *pX ) { if( pA->n_row() != pA->n_column() ) throw "The matrix is not square"; if( pA->n_row() != (long) pB->size() ) throw "Internal problem - sizes of the source and destination matrix are not equal"; long i, j, k; CDSRReal value; CDSRMMatrix<CDSRReal> matrix( (*pA) ); CDSRMVector<CDSRReal> vector( (*pB) ); CDSRMVector<long> row( pA->n_row() ); CDSRMVector<long> col( pA->n_row() ); pX->resize( pB->size() ); for( i = 0; i < pA->n_row(); i++ ) col[ i ] = row[ i ] = i; for( i = 0; i < pA->n_row(); i++ ) { if( IsNull( matrix( row[ i ], col[ i ] ) ) ) _IndexCR(i, &matrix, &row, &col ); for( k = i; k < pA->n_row(); k++ ) { value = matrix( row[ k ], col[ i ] ); if( IsNotNull( value ) && IsNotOne( value ) ) { vector[ row[ k ] ] /= value; for( j = i + 1; j < pA->n_row(); j++ ) matrix( row[ k ], col[ j ] ) /= value; matrix( row[ k ], col[ i ] ) = 1.0; } } for( k = i + 1; k < pA->n_row(); k++ ) { value = matrix( row[ k ], col[ i ] ); if( IsNotNull( value ) ) { vector[ row[ k ] ] -= vector[ row[ i ] ]; for( j = i + 1; j < pA->n_row(); j++ ) matrix( row[ k ], col[ j ] ) -= matrix( row[ i ], col[ j ] ); matrix( row[ k ], col[ i ] ) = 0.0; } } } for( i = pA->n_row() - 1; i > 0; i-- ) { for( k = 0; k < i + 1; k++ ) { value = matrix( row[ k ], col[ i ] ); if( IsNotNull( value ) && IsNotOne( value ) ) { vector[ row[ k ] ] /= value; for( j = k; j < i; j++ ) matrix( row[ k ], col[ j ] ) /= value; matrix( row[ k ], col[ i ] ) = 1.0; } } for( k = 0; k < i; k++ ) { value = matrix( row[ k ], col[ i ] ); if( IsNotNull( value ) ) { vector[ row[ k ] ] -= vector[ row[ i ] ]; matrix( row[ k ], col[ i ] ) = 0.0; } } } vector[ row[ 0 ] ] /= matrix( row[ 0 ], col[ 0 ] ); matrix( row[ 0 ], col[ 0 ] ) = 1.0; for( i = 0; i < pA->n_row(); i++ ) ( *pX )[ col[ i ] ] = vector[ row[ i ] ]; }
{ MITK_TEST_FAILED_MSG( << "Could not find test file" ) } MITK_TEST_OUTPUT(<< "Loading test image '" << filename << "'") mitk::StringList files; files.push_back( filename ); mitk::ClassicDICOMSeriesReader::Pointer reader = mitk::ClassicDICOMSeriesReader::New(); reader->SetInputFiles( files ); reader->AnalyzeInputFiles(); reader->LoadImages(); MITK_TEST_CONDITION_REQUIRED( reader->GetNumberOfOutputs() == 1, "Loaded one result from file" ); m_Image = reader->GetOutput(0).GetMitkImage(); MITK_TEST_CONDITION_REQUIRED( m_Image.IsNotNull(), "Loaded an mitk::Image" ); m_Geometry = m_Image->GetSlicedGeometry()->GetPlaneGeometry(0); MITK_TEST_CONDITION_REQUIRED( m_Geometry.IsNotNull(), "Getting image geometry" ) } void mitkImageStatisticsCalculatorTestSuite::TestCase1() { /***************************** * one whole white pixel * -> mean of 255 expected ******************************/ mitk::PlanarPolygon::Pointer figure1 = mitk::PlanarPolygon::New(); figure1->SetPlaneGeometry( m_Geometry ); mitk::Point2D pnt1; pnt1[0] = 10.5 ; pnt1[1] = 3.5; figure1->PlaceFigure( pnt1 );
void TestIISxpressISAPI::TestIISxpressISAPI::Init() { IsNotNull(m_hIISxpress); IsNotNull(m_pfnGetFilterVersion); IsNotNull(m_pfnHttpFilterProc); }
YSRESULT YsShellExtEdit_StitchingUtil::ProcessNearestMutualExclusiveEdgeVertexPair(YsShellExtEdit &shl) { YsShellExtEdit_TopologyUtil topoUtil; // See research note 2014/12/17 // See research note 2014/12/30 for Condition 5 auto edVtPairHd=edVtProx.GetNearestEdgeVertexPairHandle(); if(edVtPairHd.IsNotNull()) { // Must check if no single-use edge is connected to the vertex because of the previous stitching. auto edVtPair=edVtProx.GetEdgeVertexPair(edVtPairHd); #ifdef YS_DEBUG_SPECIFIC_VERTEX if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos) { YsPrintf("%s\n",shl.GetVertexPosition(edVtPair.vtHd).Txt()); YsPrintf("%s %s\n",shl.GetVertexPosition(edVtPair.edVtHd[0]).Txt(),shl.GetVertexPosition(edVtPair.edVtHd[1]).Txt()); YsPrintf("nSharingEdge=%d\n",edVtPair.nSharingEdge); } #endif if(2==YsShellExt_TopologyUtil::GetNumSingleUseEdgeConnectedToVertex(shl.Conv(),edVtPair.vtHd) && // Condition (3) of Mutual-Exclusive conditions YSTRUE==YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),edVtPair.edVtHd)) // Condition (1) of Mutual-Exclusive conditions { if(1==edVtPair.nSharingEdge) // Condition (4) of Mutual-Exclusive conditions { // Condition 5 const double e1e2=shl.GetEdgeLength(edVtPair.edVtHd); if(shl.GetEdgeLength(edVtPair.vtHd,edVtPair.edVtHd[0])<e1e2 && shl.GetEdgeLength(edVtPair.vtHd,edVtPair.edVtHd[1])<e1e2) { // Mutual YSBOOL reverseProximityCheckOrVertexShared[2]= { YSFALSE,YSFALSE }; YsShellExt_EdgeVertexProximityUtil::EDVTPAIR_HANDLE reverseCheckPairHd[2]= { edVtProx.FindEdgeVertexPairFromVertex(edVtPair.edVtHd[0]), edVtProx.FindEdgeVertexPairFromVertex(edVtPair.edVtHd[1]), }; for(int i=0; i<2; ++i) // Condition (2) and (2)' of Mutual-Exclusive conditions. { if(reverseCheckPairHd[i].IsNotNull()) { YsShellExt_EdgeVertexProximityUtil::EdgeVertexPair reverseCheckPair=edVtProx.GetEdgeVertexPair(reverseCheckPairHd[i]); if(reverseCheckPair.edVtHd[0]==edVtPair.vtHd || reverseCheckPair.edVtHd[1]==edVtPair.vtHd) // Condition (2) of Mutual-Exclusive conditions. { #ifdef YS_DEBUG_SPECIFIC_VERTEX if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos) { printf("%s %s\n",shl.GetVertexPosition(reverseCheckPair.edVtHd[0]).Txt(),shl.GetVertexPosition(reverseCheckPair.edVtHd[1]).Txt()); printf("(2)\n"); } #endif reverseProximityCheckOrVertexShared[i]=YSTRUE; } } if(YSTRUE!=reverseProximityCheckOrVertexShared[i]) { if(YSTRUE==YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),edVtPair.vtHd,edVtPair.edVtHd[i]) && 0==edVtProx.GetEdgeIsClosestOfHowManyVertex(edVtPair.vtHd,edVtPair.edVtHd[i])) { #ifdef YS_DEBUG_SPECIFIC_VERTEX if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos) { printf("(2)'\n"); } #endif reverseProximityCheckOrVertexShared[i]=YSTRUE; } } } if(YSTRUE==reverseProximityCheckOrVertexShared[0] && YSTRUE==reverseProximityCheckOrVertexShared[1]) { #ifdef YS_DEBUG_SPECIFIC_VERTEX if(shl.GetVertexPosition(edVtPair.vtHd)==watchVtPos) { printf("%s %d\n",__FUNCTION__,__LINE__); } #endif #ifdef YS_DEBUG_SPECIFIC_EDGE if(YSTRUE==YsSameEdge( watchEdVtPos[0], watchEdVtPos[1], shl.GetVertexPosition(edVtPair.edVtHd[0]), shl.GetVertexPosition(edVtPair.edVtHd[1]))) { printf("%s %d\n",__FUNCTION__,__LINE__); printf("%s\n",shl.GetVertexPosition(edVtPair.vtHd).Txt()); } #endif topoUtil.InsertVertexOnEdge(shl,edVtPair.edVtHd,1,&edVtPair.vtHd); } } } } #if defined(YS_DEBUG_SPECIFIC_VERTEX) && defined(YS_DEBUG_SPECIFIC_VERTEX_STOP) if(shl.GetVertexPosition(edVtPair.vtHd)==YsVec3(-1456.334997, 64.171291, -0.000000) || shl.GetVertexPosition(edVtPair.vtHd)==YsVec3(-1456.2094428700, 64.4021512874, -2.3092000235)) { printf("%s %d>",__FUNCTION__,__LINE__);getchar(); } #endif edVtProx.DeleteEdgeVertexPair(edVtPairHd); return YSOK; } return YSERR; }
YSRESULT YsShellExtEdit_StitchingUtil::ProcessExpandedNearestMutualExclusiveEdgeVertexPair(YsShellExtEdit &shl) { YsShellExtEdit_TopologyUtil topoUtil; // See research note 2014/12/23 // See research note 2014/12/30 for Condition 5 auto edVtPairHd=edVtProx.GetNearestEdgeVertexPairHandle(); if(edVtPairHd.IsNotNull()) { auto edVtPair=edVtProx.GetEdgeVertexPair(edVtPairHd); #ifdef YS_DEBUG_SPECIFIC_EDGE if(YSTRUE==YsSameEdge( watchEdVtPos[0], watchEdVtPos[1], shl.GetVertexPosition(edVtPair.edVtHd[0]), shl.GetVertexPosition(edVtPair.edVtHd[1]))) { printf("%s %d\n",__FUNCTION__,__LINE__); printf("Edge (%s)-(%s)\n",shl.GetVertexPosition(edVtPair.edVtHd[0]).Txt(),shl.GetVertexPosition(edVtPair.edVtHd[1]).Txt()); printf("NPUE %d\n",shl.GetNumPolygonUsingEdge(edVtPair.edVtHd)); printf("IsSingleUse %d\n",YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),edVtPair.edVtHd)); } #endif if(0==shl.GetNumPolygonUsingEdge(edVtPair.edVtHd) || YSTRUE!=YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),edVtPair.edVtHd)) // May be fixed already. { edVtProx.DeleteEdgeVertexPair(edVtPairHd); return YSOK; } auto nearVtx=edVtProx.FindNearestVertexFromEdgePiece(edVtPair.edVtHd); // Condition (1)&(4) getting all vertex whose closest edge is edVtHd[0]-edVtHd[1] #ifdef YS_DEBUG_SPECIFIC_EDGE if(YSTRUE==YsSameEdge( watchEdVtPos[0], watchEdVtPos[1], shl.GetVertexPosition(edVtPair.edVtHd[0]), shl.GetVertexPosition(edVtPair.edVtHd[1]))) { printf("%s %d\n",__FUNCTION__,__LINE__); printf(" %d near vertices.\n",(int)nearVtx.GetN()); printf(" nSharing %d\n",edVtPair.nSharingEdge); for(auto vtHd : nearVtx) { printf(" %s\n",shl.GetVertexPosition(vtHd).Txt()); } } #endif if(0<nearVtx.GetN() && nearVtx.GetN()==edVtPair.nSharingEdge) // One or more verteices whose closest is this edge may be processed already. Checking for the exclusive consition again. { #ifdef YS_DEBUG_SPECIFIC_EDGE if(YSTRUE==YsSameEdge( watchEdVtPos[0], watchEdVtPos[1], shl.GetVertexPosition(edVtPair.edVtHd[0]), shl.GetVertexPosition(edVtPair.edVtHd[1]))) { printf("%s %d\n",__FUNCTION__,__LINE__); } #endif // Condition (2) if(1<nearVtx.GetN()) { for(int idx=0; idx<nearVtx.GetN()-1; ++idx) { if(YSTRUE!=YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),nearVtx[idx],nearVtx[idx+1]) || 0<edVtProx.GetEdgeIsClosestOfHowManyVertex(nearVtx[idx],nearVtx[idx+1])) { edVtProx.DeleteEdgeVertexPair(edVtPairHd); return YSOK; } } } // Condition (5) const double e1e2=shl.GetEdgeLength(edVtPair.edVtHd); for(auto vtHd : nearVtx) { if(shl.GetEdgeLength(vtHd,edVtPair.edVtHd[0])>=e1e2 || shl.GetEdgeLength(vtHd,edVtPair.edVtHd[1])>=e1e2) { edVtProx.DeleteEdgeVertexPair(edVtPairHd); return YSOK; } } #ifdef YS_DEBUG_SPECIFIC_EDGE if(YSTRUE==YsSameEdge( watchEdVtPos[0], watchEdVtPos[1], shl.GetVertexPosition(edVtPair.edVtHd[0]), shl.GetVertexPosition(edVtPair.edVtHd[1]))) { printf("%s %d\n",__FUNCTION__,__LINE__); } #endif // Condition (3) YSBOOL reverseProximityCheckOrVertexShared[2]= { YSFALSE,YSFALSE }; YsShellExt_EdgeVertexProximityUtil::EDVTPAIR_HANDLE reverseCheckPairHd[2]= { edVtProx.FindEdgeVertexPairFromVertex(edVtPair.edVtHd[0]), edVtProx.FindEdgeVertexPairFromVertex(edVtPair.edVtHd[1]), }; const YsShellVertexHandle tipVtHd[2]= { nearVtx[0], nearVtx.Last() }; for(int i=0; i<2; ++i) // Condition (3) of Expanded Mutual-Exclusive conditions. { if(reverseCheckPairHd[i].IsNotNull()) { YsShellExt_EdgeVertexProximityUtil::EdgeVertexPair reverseCheckPair=edVtProx.GetEdgeVertexPair(reverseCheckPairHd[i]); if(reverseCheckPair.edVtHd[0]==tipVtHd[i] || reverseCheckPair.edVtHd[1]==tipVtHd[i]) // Condition (2) of Mutual-Exclusive conditions. { reverseProximityCheckOrVertexShared[i]=YSTRUE; } } if(YSTRUE!=reverseProximityCheckOrVertexShared[i]) { if(YSTRUE==YsShellExt_TopologyUtil::IsSingleUseEdge(shl.Conv(),tipVtHd[i],edVtPair.edVtHd[i]) && 0==edVtProx.GetEdgeIsClosestOfHowManyVertex(tipVtHd[i],edVtPair.edVtHd[i])) { reverseProximityCheckOrVertexShared[i]=YSTRUE; } } } #ifdef YS_DEBUG_SPECIFIC_EDGE if(YSTRUE==YsSameEdge( watchEdVtPos[0], watchEdVtPos[1], shl.GetVertexPosition(edVtPair.edVtHd[0]), shl.GetVertexPosition(edVtPair.edVtHd[1]))) { printf("%s %d\n",__FUNCTION__,__LINE__); printf(" %d %d\n",reverseProximityCheckOrVertexShared[0],reverseProximityCheckOrVertexShared[1]); printf(" Tip[0] %s\n",shl.GetVertexPosition(tipVtHd[0]).Txt()); printf(" Tip[1] %s\n",shl.GetVertexPosition(tipVtHd[1]).Txt()); } #endif if(YSTRUE==reverseProximityCheckOrVertexShared[0] && YSTRUE==reverseProximityCheckOrVertexShared[1]) { topoUtil.InsertVertexOnEdge(shl,edVtPair.edVtHd,nearVtx.GetN(),nearVtx); } } edVtProx.DeleteEdgeVertexPair(edVtPairHd); return YSOK; } return YSERR; }
void QmitkExampleView::ProcessSelectedImage() { // Before we even think about processing something, we need to make sure // that we have valid input. Don't be sloppy, this is a main reason // for application crashes if neglected. auto selectedDataNodes = this->GetDataManagerSelection(); if (selectedDataNodes.empty()) return; auto firstSelectedDataNode = selectedDataNodes.front(); if (firstSelectedDataNode.IsNull()) { QMessageBox::information(nullptr, "Example View", "Please load and select an image before starting image processing."); return; } auto data = firstSelectedDataNode->GetData(); // Something is selected, but does it contain data? if (data != nullptr) { // We don't use the auto keyword here, which would evaluate to a native // image pointer. Instead, we want a smart pointer in order to ensure that // the image isn't deleted somewhere else while we're using it. mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(data); // Something is selected and it contains data, but is it an image? if (image.IsNotNull()) { auto imageName = firstSelectedDataNode->GetName(); auto offset = m_Controls.offsetSpinBox->value(); MITK_INFO << "Process image \"" << imageName << "\" ..."; // We're finally using the ExampleImageFilter from ExtExampleModule. auto filter = ExampleImageFilter::New(); filter->SetInput(image); filter->SetOffset(offset); filter->Update(); mitk::Image::Pointer processedImage = filter->GetOutput(); if (processedImage.IsNull() || !processedImage->IsInitialized()) return; MITK_INFO << " done"; // Stuff the resulting image into a data node, set some properties, // and add it to the data storage, which will eventually display the // image in the application. auto processedImageDataNode = mitk::DataNode::New(); processedImageDataNode->SetData(processedImage); QString name = QString("%1 (Offset: %2)").arg(imageName.c_str()).arg(offset); processedImageDataNode->SetName(name.toStdString()); // We don't really need to copy the level window, but if we wouldn't // do it, the new level window would be initialized to display the image // with optimal contrast in order to capture the whole range of pixel // values. This is also true for the input image as long as one didn't // modify its level window manually. Thus, the images would appear // identical unless you compare the level window widget for both images. mitk::LevelWindow levelWindow; if (firstSelectedDataNode->GetLevelWindow(levelWindow)) processedImageDataNode->SetLevelWindow(levelWindow); // We also attach our ExampleImageInteractor, which allows us to paint // on the resulting images by using the mouse as long as the CTRL key // is pressed. auto interactor = CreateExampleImageInteractor(); if (interactor.IsNotNull()) interactor->SetDataNode(processedImageDataNode); this->GetDataStorage()->Add(processedImageDataNode); } } // Now it's your turn. This class/method has lots of room for improvements, // for example: // // - What happens when multiple items are selected but the first one isn't // an image? - There isn't any feedback for the user at all. // - What's the front item of a selection? Does it depend on the order // of selection or the position in the Data Manager? - Isn't it // better to process all selected images? Don't forget to adjust the // titles of the UI widgets. // - In addition to the the displayed label, it's probably a good idea to // enable or disable the button depending on the selection. }
void DicomEventHandler::OnSignalAddSeriesToDataManager(const ctkEvent& ctkEvent) { QStringList listOfFilesForSeries; listOfFilesForSeries = ctkEvent.getProperty("FilesForSeries").toStringList(); if (!listOfFilesForSeries.isEmpty()) { //for rt data, if the modality tag isn't defined or is "CT" the image is handled like before if(ctkEvent.containsProperty("Modality") && (ctkEvent.getProperty("Modality").toString().compare("RTDOSE",Qt::CaseInsensitive) == 0 || ctkEvent.getProperty("Modality").toString().compare("RTSTRUCT",Qt::CaseInsensitive) == 0 || ctkEvent.getProperty("Modality").toString().compare("RTPLAN", Qt::CaseInsensitive) == 0)) { QString modality = ctkEvent.getProperty("Modality").toString(); if(modality.compare("RTDOSE",Qt::CaseInsensitive) == 0) { auto doseReader = mitk::RTDoseReaderService(); doseReader.SetInput(listOfFilesForSeries.front().toStdString()); std::vector<itk::SmartPointer<mitk::BaseData> > readerOutput = doseReader.Read(); if (!readerOutput.empty()){ mitk::Image::Pointer doseImage = dynamic_cast<mitk::Image*>(readerOutput.at(0).GetPointer()); mitk::DataNode::Pointer doseImageNode = mitk::DataNode::New(); doseImageNode->SetData(doseImage); doseImageNode->SetName("RTDose"); if (doseImage != nullptr) { auto sopUIDProperty = doseImage->GetProperty("dicomseriesreader.SOPClassUID"); if (sopUIDProperty.IsNotNull()){ auto sopUIDStringProperty = dynamic_cast<mitk::StringProperty*>(sopUIDProperty.GetPointer()); if (sopUIDStringProperty != nullptr){ std::string sopUID = sopUIDStringProperty->GetValue(); doseImageNode->SetName(sopUID); } } berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); if (prefNode.IsNull()) { mitkThrow() << "Error in preference interface. Cannot find preset node under given name. Name: " << prefNode->ToString().toStdString(); } //set some specific colorwash and isoline properties bool showColorWashGlobal = prefNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_COLORWASH_ID.c_str(), true); bool showIsolinesGlobal = prefNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_ISOLINES_ID.c_str(), true); //Set reference dose property double referenceDose = prefNode->GetDouble(mitk::RTUIConstants::REFERENCE_DOSE_ID.c_str(), mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE); mitk::ConfigureNodeAsDoseNode(doseImageNode, mitk::GeneratIsoLevels_Virtuos(), referenceDose, showColorWashGlobal); ctkServiceReference serviceReference = mitk::PluginActivator::getContext()->getServiceReference<mitk::IDataStorageService>(); mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService<mitk::IDataStorageService>(serviceReference); mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); dataStorage->Add(doseImageNode); mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage); } }//END DOSE } else if(modality.compare("RTSTRUCT",Qt::CaseInsensitive) == 0) { auto structReader = mitk::RTStructureSetReaderService(); structReader.SetInput(listOfFilesForSeries.front().toStdString()); std::vector<itk::SmartPointer<mitk::BaseData> > readerOutput = structReader.Read(); if (readerOutput.empty()){ MITK_ERROR << "No structure sets were created" << endl; } else { std::vector<mitk::DataNode::Pointer> modelVector; ctkServiceReference serviceReference = mitk::PluginActivator::getContext()->getServiceReference<mitk::IDataStorageService>(); mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService<mitk::IDataStorageService>(serviceReference); mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); for (const auto& aStruct : readerOutput){ mitk::ContourModelSet::Pointer countourModelSet = dynamic_cast<mitk::ContourModelSet*>(aStruct.GetPointer()); mitk::DataNode::Pointer structNode = mitk::DataNode::New(); structNode->SetData(countourModelSet); structNode->SetProperty("name", aStruct->GetProperty("name")); structNode->SetProperty("color", aStruct->GetProperty("contour.color")); structNode->SetProperty("contour.color", aStruct->GetProperty("contour.color")); structNode->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); structNode->SetVisibility(true, mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))); structNode->SetVisibility(false, mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget2"))); structNode->SetVisibility(false, mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget3"))); structNode->SetVisibility(true, mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget4"))); dataStorage->Add(structNode); } mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage); } } else if (modality.compare("RTPLAN", Qt::CaseInsensitive) == 0) { auto planReader = mitk::RTPlanReaderService(); planReader.SetInput(listOfFilesForSeries.front().toStdString()); std::vector<itk::SmartPointer<mitk::BaseData> > readerOutput = planReader.Read(); if (!readerOutput.empty()){ //there is no image, only the properties are interesting mitk::Image::Pointer planDummyImage = dynamic_cast<mitk::Image*>(readerOutput.at(0).GetPointer()); mitk::DataNode::Pointer planImageNode = mitk::DataNode::New(); planImageNode->SetData(planDummyImage); planImageNode->SetName("RTPlan"); ctkServiceReference serviceReference = mitk::PluginActivator::getContext()->getServiceReference<mitk::IDataStorageService>(); mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService<mitk::IDataStorageService>(serviceReference); mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); dataStorage->Add(planImageNode); } } } else { mitk::StringList seriesToLoad; QStringListIterator it(listOfFilesForSeries); while (it.hasNext()) { seriesToLoad.push_back(it.next().toStdString()); } //Get Reference for default data storage. ctkServiceReference serviceReference = mitk::PluginActivator::getContext()->getServiceReference<mitk::IDataStorageService>(); mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService<mitk::IDataStorageService>(serviceReference); mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); std::vector<mitk::BaseData::Pointer> baseDatas = mitk::IOUtil::Load(seriesToLoad.front()); for (const auto &data : baseDatas) { mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(data); std::string nodeName = "Unnamed Dicom"; std::string studyUID = ""; std::string seriesUID = ""; data->GetPropertyList()->GetStringProperty("DICOM.0020.000D", studyUID); data->GetPropertyList()->GetStringProperty("DICOM.0020.000E", seriesUID); if (!studyUID.empty()) { nodeName = studyUID; } if (!seriesUID.empty()) { if (!studyUID.empty()) { nodeName += "/"; } nodeName += seriesUID; } dataStorage->Add(node); } } } else { MITK_INFO << "There are no files for the current series"; } }
void PD_2DXYPS::DrawPlotAxes() { if (!plotAnnotation.DoAnno()) { SetClipPlanes(); return; } SetIncrFont(); ClearClipPlanes(); SetAxesLocals(); SetLineSolid(); xAxis.SetMajorIncs(); xAxis.SetMinorIncs(); yAxis.SetMajorIncs(); yAxis.SetMinorIncs(); SC_DoubleArray xMajorIncs, xMinorIncs, yMajorIncs, yMinorIncs; xAxis.GetAxesMajorIncs(xMajorIncs); xAxis.GetAxesMinorIncs(xMinorIncs); yAxis.GetAxesMajorIncs(yMajorIncs); yAxis.GetAxesMinorIncs(yMinorIncs); Point2D axesOffComp, labelOffComp; bool dummy; GetAxesOffsets(axesOffComp, labelOffComp, dummy); Point2D majorTicLength = GetPixelComponents(plotAnnotation.majorTicLength); Point2D minorTicLength = GetPixelComponents(plotAnnotation.minorTicLength); Point2D majorTicOffset = GetPixelComponents(plotAnnotation.majorTicOffset); Point2D minorTicOffset = GetPixelComponents(plotAnnotation.minorTicOffset); // set Z val SetAnnoLow(); if (plotAnnotation.drawAxesLines) { AxesDrawSetup(); HardCopyBlockStart(24); // 4 axes + 2 caps per axes * 2 // x axis if (plotAnnotation.DoXAxis()) { DrawXAxes(convYaxisMin, -axesOffComp.pY); if (plotAnnotation.framePlot) DrawXAxes(convYaxisMax, axesOffComp.pY); } // y axis if (plotAnnotation.DoYAxis()) { DrawYAxes(convXaxisMin, -axesOffComp.pX); if (plotAnnotation.framePlot) DrawYAxes(convXaxisMax, axesOffComp.pX); } if (plotAnnotation.axesOffset > 0) { // slight kluge -- tic routines require untransformed X&Ys double xmin, xmax, ymin, ymax; xAxis.GetAxisLimits(xmin, xmax); yAxis.GetAxisLimits(ymin, ymax); // draw caps on axes if (plotAnnotation.DoXAxis()) { DrawXTic(xmin, convYaxisMin, -axesOffComp.pY, axesOffComp.pY, 0.0); DrawXTic(xmax, convYaxisMin, -axesOffComp.pY, axesOffComp.pY, 0.0); if (plotAnnotation.framePlot) { DrawXTic(xmin, convYaxisMax, axesOffComp.pY, -axesOffComp.pY, 0.0); DrawXTic(xmax, convYaxisMax, axesOffComp.pY, -axesOffComp.pY, 0.0); } } if (plotAnnotation.DoYAxis()) { DrawYTic(convXaxisMin, ymin, -axesOffComp.pX, axesOffComp.pX, 0.0); DrawYTic(convXaxisMin, ymax, -axesOffComp.pX, axesOffComp.pX, 0.0); if (plotAnnotation.framePlot) { DrawYTic(convXaxisMax, ymin, axesOffComp.pX, -axesOffComp.pX, 0.0); DrawYTic(convXaxisMax, ymax, axesOffComp.pX, -axesOffComp.pX, 0.0); } } } HardCopyBlockEnd(); SetAnnoLow(); } double axmaxOffset = 0.0; if (plotAnnotation.DoXAxis() && (xAxis.axisMajorIncs != PC_Axes::aitNone)) if (xAxis.axisMajorIncs == PC_Axes::aitGrid) { MajorGridDrawSetup(); HardCopyBlockStart(xMajorIncs.Size() * 2); if (plotAnnotation.framePlot) axmaxOffset = axesOffComp.pY; for (int i = 0; i < xMajorIncs.Size(); i++) DrawXGrid(xMajorIncs[i], -axesOffComp.pY, axmaxOffset, majorTicOffset.pY); HardCopyBlockEnd(); SetAnnoLow(); } else { MajorTicDrawSetup(); HardCopyBlockStart(xMajorIncs.Size() * 4); int i; for (i = 0; i < xMajorIncs.Size(); i++) { DrawXTic(xMajorIncs[i], convYaxisMin, -axesOffComp.pY, majorTicLength.pY, majorTicOffset.pY); if (plotAnnotation.framePlot) DrawXTic(xMajorIncs[i], convYaxisMax, axesOffComp.pY, -majorTicLength.pY, -majorTicOffset.pY); } HardCopyBlockEnd(); } if (plotAnnotation.DoYAxis() && (yAxis.axisMajorIncs != PC_Axes::aitNone)) if (yAxis.axisMajorIncs == PC_Axes::aitGrid) { MajorGridDrawSetup(); if (plotAnnotation.framePlot) axmaxOffset = axesOffComp.pX; HardCopyBlockStart(yMajorIncs.Size() * 2); for (int i = 0; i < yMajorIncs.Size(); i++) { DrawYGrid(yMajorIncs[i], -axesOffComp.pX, axmaxOffset, majorTicOffset.pX); } HardCopyBlockEnd(); SetAnnoLow(); } else { MajorTicDrawSetup(); HardCopyBlockStart(yMajorIncs.Size() * 4); for (int i = 0; i < yMajorIncs.Size(); i++) { DrawYTic(convXaxisMin, yMajorIncs[i], -axesOffComp.pX, majorTicLength.pX, majorTicOffset.pX); if (plotAnnotation.framePlot) DrawYTic(convXaxisMax, yMajorIncs[i], axesOffComp.pX, -majorTicLength.pX, -majorTicOffset.pX); } HardCopyBlockEnd(); } if (plotAnnotation.DoXAxis() && (xAxis.axisMinorIncs != PC_Axes::aitNone)) if (xAxis.axisMinorIncs == PC_Axes::aitGrid) { MinorGridDrawSetup(); if (plotAnnotation.framePlot) axmaxOffset = axesOffComp.pY; HardCopyBlockStart((xMajorIncs.Size() + 1) * xMinorIncs.Size() * 2); for (int i = -1; i < xMajorIncs.Size(); i++) for (int j = 0; j < xMinorIncs.Size(); j++) DrawXGrid(GetMinorIncVal(xMajorIncs, xMinorIncs, i, j, doLogX, convXaxisMax < convXaxisMin), -axesOffComp.pY, axmaxOffset, minorTicOffset.pX); HardCopyBlockEnd(); SetAnnoLow(); } else { MinorTicDrawSetup(); HardCopyBlockStart((xMajorIncs.Size() + 1) * xMinorIncs.Size() * 4); for (int i = -1; i < xMajorIncs.Size(); i++) for (int j = 0; j < xMinorIncs.Size(); j++) { double incVal = GetMinorIncVal(xMajorIncs, xMinorIncs, i, j, doLogX, convXaxisMax < convXaxisMin); DrawXTic(incVal, convYaxisMin, -axesOffComp.pY, minorTicLength.pY, minorTicOffset.pY); if (plotAnnotation.framePlot) DrawXTic(incVal, convYaxisMax, axesOffComp.pY, -minorTicLength.pY, -minorTicOffset.pY); } HardCopyBlockEnd(); } if (plotAnnotation.DoYAxis() && (yAxis.axisMinorIncs != PC_Axes::aitNone)) if (yAxis.axisMinorIncs == PC_Axes::aitGrid) { MinorGridDrawSetup(); if (plotAnnotation.framePlot) axmaxOffset = axesOffComp.pX; HardCopyBlockStart((yMajorIncs.Size() + 1) * yMinorIncs.Size() * 2); for (int i = -1; i < yMajorIncs.Size(); i++) for (int j = 0; j < yMinorIncs.Size(); j++) DrawYGrid(GetMinorIncVal(yMajorIncs, yMinorIncs, i, j, doLogY, convYaxisMax < convYaxisMin), -axesOffComp.pX, axmaxOffset, minorTicOffset.pX); HardCopyBlockEnd(); SetAnnoLow(); } else { MinorTicDrawSetup(); HardCopyBlockStart((yMajorIncs.Size() + 1) * yMinorIncs.Size() * 4); for (int i = -1; i < yMajorIncs.Size(); i++) for (int j = 0; j < yMinorIncs.Size(); j++) { double incVal = GetMinorIncVal(yMajorIncs, yMinorIncs, i, j, doLogY, convYaxisMax < convYaxisMin); DrawYTic(convXaxisMin, incVal, -axesOffComp.pX, minorTicLength.pX, minorTicOffset.pX); if (plotAnnotation.framePlot) DrawYTic(convXaxisMax, incVal, axesOffComp.pX, -minorTicLength.pX, -minorTicOffset.pX); } HardCopyBlockEnd(); } double maxHeight = 0.0; double xaxYpos = convYaxisMin - axesOffComp.pY - labelOffComp.pY - majorTicOffset.pY; double maxWidth = 0.0; double yaxXpos = convXaxisMin - axesOffComp.pX - labelOffComp.pX - majorTicOffset.pX; if (plotAnnotation.labelIncrements) { SetDrawColor(defaultPenSet->GetColor(plotAnnotation.axesDataPen)); char labStr[80]; ExtendedLabelData labInfo; if (plotAnnotation.DoXAxis()) { // need to go through all labels once to calc over top on exponents if horiz double exponentShift = 0.0; for (int i = 0; i < xMajorIncs.Size(); i++) { double xTran = TransformX(xMajorIncs[i]); if (Limit::WithinOneLimit(convXaxisMin, convXaxisMax, xTran)) { xAxis.axisIncFormat.RealToString(xMajorIncs[i], labStr, 80); if (xAxis.incrFont.fontRotation == PSC_Font::fr_Horiz) { if (GetExtendedStringSizeInfo(xAxis.incrFont, labStr, labInfo)) { if (labInfo.aboveTop > exponentShift) exponentShift = labInfo.aboveTop; double totHeight = labInfo.height + labInfo.aboveTop; if ((fabs(totHeight) > fabs(maxHeight))) maxHeight = totHeight; } } else { double w, h; if (GetStringSizeInfo(xAxis.incrFont, labStr, w, h)) { if (fabs(w) > fabs(maxHeight)) maxHeight = w; } } } } //set alignment for printing HorizontalTextAlignment halign; VerticalTextAlignment valign; if (xAxis.incrFont.fontRotation == PSC_Font::fr_Horiz) { halign = hta_Center; valign = vta_Top; } else { valign = vta_Center; if (xAxis.incrFont.fontRotation == PSC_Font::fr_VertLeft) halign = hta_Right; else halign = hta_Left; } // now print label double xincLabYPos = xaxYpos - exponentShift; for (int i = 0; i < xMajorIncs.Size(); i++) { double xTran = TransformX(xMajorIncs[i]); if (Limit::WithinOneLimit(convXaxisMin, convXaxisMax, xTran)) { xAxis.axisIncFormat.RealToString(xMajorIncs[i], labStr, 80); PrintString(xAxis.incrFont, labStr, halign, valign, xTran, xincLabYPos); } } } if (plotAnnotation.DoYAxis()) { // need to go through all labels once to calc over top on exponents if not horiz double exponentShift = 0.0; for (int i = 0; i < yMajorIncs.Size(); i++) { double yTran = TransformY(yMajorIncs[i]); if (Limit::WithinOneLimit(convYaxisMin, convYaxisMax, yTran)) { yAxis.axisIncFormat.RealToString(yMajorIncs[i], labStr, 80); if (yAxis.incrFont.fontRotation != PSC_Font::fr_Horiz) { if (GetExtendedStringSizeInfo(yAxis.incrFont, labStr, labInfo)) { if (labInfo.aboveTop > exponentShift) exponentShift = labInfo.aboveTop; double totHeight = labInfo.height + labInfo.aboveTop; if ((fabs(totHeight) > fabs(maxWidth))) maxWidth = totHeight; } } else { double w, h; if ((GetStringSizeInfo(yAxis.incrFont, labStr, w, h)) && (fabs(w) > fabs(maxWidth))) maxWidth = w; } } } //set alignment for printing HorizontalTextAlignment halign; VerticalTextAlignment valign; if (yAxis.incrFont.fontRotation == PSC_Font::fr_Horiz) { halign = hta_Right; valign = vta_Center; } else { halign = hta_Center; if (yAxis.incrFont.fontRotation == PSC_Font::fr_VertLeft) valign = vta_Bottom; else valign = vta_Top; } for (int i = 0; i < yMajorIncs.Size(); i++) { double yTran = TransformY(yMajorIncs[i]); if (Limit::WithinOneLimit(convYaxisMin, convYaxisMax, yTran)) { yAxis.axisIncFormat.RealToString(yMajorIncs[i], labStr, 80); PrintString(yAxis.incrFont, labStr, halign, valign, yaxXpos, yTran); } } } } plotAnnotation.xaxesLabelPos.pX = (convXaxisMin + convXaxisMax) / 2.0; plotAnnotation.xaxesLabelPos.pY = xaxYpos - maxHeight - labelOffComp.pY; plotAnnotation.yaxesLabelPos.pX = yaxXpos - maxWidth - labelOffComp.pX * 2.0; plotAnnotation.yaxesLabelPos.pY = (convYaxisMin + convYaxisMax) / 2.0; if (plotAnnotation.labelAxes) { if (plotAnnotation.DoXAxis() && IsNotNull(plotAnnotation.xaxesLabel)) { PrintString(plotAnnotation.labelFont, plotAnnotation.xaxesLabel, hta_Center, vta_Top, plotAnnotation.xaxesLabelPos.pX, plotAnnotation.xaxesLabelPos.pY); } if (plotAnnotation.DoYAxis() && IsNotNull(plotAnnotation.yaxesLabel)) { PSC_Font yLabFont(plotAnnotation.labelFont); yLabFont.fontRotation = PSC_Font::fr_VertLeft; PrintString(yLabFont, plotAnnotation.yaxesLabel, hta_Center, vta_Bottom, plotAnnotation.yaxesLabelPos.pX, plotAnnotation.yaxesLabelPos.pY); } } SetClipPlanes(); }
const DATATYPE& operator*() const { ASSERT(IsNotNull()); StackElement& curTos = m_stack[m_tos - 1]; return curTos.m_node->m_branch[curTos.m_branchIndex].m_data; }
void PFO_VariableArrayGridLinesGL :: DrawPlotObject() { if (!InitDrawObject()) return; Limit3D currLimits = GetCurrentViewLimits(); OGL2DBase& currPlot = static_cast<OGL2DBase&>(*objectBase); PC_GridLine currGrid(currPlot, arrayIsX); GL_Line::SetLineProperties(gridLineSpec); for (int i = 0; i < variableArrayDC->Size(); i++) { double varVal = (*variableArrayDC)[i].GetValue(); if (!currGrid.CreateGridLine(varVal, currLimits)) continue; currGrid.SetLabelPos(labelFormat.labelPosition / 100.0); currGrid.AdjustForAxes(); char label[80]; bool doLabel; switch (labelFormat.labelType) { case PSC_GridLineLabelFormat::ltNone: { doLabel = false; break; } case PSC_GridLineLabelFormat::ltText : { CopyString(label, (*variableArrayDC)[i].GetID(), 80); doLabel = IsNotNull(label); break; } case PSC_GridLineLabelFormat::ltValue : { valueFormat.RealToString(varVal, label, 80); doLabel = true; break; } } bool drawFullLine = true; if (doLabel) { currGrid.OffsetLabelPos(labelFont, labelFormat.labelOffset, labelFormat.halign, labelFormat.valign); if (labelFormat.blankLabel) { drawFullLine = false; currGrid.DrawBlankedLine(labelFont, label, labelFormat.halign, labelFormat.valign); } currGrid.PrintUnclippedLabel(labelFont, label, labelFormat.halign, labelFormat.valign); } if (drawFullLine) currGrid.DrawGridLine(); } CloseDrawObject(); }