Exemple #1
0
void Code::starting()
{
    SLM_TRACE_FUNC();
    this->::fwGui::IGuiContainerSrv::create();

    ::fwGuiQt::container::QtContainer::sptr qtContainer = ::fwGuiQt::container::QtContainer::dynamicCast(
        this->getContainer() );

    ::fwData::String::sptr stringObj = this->getInOut< ::fwData::String >(s_STRING_INOUT);

    QHBoxLayout* layout = new QHBoxLayout();
    m_valueCtrl = new QTextEdit( );
    layout->addWidget( m_valueCtrl, 1);

    if(m_language == s_PYTHON )
    {
        m_highlighter = new ::fwGuiQt::highlighter::PythonHighlighter(m_valueCtrl->document());
    }
    else if(m_language == s_CPP )
    {
        m_highlighter = new ::fwGuiQt::highlighter::CppHighlighter(m_valueCtrl->document());
    }
    else
    {
        OSLM_WARN("Language "<<m_language<<" not yet supported.");
    }

    qtContainer->setLayout( layout );

    QObject::connect(m_valueCtrl, SIGNAL(textChanged()), this, SLOT(onModifyValue()));
    this->updating();
}
Exemple #2
0
//@todo remove throw specifications
void IEditionService::attach( ::fwServices::ComChannelService::sptr observer) throw()
{
    // Pre-condition : This observer must exist and must not be already registered.
    SLM_ASSERT("The ComChannelService given in parameter is a null shared pointer.", observer != 0 );
    SLM_ASSERT("ACH : The ComChannelService, given in parameter, is already registered", !isAttached( observer ) );

    // Get the service observer
    ::fwServices::IService::sptr service = observer->getDest();

    // Test if this service handling all events or if it has a specific configuration
    if ( service->isHandlingAllEvents() )
    {
        OSLM_WARN("Sorry, IService API to manage events has changed, this service "<< service->getClassname() <<" must define a list of handling message thanks to method IService::addNewHandledEvent() which must be used the service constructor.");
        m_globalObservers.push_back( observer );
        // sort the list to put the new element at the right place.
        m_globalObservers.sort( Less );
    }
    else
    {
        OSLM_DEBUG("This service not handling all events : " << service->getClassname() );
        std::vector< std::string > handlingEvents = service->getHandledEvents();
        BOOST_FOREACH(std::string handlingEvent, handlingEvents)
        {
            ObserverContainer & specificObservers = m_event2SpecificObservers[ handlingEvent ];
            specificObservers.push_back( observer );
            specificObservers.sort( Less );
        }
    }
void PulseProgressDialog::show()
{
#ifdef PULSEPROGRESS_USE_THREAD

    this->Bind( wxEVT_LOCALTHREAD_COMPLETED , &PulseProgressDialog::onComplete , this);

    m_wxpd = new wxProgressDialog(
                                    ::fwWX::std2wx(m_title),
                                    "                                             ", // sinon pas de place pour ecrire definit espace initial
                                    100 /*percent*/,
                                    NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH);

    m_wxpd->Pulse( m_message );
    m_wxpd->Fit();
    m_wxpd->Show();
    m_wxpd->Update();
    m_thread = new LocalThread( m_stuff);

    if ( m_thread->Create() != wxTHREAD_NO_ERROR )
    {
        wxLogError("Can't create the thread!");
        delete m_thread;
        m_thread = NULL;
    }
    else
    {
        if (m_thread->Run() != wxTHREAD_NO_ERROR )
        {
            wxLogError("Can't create the thread!");
            delete m_thread;
            m_thread = NULL;
        }
    }

    int i=0;

    while( m_thread->isFinished()== false ) // moins couteux que wxThread::isRunning
    {
        OSLM_TRACE("PulseProgressDialog  in Loop m_thread->isRunning" << m_thread->IsRunning() << " " << ++i );
        m_wxpd->Pulse();
        m_wxpd->Update();
        wxYield();
        wxMilliSleep(m_frequence);
    }
    OSLM_TRACE("PulseProgressDialog AFTER Loop m_thread->isRunning " << m_thread->IsRunning() << " " << ++i );

    if ( m_thread->getErrorMessage().size() )
    {
        m_wxpd->Update(100,"Failed !!!");

        OSLM_WARN( "PulseProgressDialog::m_stuff an exception has occured " << m_thread->getErrorMessage() );
        throw ::fwTools::Failed( m_thread->getErrorMessage() );
    }
    m_wxpd->Update(100,"Done");
#else
    m_thread = NULL;
    m_stuff();
#endif
}
Exemple #4
0
std::string ObjectTracker::getClassname( xmlNodePtr xmlNode )
{
    std::string className;
    try
    {
        className =  XMLParser::getAttribute (xmlNode, "class");
    }
    catch (...)
    {
        OSLM_WARN("No className for " << xmlNode->name );
    }

    return className;
}
Exemple #5
0
std::string ObjectTracker::getID( xmlNodePtr xmlNode )
{
    std::string id;
    try
    {
        id =  XMLParser::getAttribute (xmlNode, "id");
    }
    catch (...)
    {
        OSLM_WARN("No tracking id for " << xmlNode->name );
    }

    return id;
}
Exemple #6
0
void DicomSearch::searchRecursivelyFiles(const ::boost::filesystem::path &dirPath, std::vector<std::string>& dicomFiles)
{
    std::vector<std::string> vecStr;
    std::string strIgnoreFile = ".zip|.txt|.htm|.html|.xml|.exe|.gz|.dir|.gif|.jpeg|.jpg|dicomdir|.DS_Store";
    ::boost::algorithm::split( vecStr, strIgnoreFile, ::boost::algorithm::is_any_of("|"), ::boost::algorithm::token_compress_on );

    std::string lowerFilename;
    std::string filename;
    for( ::boost::filesystem::recursive_directory_iterator it(dirPath);
            it != ::boost::filesystem::recursive_directory_iterator(); ++it)
    {
        if(! ::boost::filesystem::is_directory(*it))
        {
#if BOOST_FILESYSTEM_VERSION > 2
            lowerFilename = filename = it->path().string();
#else
            lowerFilename = filename = it->string();
#endif
            std::transform ( lowerFilename.begin(), lowerFilename.end(), lowerFilename.begin(), tolower );
            if(DicomSearch::compare( lowerFilename, &vecStr) )
            {
                try
                {
                    ::gdcm::Reader reader;
                    reader.SetFileName( filename.c_str() );
                    if( !reader.Read() )// with GDCM2.0.18 use !reader.CanRead()
                    {
                        OSLM_WARN("Failed to read: " << filename );
                    }
                    else
                    {
                        dicomFiles.push_back( filename.c_str() );
                    }
                }
                catch (std::exception& e)
                {
                    OSLM_ERROR ( "Try with another reader for this file : " << filename.c_str());
                }
            }
        }
    }
}
Exemple #7
0
void SStringReader::updating() throw ( ::fwTools::Failed )
{
    SLM_TRACE_FUNC();

    if ( this->hasLocationDefined() )
    {
        // Read data.txt
        std::string line;
        std::string data ("");
        std::ifstream myfile ( this->getFile().string().c_str() );
        if ( myfile.is_open() )
        {
            while ( myfile.good() )
            {
                getline( myfile, line );
                OSLM_DEBUG("Read line : " << line );
                data += line;
            }
            myfile.close();
        }
        else
        {
            OSLM_ERROR("Unable to open file : " << this->getFile() );
        }
        OSLM_DEBUG("Loaded data : " << data );

        // Set new string value in your associated object
        ::fwData::String::sptr myAssociatedData = this->getObject< ::fwData::String >();
        myAssociatedData->setValue( data );
    }
    else
    {
        OSLM_WARN("Be careful, reader failed because no file location is defined." );
    }

    // Then, notifies listerners that the image has been modified
    notifyMessage();
}
::fwData::TransformationMatrix3D::sptr SplineReaderService::loadObjectTransformationMatrix3D(std::string m_file)
{
    ::fwData::TransformationMatrix3D::NewSptr matrix;
    ::boost::filesystem::path location(m_file) ;

    std::fstream file;
    file.open(location.string().c_str(), std::fstream::in);
    if (!file.is_open())
    {
        OSLM_WARN( "Object Matrix file loading error for " + location.string());
        return matrix;
    }
    double val;
    for( int l=0 ; l < 4 ; l++ )
    {
        for( int c=0 ; c < 4 ; c++ )
        {
            file >> val;
            matrix->setCoefficient(l, c, val);
        }
    }
    return matrix;
}
Exemple #9
0
void ItkLogger::DisplayWarningText(const char* _txt)
{
    OSLM_WARN("[ITK]: " << _txt);
}
void DicomSurfaceWriter::write() throw (::fwTools::Failed)
{
    ::fwData::Acquisition::csptr series = this->getConcreteObject();
    SLM_ASSERT("fwData::Acquisition not instanced", series);


    //*****     Get the dictionary *****//
    // Reading of the dictionary
    ::fwData::StructureTraitsDictionary::NewSptr structDico;
    // Ready of the dictionary file.

    ::fwDataIO::reader::DictionaryReader::NewSptr dictionaryReader;
    dictionaryReader->setObject(structDico);
    std::string dictionaryPath("./share/fwDataIO_0-2/OrganDictionary.dic");
    dictionaryReader->setFile(dictionaryPath);
    try
    {
        dictionaryReader->read();
    }
    catch(const std::exception & e)
    {
        OSLM_ERROR(e.what());
    }

    //*****     Write surface segmentations     *****//
    unsigned int    skippedSegment  = 0;    // Number of segmentation not written
    const uint32_t  nbSegmentation  = series->getNumberOfReconstructions();

    for (unsigned int i = 0; i < nbSegmentation; ++i)
    {
        try
        {
            // Get the info of the struture type
            ::fwData::Reconstruction::csptr reconstruction = series->getReconstructions()[i];
            const std::string & segmentLabel    = reconstruction->getStructureType();
            ::fwData::StructureTraitsDictionary::StructureTypeNameContainer segmentLabels = structDico->getStructureTypeNames();
            ::fwData::StructureTraitsDictionary::StructureTypeNameContainer::const_iterator itr = std::find(segmentLabels.begin(), segmentLabels.end(),segmentLabel);
            ::fwData::StructureTraits::sptr structure;
            ::fwData::StructureTraits::NewSptr emptyStructure;
            if(itr != segmentLabels.end())
            {
                structure = structDico->getStructure(segmentLabel);
            }
            else
            {
                structure = emptyStructure;
            }

            // Write segmentation
            DicomSegmentWriter::writeSurfaceSegmentation(i, structure);

            // Here, the segment is identified and its surface can be written.
            this->writeSurfaceMesh(i);
        }
        catch(::fwTools::Failed & e)
        {
            ++skippedSegment;
            OSLM_ERROR(e.what());
        }
    }

    if (skippedSegment == nbSegmentation)
    {
        throw ::fwTools::Failed("All 3D reconstructions have been rejected");
    }
    else if (skippedSegment > 0)
    {
        OSLM_WARN(skippedSegment<<" 3D reconstruction(s) have been rejected");
    }

    ::boost::shared_ptr< ::gdcm::SurfaceWriter >    gSurfaceWriter  = ::boost::static_pointer_cast< ::gdcm::SurfaceWriter >( this->getWriter() );
    ::gdcm::DataSet &                               gDsRoot         = this->getDataSet();

    // Number of Surfaces Tag(0x0066,0x0001)
    gSurfaceWriter->SetNumberOfSurfaces( nbSegmentation - skippedSegment ); // Type 1
    OSLM_TRACE("Number of Surfaces : " << nbSegmentation - skippedSegment);

    //*****     Write Enhanced General Equipement Module     *****//
    //See: PS 3.3 C.7.5.2
    {
        DicomEquipmentWriter equipmentWriter;
        equipmentWriter.writeEnhancedGeneralEquipement(gDsRoot);
    }

    //*****     Write Content Identification Module     *****//
    //See: PS 3.3 Table 10-12
    this->writeContentIdentification();

    //*****     Complete the file      *****//
    // Set the instance to surface segmentation storage
    ::boost::shared_ptr< DicomInstance > dicomInstance = this->getDicomInstance();
    const char * SOPClassUID = ::gdcm::MediaStorage::GetMSString( ::gdcm::MediaStorage::SurfaceSegmentationStorage );
    std::string SOPClassUIDStr;
    if (SOPClassUID == 0)
        SOPClassUIDStr = "1.2.840.10008.5.1.4.1.1.66.5";
    else
        SOPClassUIDStr = SOPClassUID;
    dicomInstance->setSOPClassUID( SOPClassUIDStr );

    ::gdcm::UIDGenerator gUIDgen;
    gUIDgen.SetRoot( SOPClassUIDStr.c_str() );
    dicomInstance->setSOPInstanceUID( gUIDgen.Generate() );

    dicomInstance->setModality("SEG");

    //*****     Write the file      *****//
    DicomRefInstanceWriter< ::fwData::Acquisition >::write();
}