Esempio n. 1
0
void Histogram::updateCurrentPoint( ::scene2D::data::Event::sptr _event )
{
    SLM_TRACE_FUNC();
    
    SLM_ASSERT("m_histogramPointUID must be defined in order to update the related ::fwData::Point data.",
            !m_histogramPointUID.empty());
    
    ::fwData::Histogram::sptr histogram = this->getObject< ::fwData::Histogram>();
    ::fwData::Histogram::fwHistogramValues values = histogram->getValues();
    const float histogramMinValue = histogram->getMinValue();
    const float histogramBinsWidth = histogram->getBinsWidth();

    // Event coordinates in scene
    ::scene2D::data::Coord sceneCoord = this->getScene2DRender()->mapToScene( _event->getCoord() );

    const int histIndex = (int) sceneCoord.getX();
    const int index = histIndex - histogramMinValue;
    const int nbValues = (int)values.size() * histogramBinsWidth;

    if(index >= 0 && index < nbValues)
    {
        ::fwData::Point::sptr point =
            ::fwData::Point::dynamicCast( ::fwTools::fwID::getObject( m_histogramPointUID ) );

        SLM_ASSERT("m_histogramPointUID can't be null here.", point);

        point->getRefCoord()[0] = sceneCoord.getX();
        point->getRefCoord()[1] = values.at( index / histogramBinsWidth ) * m_scale;
    }
}
Esempio n. 2
0
void Instantiator::ClassInitialize()
{
    vtkInstantiator::RegisterInstantiator("fwVtkBoxRepresentation", vtkInstantiatorfwVtkBoxRepresentationNew);
    vtkInstantiator::RegisterInstantiator("fwVtkPicker", vtkInstantiatorfwVtkPickerNew);
    vtkInstantiator::RegisterInstantiator("fwVtkCellPicker", vtkInstantiatorfwVtkCellPickerNew);
    vtkInstantiator::RegisterInstantiator("InteractorStyle2DForNegato", vtkInstantiatorInteractorStyle2DForNegatoNew);
    vtkInstantiator::RegisterInstantiator("InteractorStyle3DForNegato", vtkInstantiatorInteractorStyle3DForNegatoNew);

#ifdef DEBUG
    vtkObject *o = vtkInstantiator::CreateInstance("fwVtkBoxRepresentation");
    SLM_ASSERT("Unable to instantiate a fwVtkBoxRepresentation",o);
    o->Delete();

    o = vtkInstantiator::CreateInstance("fwVtkPicker");
    SLM_ASSERT("Unable to instantiate a fwVtkPicker",o);
    o->Delete();

    o = vtkInstantiator::CreateInstance("fwVtkCellPicker");
    SLM_ASSERT("Unable to instantiate a fwVtkCellPicker",o);
    o->Delete();

    o = vtkInstantiator::CreateInstance("InteractorStyle2DForNegato");
    SLM_ASSERT("Unable to instantiate a InteractorStyle2DForNegato",o);
    o->Delete();

    o = vtkInstantiator::CreateInstance("InteractorStyle3DForNegato");
    SLM_ASSERT("Unable to instantiate a InteractorStyle3DForNegato",o);
    o->Delete();
#endif
}
Esempio n. 3
0
void Native::setBundle( const Bundle * bundle ) throw()
{
    // Pre-condition
    SLM_ASSERT("bundle already initialized", m_bundle == 0 );
    m_bundle = bundle;
    // Post-condition
    SLM_ASSERT("bundle not correctly attached", m_bundle == bundle );
}
    virtual void Execute( vtkObject *caller, unsigned long eventId, void *)
    {
        assert(m_priority>=0);
        SLM_ASSERT("m_adaptor not instanced", m_adaptor);
        SLM_ASSERT("m_picker not instanced", m_picker);

        this->process(vtkRenderWindowInteractor::SafeDownCast(caller), eventId);
    }
void ContainerBuilder::destroyContainer()
{
    SLM_ASSERT("Sorry, Container not initialized", m_container);
    SLM_ASSERT("Sorry, the parent container is not a QtContainer", m_parent);

    m_container->destroyContainer();
    m_parent->clean();
}
Esempio n. 6
0
bool App::OnInit()
{
    ::fwWX::LoggerInitializer::initialize();

    m_profile = ::fwRuntime::profile::getCurrentProfile();
    SLM_ASSERT("Profile is not initialized", m_profile);

#ifndef TDVPM_COMPLIANT
    m_locale = new wxLocale();
    ::boost::filesystem::path pathLauncher;
    pathLauncher = ::boost::filesystem::current_path() / "share" / "launcher_0-1" / "locale" ;

    wxLocale::AddCatalogLookupPathPrefix( ::fwWX::std2wx( pathLauncher.string() ));
    m_locale->Init(GetUILanguage());
    m_locale->AddCatalog(_T("launcher"));
    m_locale->AddCatalog(_T("runtime"));
    // Set the locale to C for all number of all application
    setlocale(LC_NUMERIC,"C");
#else
    setlocale(LC_ALL,"C");
#endif

    wxApp::OnInit();

    std::string appName = m_profile->getName();
#ifndef TDVPM_COMPLIANT
    m_locale->AddCatalog(::fwWX::std2wx(appName), wxLANGUAGE_FRENCH, _T("utf-8"));
#endif
    SetAppName( ::fwWX::std2wx(appName) );

    std::string checkerPath = ::fwTools::os::getUserDataDir("IRCAD", appName, true);

    if (checkerPath.empty())
    {
        checkerPath = ::fwTools::os::getUserDataDir("IRCAD", "", true);
    }
    if (checkerPath.empty())
    {
        checkerPath = ::fwTools::os::getUserDataDir("", "", true);
    }
    SLM_ASSERT("Unable to find user's data dir.", !checkerPath.empty());

    m_checker = new wxSingleInstanceChecker();
    if (m_profile->getCheckSingleInstance())
    {
        m_checker->Create( ::fwWX::std2wx(appName) + _(".pid"), ::fwWX::std2wx(checkerPath));
        if ( m_checker->IsAnotherRunning() )
        {
            wxLogError(_("Another " + ::fwWX::std2wx(appName) + _(" instance is already running, aborting.")));
            return false;
        }
    }

    // Initialize root object : root object, views, ...
    //::fwServices::RootManager::initializeRootObject();

    return TRUE;
}
Esempio n. 7
0
void SImageCenter::updating()
{

    ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_IMAGE_IN);
    ::fwData::mt::ObjectReadLock imLock(image);

    SLM_ASSERT("Missing image '"+ s_IMAGE_IN + "'", image);

    const bool imageValidity = ::fwDataTools::fieldHelper::MedicalImageHelpers::checkImageValidity(image);

    if(!imageValidity)
    {
        SLM_WARN("Can not compute center of a invalid image.");
        return;
    }

    ::fwData::TransformationMatrix3D::sptr matrix =
        this->getInOut< ::fwData::TransformationMatrix3D >(s_TRANSFORM_INOUT);

    SLM_ASSERT("Missing matrix '"+ s_TRANSFORM_INOUT +"'", matrix);

    ::fwData::mt::ObjectWriteLock matLock(matrix);

    ::fwDataTools::TransformationMatrix3D::identity(matrix);

    //compute the center
    const ::fwData::Image::SizeType size       = image->getSize();
    const ::fwData::Image::SpacingType spacing = image->getSpacing();
    const ::fwData::Image::OriginType origin   = image->getOrigin();

    SLM_ASSERT("Image should be in 3 Dimensions", size.size() == 3);

    std::vector<double> center(3, 0.);

    center[0] = (static_cast<double>(size[0]) * spacing[0]) / 2.;
    center[1] = (static_cast<double>(size[1]) * spacing[1]) / 2.;
    center[2] = (static_cast<double>(size[2]) * spacing[2]) / 2.;

    //compute origin -center

    center[0] += origin[0];
    center[1] += origin[1];
    center[2] += origin[2];

    matrix->setCoefficient(0, 3, center[0]);
    matrix->setCoefficient(1, 3, center[1]);
    matrix->setCoefficient(2, 3, center[2]);

    // output the translation matrix

    auto sig = matrix->signal< ::fwData::TransformationMatrix3D::ModifiedSignalType >
                   (::fwData::TransformationMatrix3D::s_MODIFIED_SIG);

    sig->asyncEmit();

    m_sigComputed->asyncEmit();
}
Esempio n. 8
0
void IFrameSrv::initialize()
{
    // find gui configuration
    std::vector < ConfigurationType > vectGui    = m_configuration->find("gui");
    std::vector < ConfigurationType > vectWindow = m_configuration->find("window");

    if(!vectGui.empty())
    {
        // find LayoutManager configuration
        std::vector < ConfigurationType > vectLayoutMng = vectGui.at(0)->find("frame");
        SLM_ASSERT("<frame> xml element must exist", !vectLayoutMng.empty());
        m_frameConfig = vectLayoutMng.at(0);
        this->initializeLayoutManager(m_frameConfig);

        // find menuBarBuilder configuration
        std::vector < ConfigurationType > vectMBBuilder = vectGui.at(0)->find("menuBar");
        if(!vectMBBuilder.empty())
        {
            m_menuBarConfig = vectMBBuilder.at(0);
            this->initializeMenuBarBuilder(m_menuBarConfig);

            m_hasMenuBar = true;
        }

        // find toolBarBuilder configuration
        std::vector < ConfigurationType > vectTBBuilder = vectGui.at(0)->find("toolBar");
        if(!vectTBBuilder.empty())
        {
            m_toolBarConfig = vectTBBuilder.at(0);
            this->initializeToolBarBuilder(m_toolBarConfig);

            m_hasToolBar = true;
        }
    }

    if(!vectWindow.empty())
    {
        ConfigurationType window = vectWindow.at(0);
        std::string onclose      = window->getAttributeValue("onclose");
        if ( !onclose.empty() )
        {
            m_closePolicy = onclose;
        }
        SLM_ASSERT("Invalid onclose value : " << m_closePolicy << ". Should be 'exit', 'notify' or 'message'",
                   m_closePolicy == CLOSE_POLICY_NOTIFY || m_closePolicy == CLOSE_POLICY_EXIT
                   || m_closePolicy == CLOSE_POLICY_MESSAGE);
    }

    m_viewRegistrar = ::fwGui::registrar::ViewRegistrar::New(this->getID());
    // find ViewRegistryManager configuration
    std::vector < ConfigurationType > vectRegistrar = m_configuration->find("registry");
    if(!vectRegistrar.empty())
    {
        m_registrarConfig = vectRegistrar.at(0);
        m_viewRegistrar->initialize(m_registrarConfig);
    }
}
Esempio n. 9
0
void SWriter::configuring() throw(::fwTools::Failed)
{
    ::io::IWriter::configuring();

    typedef SPTR(::fwRuntime::ConfigurationElement) ConfigurationElement;
    typedef std::vector < ConfigurationElement >    ConfigurationElementContainer;

    m_customExts.clear();
    m_allowedExtLabels.clear();

    ConfigurationElementContainer customExtsList = m_configuration->find("archive");
    BOOST_FOREACH(ConfigurationElement archive, customExtsList)
    {
        const std::string& backend = archive->getAttributeValue("backend");
        SLM_ASSERT("No backend attribute given in archive tag", backend != "");
        SLM_ASSERT("Unsupported backend '" + backend + "'",
                SReader::s_EXTENSIONS.find("." + backend) != SReader::s_EXTENSIONS.end());

        ConfigurationElementContainer exts = archive->find("extension");
        BOOST_FOREACH(ConfigurationElement ext, exts)
        {
            const std::string& extension = ext->getValue();
            SLM_ASSERT("No extension given for backend '" + backend + "'", !extension.empty());
            SLM_ASSERT("Extension must begin with '.'", extension[0] == '.');

            m_customExts[extension] = backend;
            m_allowedExtLabels[extension] = ext->getAttributeValue("label");
        }
    }

    ConfigurationElementContainer extensionsList = m_configuration->find("extensions");
    SLM_ASSERT("The <extensions> element can be set at most once.", extensionsList.size() <= 1);

    if(extensionsList.size() == 1)
    {
        m_allowedExts.clear();

        ConfigurationElementContainer extensions = extensionsList.at(0)->find("extension");
        BOOST_FOREACH(ConfigurationElement extension, extensions)
        {
            const std::string& ext = extension->getValue();

            // The extension must be found either in custom extensions list or in known extensions
            FileExtension2NameType::const_iterator itKnown = SReader::s_EXTENSIONS.find(ext);
            FileExtension2NameType::const_iterator itCustom = m_customExts.find(ext);

            const bool extIsKnown = (itKnown != SReader::s_EXTENSIONS.end() || itCustom != m_customExts.end());
            OSLM_ASSERT("Extension '" << ext << "' is not allowed in configuration", extIsKnown);

            if(extIsKnown)
            {
                m_allowedExts.insert(m_allowedExts.end(), ext);
                m_allowedExtLabels[ext] = extension->getAttributeValue("label");
            }
        }
    }
bool MedicalImageHelpers::checkImageSliceIndex( ::fwData::Image::sptr _pImg )
{
    SLM_ASSERT("_pImg pointer null", _pImg);

    bool fieldIsModified = false;

    const ::fwData::Image::SizeType &imageSize = _pImg->getSize();

    ::fwData::Integer::sptr axialIdx    = _pImg->getField< ::fwData::Integer >( ::fwComEd::Dictionary::m_axialSliceIndexId );
    ::fwData::Integer::sptr frontalIdx  = _pImg->getField< ::fwData::Integer >( ::fwComEd::Dictionary::m_frontalSliceIndexId);
    ::fwData::Integer::sptr sagittalIdx = _pImg->getField< ::fwData::Integer >( ::fwComEd::Dictionary::m_sagittalSliceIndexId );

    // Manage image landmarks
    if ( ! (axialIdx && frontalIdx && sagittalIdx) )
    {
        // Set value
        axialIdx = ::fwData::Integer::New(-1);
        _pImg->setField( ::fwComEd::Dictionary::m_axialSliceIndexId, axialIdx );

        frontalIdx = ::fwData::Integer::New(-1);
        _pImg->setField( ::fwComEd::Dictionary::m_frontalSliceIndexId, frontalIdx );

        sagittalIdx = ::fwData::Integer::New(-1);
        _pImg->setField( ::fwComEd::Dictionary::m_sagittalSliceIndexId, sagittalIdx );

        fieldIsModified = true;
    }


    SLM_ASSERT (
        "Information on image slice index is not correct, miss one of these fields : m_axialSliceIndexId, m_frontalSliceIndexId, m_sagittalSliceIndexId.",
        axialIdx && frontalIdx && sagittalIdx
    );

    // Get value
    if( axialIdx->value() < 0 ||  imageSize[2] < axialIdx->value() )
    {
        axialIdx->value() = static_cast< ::fwData::Integer::ValueType >(imageSize[2] / 2);
        fieldIsModified = true;
    }

    if( frontalIdx->value() < 0 ||  imageSize[1] < frontalIdx->value() )
    {
        frontalIdx->value() = static_cast< ::fwData::Integer::ValueType >(imageSize[1] / 2);
        fieldIsModified = true;
    }

    if( sagittalIdx->value() < 0 ||  imageSize[0] < sagittalIdx->value() )
    {
        sagittalIdx->value() = static_cast< ::fwData::Integer::ValueType >(imageSize[0] / 2);
        fieldIsModified = true;
    }


    return fieldIsModified;
}
Esempio n. 11
0
void XMLSubstitute::substitute( xmlNodePtr original, xmlNodePtr substitutionRules, std::map< std::string, std::string> &dictionary)
{
    std::list< ::fwRuntime::io::Substitute > substitutions = getSubstitutions( substitutionRules );

    for ( std::list< ::fwRuntime::io::Substitute >::iterator iter = substitutions.begin(); iter != substitutions.end(); ++iter )
    {
        std::string xpath = iter->xpath;
        std::string dictEntry = iter->dictEntry;
        std::string status = iter->status;
        bool entryInDictionary = dictionary.find(dictEntry) != dictionary.end();

        if ( status=="required" && !entryInDictionary )
        {
            OSLM_FATAL("XML substitution required dictEntry [" << dictEntry << "] missing for xpath " << xpath );
        }
        // optional and not in dictionary
        if ( status=="optional" && !entryInDictionary )
        {
            OSLM_INFO("XML substitution optional dictEntry [" << dictEntry << "] not modified for xpath " << xpath );
            continue;
        }

        OSLM_INFO("XML substitution dictEntry [" << dictEntry << "] modified with xpath " << xpath << " with the value : " <<  dictionary[dictEntry] );

        // create the context for xpath
        xmlXPathContextPtr xpathCtx;
        xpathCtx = xmlXPathNewContext(original->doc);
        SLM_ASSERT("xpathCtx not instanced", xpathCtx);
        // search
        xmlChar *xpathExpr= BAD_CAST xpath.c_str();
        xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
        SLM_ASSERT("xpathObj not instanced", xpathObj);

        int NbNodesFound = xpathObj->nodesetval->nodeNr;
        for (int i=NbNodesFound-1; i >= 0; --i )
        {
            xmlNodePtr node = xpathObj->nodesetval->nodeTab[i];
            // substitution
            if (node->type == XML_ATTRIBUTE_NODE )
            {
                xmlSetProp( node->parent, node->name, BAD_CAST dictionary[dictEntry].c_str() );
            }
            if (node->type == XML_ELEMENT_NODE )
            {
                xmlNodeSetName( node , BAD_CAST dictionary[dictEntry].c_str() );
            }
            if (node->type == XML_TEXT_NODE )
            {
                xmlNodeSetContent( node , BAD_CAST dictionary[dictEntry].c_str() );
            }
        }
        xmlXPathFreeObject(xpathObj );
    }
}
Esempio n. 12
0
void SMesh::updateCellColors()
{
    ::fwData::Mesh::csptr mesh = this->getInput < ::fwData::Mesh >(s_MESH_INPUT);
    SLM_ASSERT("Missing mesh", mesh);
    SLM_ASSERT("m_polyData not instanced", m_polyData);

    ::fwData::mt::ObjectReadLock lock(mesh);
    ::fwVtkIO::helper::Mesh::updatePolyDataCellColor(m_polyData, mesh);
    this->setVtkPipelineModified();
    this->requestRender();
}
Esempio n. 13
0
void ISlideViewBuilder::initialize( ::fwRuntime::ConfigurationElement::sptr configuration)
{
    SLM_ASSERT("Bad configuration name " + configuration->getName() + ", must be 'slideView'",
               configuration->getName() == "slideView");


    if (configuration->hasAttribute("align"))
    {
        std::string aligment = configuration->getExistingAttributeValue("align");
        if (aligment == "top")
        {
            m_aligment = TOP;
        }
        else if (aligment == "bottom")
        {
            m_aligment = BOTTOM;
        }
        else if (aligment == "right")
        {
            m_aligment = RIGHT;
        }
        else if (aligment == "left")
        {
            m_aligment = LEFT;
        }
        else
        {
            SLM_FATAL("Wrong value '"+ aligment +"' for 'align' attribute (require top, bottom, right or left)");
        }
    }

    if (configuration->hasAttribute("opacity"))
    {
        std::string opacity = configuration->getExistingAttributeValue("opacity");
        m_opacity = std::stod(opacity);
        SLM_ASSERT("Opacity must be in [0 - 1]; actual: " + opacity, m_opacity >= 0. && m_opacity <= 1.);
    }

    if (configuration->hasAttribute("size"))
    {
        std::string size = configuration->getExistingAttributeValue("size");
        m_size = std::stoi(size);
        SLM_ASSERT("Size must not be negative", m_size >= 0.);
    }

    ::fwRuntime::ConfigurationElement::csptr styleCfg = configuration->findConfigurationElement("styleSheet");
    if (styleCfg)
    {
        m_styleSheet = styleCfg->getValue();
    }
}
Esempio n. 14
0
    void operator()(Parameters& params)
    {
        typedef typename ::itk::Image< PIXELTYPE, 3 > ImageType;
        const typename ImageType::Pointer itkImage = ::fwItkIO::itkImageFactory< ImageType >(params.i_image);

        typename ::itk::ResampleImageFilter<ImageType, ImageType>::Pointer resampler =
            ::itk::ResampleImageFilter<ImageType, ImageType>::New();

        typename ::itk::MinimumMaximumImageCalculator< ImageType >::Pointer minCalculator =
            ::itk::MinimumMaximumImageCalculator< ImageType >::New();

        minCalculator->SetImage(itkImage);
        minCalculator->ComputeMinimum();
        resampler->SetDefaultPixelValue(minCalculator->GetMinimum());

        resampler->SetTransform(params.i_trf.GetPointer());
        resampler->SetInput(itkImage);

        typename ImageType::SizeType size           = itkImage->GetLargestPossibleRegion().GetSize();
        typename ImageType::PointType origin        = itkImage->GetOrigin();
        typename ImageType::SpacingType spacing     = itkImage->GetSpacing();
        typename ImageType::DirectionType direction = itkImage->GetDirection();

        SLM_ASSERT("Input spacing can't be null along any axis", spacing[0] > 0 && spacing[1] > 0 && spacing[2] > 0);

        if(params.i_targetImage)
        {
            for(std::uint8_t i = 0; i < 3; ++i)
            {
                // ITK uses unsigned long to store sizes.
                size[i] = static_cast<typename ImageType::SizeType::SizeValueType>(params.i_targetImage->getSize()[i]);

                origin[i]  = params.i_targetImage->getOrigin()[i];
                spacing[i] = params.i_targetImage->getSpacing()[i];

                SLM_ASSERT("Output spacing can't be null along any axis.", spacing[i] > 0);
            }
        }

        resampler->SetSize(size);
        resampler->SetOutputOrigin(origin);
        resampler->SetOutputDirection(direction);
        resampler->SetOutputSpacing(spacing);

        resampler->Update();

        typename ImageType::Pointer outputImage = resampler->GetOutput();

        ::fwItkIO::itkImageToFwDataImage(outputImage, params.o_image);
    }
    void stopSlicing()
    {
        SLM_TRACE("vtkEvent: MiddleButtonReleaseEvent");
        SLM_ASSERT("m_adaptor not instanced", m_adaptor);
        SLM_ASSERT("m_picker not instanced", m_picker);
        SLM_ASSERT("Slicing doesn't begun", m_mouseMoveObserved);

        m_adaptor->getInteractor()->RemoveObservers(vtkCommand::MouseMoveEvent, this);
        m_mouseMoveObserved = false;
        m_adaptor->stopSlicing();
        m_localPicker->Delete();
        m_localPicker = nullptr;
        m_pickedProp  = nullptr;
    }
Esempio n. 16
0
void fillContainer(T min, T max, CONTAINER& randContainer, ::boost::uint32_t seedVal = std::time(NULL))
{
    SLM_ASSERT("Wrong min/max value", min <= max);
    SLM_ASSERT("Container type not same as T", (::boost::is_same< T, typename CONTAINER::value_type>::value) );
    typedef typename ::boost::mpl::if_<
            ::boost::is_floating_point<T>,
            ::boost::uniform_real<>,
            ::boost::uniform_int<>
    >::type DistroType;

    ::boost::mt19937 seed(seedVal);
    DistroType dist(min, max);
    ::boost::variate_generator< ::boost::mt19937&, DistroType > random(seed, dist);
    std::generate(randContainer.begin(), randContainer.end(), random);
}
Esempio n. 17
0
void SMesh::updateVertex()
{
    ::fwData::Mesh::csptr mesh = this->getInput < ::fwData::Mesh >(s_MESH_INPUT);
    SLM_ASSERT("Missing mesh", mesh);
    SLM_ASSERT("m_polyData not instanced", m_polyData);

    ::fwData::mt::ObjectReadLock lock(mesh);
    ::fwVtkIO::helper::Mesh::updatePolyDataPoints(m_polyData, mesh);

    if (m_autoResetCamera)
    {
        this->getRenderer()->ResetCamera();
    }
    this->setVtkPipelineModified();
    this->requestRender();
}
Esempio n. 18
0
void SMesh::updating()
{
    ::fwData::Mesh::csptr mesh = this->getInput < ::fwData::Mesh >(s_MESH_INPUT);
    SLM_ASSERT("Missing mesh", mesh);
    this->updateMesh( mesh );
    this->requestRender();
}
Esempio n. 19
0
void SSeriesDBReader::updating() throw(::fwTools::Failed)
{
    SLM_TRACE_FUNC();
    if( this->hasLocationDefined() )
    {
        ::fwMedData::SeriesDB::sptr seriesDB = createSeriesDB( this->getFolder() );

        if( seriesDB->size() > 0 )
        {
            // Retrieve dataStruct associated with this service
            ::fwMedData::SeriesDB::sptr associatedSeriesDB = this->getObject< ::fwMedData::SeriesDB >();
            SLM_ASSERT("associated SeriesDB not instanced", associatedSeriesDB);
            associatedSeriesDB->shallowCopy( seriesDB ) ;

            ::fwGui::Cursor cursor;
            cursor.setCursor(::fwGui::ICursor::BUSY);
            this->notificationOfDBUpdate();
            cursor.setDefaultCursor();
        }
        else
        {
            ::fwGui::dialog::MessageDialog::showMessageDialog(
                    "Image Reader","This file can not be read. Retry with another file reader.",
                    ::fwGui::dialog::IMessageDialog::WARNING);
        }
    }
}
Esempio n. 20
0
void SAddLabeledPoint::updating()
{
    ::fwData::PointList::sptr landmarks = this->getInOut< ::fwData::PointList >(s_POINTLIST_INOUT);
    if (!landmarks)
    {
        FW_DEPRECATED_KEY(s_POINTLIST_INOUT, "inout", "18.0");
        landmarks = this->getObject< ::fwData::PointList >();
    }
    SLM_ASSERT("landmarks not instanced", landmarks);

    std::string value;
    if ( this->defineLabel(value) )
    {
        // create a new point
        ::fwData::Point::sptr newPoint = ::fwData::Point::New();

        // append to landmark
        landmarks->getPoints().push_back( newPoint );

        // append to point the label
        ::fwData::String::sptr label = ::fwData::String::New();
        label->value()               = value;
        newPoint->setField( ::fwDataTools::fieldHelper::Image::m_labelId, label );

        // notify
        auto sig =
            landmarks->signal< ::fwData::PointList::PointAddedSignalType >(::fwData::PointList::s_POINT_ADDED_SIG);
        {
            ::fwCom::Connection::Blocker block(sig->getConnection(m_slotUpdate));
            sig->asyncEmit(newPoint);
        }
    }
}
Esempio n. 21
0
bool SlideBar::eventFilter(QObject* obj, QEvent* event)
{
    // Update the widget position when the parent is moved or resized
    if (event->type() == QEvent::Resize
        || event->type() == QEvent::Move)
    {
        this->updatePosition();
    }
    else if (event->type() == QEvent::WindowActivate)
    {
        auto activeWindow = qApp->activeWindow();
        SLM_ASSERT("No active window", activeWindow);
        activeWindow->installEventFilter(this);
        this->updatePosition();
    }
    else if (event->type() == QEvent::WindowDeactivate)
    {
        auto mainFrame = dynamic_cast< ::fwGuiQt::QtMainFrame*>(obj);
        if(mainFrame)
        {
            mainFrame->removeEventFilter(this);
        }
    }
    return QObject::eventFilter(obj, event);
}
Esempio n. 22
0
void SQueryEditor::configuring()
{
    ::fwServices::IService::ConfigType configuration = this->getConfigTree();
    //Parse server port and hostname
    if(configuration.count("server"))
    {
        const std::string serverInfo               = configuration.get("server", "");
        const std::string::size_type splitPosition = serverInfo.find(':');
        SLM_ASSERT("Server info not formatted correctly", splitPosition != std::string::npos);

        const std::string hostnameStr = serverInfo.substr(0, splitPosition);
        const std::string portStr     = serverInfo.substr(splitPosition + 1, serverInfo.size());

        m_serverHostnameKey = this->getPreferenceKey(hostnameStr);
        m_serverPortKey     = this->getPreferenceKey(portStr);
        if(m_serverHostnameKey.empty())
        {
            m_serverHostname = hostnameStr;
        }
        if(m_serverPortKey.empty())
        {
            m_serverPort = std::stoi(portStr);
        }
    }
    else
    {
        throw ::fwTools::Failed("'server' element not found");
    }

    ::fwGui::IGuiContainerSrv::initialize();
}
Esempio n. 23
0
void GridFromFloat::configuring() throw ( ::fwTools::Failed )
{
    SLM_TRACE_FUNC();

    SLM_ASSERT("\"config\" tag missing", m_configuration->getName() == "config");

    this->IAdaptor::configuring();

    SLM_TRACE("IAdaptor configuring ok");

    // Set the x/y min/max values
    m_xMin = ::boost::lexical_cast< float >( m_configuration->getAttributeValue("xMin") );
    m_xMax = ::boost::lexical_cast< float >( m_configuration->getAttributeValue("xMax") );
    m_yMin = ::boost::lexical_cast< float >( m_configuration->getAttributeValue("yMin") );
    m_yMax = ::boost::lexical_cast< float >( m_configuration->getAttributeValue("yMax") );

    // If the corresponding attributes are present in the config, set the xSpacing, ySpacing between the lines and color of the lines
    if (!m_configuration->getAttributeValue("xSpacing").empty())
    {
        m_xSpacing = ::boost::lexical_cast< float >( m_configuration->getAttributeValue("xSpacing") );
    }
    if (!m_configuration->getAttributeValue("ySpacing").empty())
    {
        m_ySpacing = ::boost::lexical_cast< float >( m_configuration->getAttributeValue("ySpacing") );
    }
    if (!m_configuration->getAttributeValue("color").empty())
    {
        ::scene2D::data::InitQtPen::setPenColor(m_pen, m_configuration->getAttributeValue("color"));
    }
}
Esempio n. 24
0
void IAdaptor::setRenderService( SRender::sptr service)
{
    /// Preconditions
    SLM_ASSERT("service not instanced", service);

    m_renderService = service;
}
void IGuiContainerSrv::setParent(std::string wid)
{
    m_viewRegistrar->setParent(wid);
    ::fwGui::container::fwContainer::sptr parent = m_viewRegistrar->getParent();
    SLM_ASSERT("Parent container is unknown.", parent);
    m_containerBuilder->setParent(parent);
}
void SliceIndexPositionEditor::starting() throw(::fwTools::Failed)
{
    this->create();

    ::fwGuiQt::container::QtContainer::sptr qtContainer =  ::fwGuiQt::container::QtContainer::dynamicCast( this->getContainer() );
    QWidget * const container = qtContainer->getQtContainer();
    SLM_ASSERT("container not instanced", container);

    QVBoxLayout* layout = new QVBoxLayout( container );

    m_sliceSelectorPanel = new ::fwGuiQt::SliceSelector( container );
    m_sliceSelectorPanel->setEnable(false);

    ::fwGuiQt::SliceSelector::ChangeIndexCallback changeIndexCallback;
    changeIndexCallback = ::boost::bind( &::uiImage::SliceIndexPositionEditor::sliceIndexNotification, this, _1);
    m_sliceSelectorPanel->setChangeIndexCallback(changeIndexCallback);

    ::fwGuiQt::SliceSelector::ChangeIndexCallback changeTypeCallback;
    changeTypeCallback = ::boost::bind( &::uiImage::SliceIndexPositionEditor::sliceTypeNotification, this, _1);
    m_sliceSelectorPanel->setChangeTypeCallback(changeTypeCallback);
    layout->addWidget( m_sliceSelectorPanel );
    layout->setContentsMargins(0,0,0,0);

    ::fwData::Image::sptr image = this->getObject< ::fwData::Image >();
    this->updateImageInfos(image);
    this->updateSliceType(m_orientation);

    container->setLayout( layout );

    this->updating();
}
void LineLayoutManager::destroyLayout()
{
    this->destroySubViews();
    SLM_ASSERT("Parent container is not available.", m_parentContainer);
    wxWindow* wxContainer = m_parentContainer->getWxContainer();
    wxContainer->SetSizer(NULL);
}
Esempio n. 28
0
void PatientDBInfoEditor::starting() throw(::fwTools::Failed)
{
    SLM_TRACE_FUNC();
    this->::fwGui::IGuiContainerSrv::create();

    ::fwGuiQt::container::QtContainer::sptr qtContainer =  ::fwGuiQt::container::QtContainer::dynamicCast( this->getContainer() );
    QWidget* const container = qtContainer->getQtContainer();
    SLM_ASSERT("container not instanced", container);

    QVBoxLayout* layout = new QVBoxLayout();

    m_editorPanel = new QTreeWidget(container);
    m_editorPanel->setSelectionMode(QAbstractItemView::SingleSelection);
    m_editorPanel->setSelectionBehavior(QAbstractItemView::SelectRows);
    m_editorPanel->setColumnCount(2);
    m_editorPanel->setAlternatingRowColors( true );
    m_editorPanel->setColumnWidth(0,170);

    QStringList labels;
    labels << tr("Field") << tr("Value");
    m_editorPanel->setHeaderLabels(labels);

    layout->addWidget( m_editorPanel, 1);
    layout->setContentsMargins(0,0,0,0);
    container->setLayout( layout );

    this->updating();
}
void SSliceIndexDicomPullerEditor::triggerNewSlice()
{
    // DicomSeries
    ::fwMedData::DicomSeries::csptr dicomSeries = this->getInOut< ::fwMedData::DicomSeries >("series");
    SLM_ASSERT("DicomSeries should not be null !", dicomSeries);

    // Compute slice index
    std::size_t selectedSliceIndex = m_sliceIndexSlider->value() + dicomSeries->getFirstInstanceNumber();
    OSLM_TRACE("triggered new slice : " << selectedSliceIndex);
    if(!dicomSeries->isInstanceAvailable(selectedSliceIndex))
    {
        if(m_pacsConfiguration)
        {
            m_pullSeriesWorker->post(std::bind(&::ioPacs::SSliceIndexDicomPullerEditor::pullInstance, this));
        }
        else
        {
            SLM_ERROR("There is no instance available for selected slice index.");
        }
    }
    else
    {
        //m_slotReadImage->asyncRun(selectedSliceIndex);
        this->readImage(selectedSliceIndex);
    }
}
void JpgPatientDBReaderService::updating() throw(::fwTools::Failed)
{
    SLM_TRACE_FUNC();
    if( this->hasLocationDefined() )
    {
        ::fwData::PatientDB::sptr patientDB = createPatientDB( this->getFolder() );

        if( patientDB->getNumberOfPatients() > 0 )
        {
            // Retrieve dataStruct associated with this service
            ::fwData::PatientDB::sptr associatedPatientDB = this->getObject< ::fwData::PatientDB >();
            SLM_ASSERT("associatedPatientDB not instanced", associatedPatientDB);

            associatedPatientDB->shallowCopy( patientDB );

            ::fwGui::Cursor cursor;
            cursor.setCursor(::fwGui::ICursor::BUSY);
            notificationOfDBUpdate();
            cursor.setDefaultCursor();
        }
        else
        {
            ::fwGui::dialog::MessageDialog::showMessageDialog("Image Reader",
                    "File format unknown. Retry with another file reader.",
                    ::fwGui::dialog::IMessageDialog::WARNING);
        }
    }
}