void SMesh::configuring() { this->configureParams(); const ConfigType config = this->getConfigTree().get_child("config.<xmlattr>"); const std::string color = config.get<std::string>("color", "#ffffffff"); const std::string unclippedColor = config.get<std::string>("unclippedcolor", "#aaaaff44"); m_material->diffuse()->setRGBA(color); m_unclippedPartMaterial->diffuse()->setRGBA(unclippedColor); const std::string autoresetcamera = config.get<std::string>("autoresetcamera", "yes"); SLM_ASSERT("'autoresetcamera' must be 'yes' or 'no'", autoresetcamera == "yes" || autoresetcamera == "no"); m_autoResetCamera = (autoresetcamera == "yes"); const std::string uvGen = config.get<std::string>("uvgen", "none"); if(uvGen == "none") { m_uvgen = NONE; } else if(uvGen == "sphere") { m_uvgen = SPHERE; } else if(uvGen == "cylinder") { m_uvgen = CYLINDER; } else if(uvGen == "plane") { m_uvgen = PLANE; } else { SLM_FATAL("'uvgen' value must be 'none', 'sphere', 'cylinder' or 'plane', actual: " + uvGen); } if (config.count("texture")) { SLM_FATAL("'texture' is deprecated, you need to connect manually the SMesh::textureApplied signal to the " "STexture::applyTexture slot."); } if (config.count("shadingMode")) { const std::string shading = config.get<std::string>("shadingMode"); const ::fwData::Material::ShadingType shadingMode = (shading == "ambient") ? ::fwData::Material::AMBIENT : (shading == "flat") ? ::fwData::Material::FLAT : (shading == "gouraud") ? ::fwData::Material::GOURAUD : ::fwData::Material::PHONG; m_material->setShadingMode(shadingMode); } this->setClippingPlanesId(config.get<std::string>("clippingplane", "")); }
void SliceIndexPositionEditor::configuring() throw(fwTools::Failed) { this->initialize(); if( this->m_configuration->size() > 0 ) { ::fwRuntime::ConfigurationElementContainer::Iterator iter = this->m_configuration->begin() ; SLM_ASSERT("Sorry, only one xml element \"sliceIndex\" is accepted.", this->m_configuration->size() == 1 && (*iter)->getName() == "sliceIndex" ); SLM_ASSERT("Sorry, xml element \"sliceIndex\" is empty.", ! (*iter)->getValue().empty() ); std::string orientation = (*iter)->getValue(); ::boost::algorithm::trim(orientation); ::boost::algorithm::to_lower(orientation); if(orientation == "axial" ) { m_orientation = Z_AXIS; } else if(orientation == "frontal" ) { m_orientation = Y_AXIS; } else if(orientation == "sagittal" ) { m_orientation = X_AXIS; } else { SLM_FATAL("The value for the xml element \"sliceIndex\" can only be axial, frontal or sagittal."); } } }
void SPlaneSlicer::configuring() { const auto& srvConf = this->getConfigTree(); const auto& config = srvConf.get_child("config.<xmlattr>"); const std::string& orientation = config.get<std::string>("orientation", ""); if(orientation == "axial") { m_orientation = ::fwDataTools::helper::MedicalImageAdaptor::Orientation::Z_AXIS; } else if(orientation == "sagittal") { m_orientation = ::fwDataTools::helper::MedicalImageAdaptor::Orientation::X_AXIS; } else if(orientation == "frontal") { m_orientation = ::fwDataTools::helper::MedicalImageAdaptor::Orientation::Y_AXIS; } else { SLM_FATAL("Unknown orientation: '" + orientation + "'."); } }
void PSAFromPDBSelectorUpdaterSrv::configuring() throw ( ::fwTools::Failed ) { SLM_TRACE_FUNC(); ::fwRuntime::ConfigurationElementContainer handleEvents = m_configuration->findAllConfigurationElement("update"); SLM_ASSERT("Problem with configuration for PSAFromPDBSelectorUpdaterSrv type, missing element \"update\"", handleEvents.size() != 0 ); OSLM_DEBUG( "handleEvents.size() = " << handleEvents.size() ); m_psaManagedEvents.clear(); for( ::fwRuntime::ConfigurationElementContainer::Iterator item = handleEvents.begin(); item != handleEvents.end(); ++item ) { SLM_FATAL_IF( "Sorry, attribute \"patientKey\" is missing", !(*item)->hasAttribute("patientKey") ); std::string patientKey = (*item)->getExistingAttributeValue("patientKey"); SLM_FATAL_IF( "Sorry, attribute \"studyKey\" is missing", !(*item)->hasAttribute("studyKey") ); std::string studyKey = (*item)->getExistingAttributeValue("studyKey"); SLM_FATAL_IF( "Sorry, attribute \"acquisitionKey\" is missing", !(*item)->hasAttribute("acquisitionKey") ); std::string acquisitionKey = (*item)->getExistingAttributeValue("acquisitionKey"); SLM_FATAL_IF( "Sorry, attribute \"patientNameKey\" is missing", !(*item)->hasAttribute("patientNameKey") ); std::string patientNameKey = (*item)->getExistingAttributeValue("patientNameKey"); SLM_FATAL_IF( "Sorry, attribute \"patientInfoKey\" is missing", !(*item)->hasAttribute("patientInfoKey") ); std::string patientInfoKey = (*item)->getExistingAttributeValue("patientInfoKey"); SLM_FATAL_IF( "Sorry, attribute \"onEvent\" is missing", !(*item)->hasAttribute("onEvent") ); std::string onEvent = (*item)->getExistingAttributeValue("onEvent"); SLM_FATAL_IF( "Sorry, attribute \"fromUID\" is missing", !(*item)->hasAttribute("fromUID") ); std::string fromUID = (*item)->getExistingAttributeValue("fromUID"); SLM_FATAL_IF( "Sorry, attribute \"actionType\" is missing", !(*item)->hasAttribute("actionType") ); std::string actionType = (*item)->getExistingAttributeValue("actionType"); ActionType action; if ( actionType == "ADD" ) { action = ADD; } else if ( actionType == "SWAP" ) { action = SWAP; } else if ( actionType == "REMOVE" ) { action = REMOVE; } else if ( actionType == "ADD_OR_SWAP" ) { action = ADD_OR_SWAP; } else if ( actionType == "REMOVE_IF_PRESENT" ) { action = REMOVE_IF_PRESENT; } else if ( actionType == "DO_NOTHING" ) { action = DO_NOTHING; } else { SLM_FATAL("Sorry this type of \"actionType\" is not managed by PSAFromPDBSelectorUpdaterSrv type"); } OSLM_INFO( "Manage event "<< onEvent <<" from this object "<< fromUID <<" and "<< actionType << " "<< patientKey << " " << studyKey << " " << acquisitionKey << " " << patientNameKey << " in my composite."); PSAManagedEvent managedEvent (onEvent, fromUID, patientKey, studyKey, acquisitionKey, patientNameKey, patientInfoKey, action); m_psaManagedEvents.push_back( managedEvent ); addNewHandledEvent( onEvent ); } }
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(); } }
void bt_sighandler(int sig, siginfo_t *info, void *secret) { void *trace[16]; char **messages = (char **)NULL; int i, trace_size = 0; ucontext_t *uc = (ucontext_t *)secret; std::stringstream ss; ss << "Got signal " << sig; /* Do something useful with siginfo_t */ if (sig == SIGSEGV) { ss << " faulty address is " << info->si_addr; #ifndef __MACOSX__ ss << " from " << uc->uc_mcontext.gregs[REG_EIP]; #endif } ss << std::endl; trace_size = backtrace(trace, 16); /* overwrite sigaction with caller's address */ #ifndef __MACOSX__ trace[1] = (void *) uc->uc_mcontext.gregs[REG_EIP]; #endif messages = backtrace_symbols(trace, trace_size); /* skip first stack frame (points here) */ ss << " [bt] Execution path:" << std::endl; for (i = 1; i<trace_size; ++i) { ss << " [bt] " << decode(messages[i]) << std::endl; } if (sig == SIGSEGV) { SLM_FATAL("SIGSEV signal " + ss.str() ); exit(0); } else { SLM_ERROR("SIGUSR1 signal " + ss.str() ); } }
void SSnapshot::snap(std::string filePath) { SLM_ASSERT("filePath is empty", !filePath.empty()); namespace fs = ::boost::filesystem; fs::path pathImageSnap(filePath); std::string ext = ".jpg"; ext = pathImageSnap.extension().string(); vtkImageWriter* writer = 0; if( ext == ".jpg" || ext == ".jpeg" ) { writer = vtkJPEGWriter::New(); } else if ( ext == ".bmp" ) { writer = vtkBMPWriter::New(); } else if ( ext == ".tiff" ) { writer = vtkTIFFWriter::New(); } else if ( ext == ".png" ) { writer = vtkPNGWriter::New(); } else { SLM_FATAL("Error: Format is not supported."); } vtkWindowToImageFilter* snapper = vtkWindowToImageFilter::New(); snapper->SetMagnification( 1 ); snapper->SetInput( this->getRenderer()->GetRenderWindow() ); writer->SetInputConnection( snapper->GetOutputPort() ); writer->SetFileName( pathImageSnap.string().c_str() ); writer->Write(); snapper->Delete(); writer->Delete(); }
void Object::shallowCopy(const ::fwData::Object::csptr& source ) { FwCoreNotUsedMacro(source); SLM_FATAL("shallowCopy not implemented for : " + this->getClassname() ); }
::boost::shared_ptr<Bundle> BundleDescriptorReader::processPlugin(xmlNodePtr node, const ::boost::filesystem::path& location) throw(RuntimeException) { // Creates the bundle. ::boost::shared_ptr<Bundle> bundle; // Processes all plugin attributes. xmlAttrPtr curAttr; std::string bundleIdentifier; std::string version; std::string pluginClass; for(curAttr = node->properties; curAttr != 0; curAttr = curAttr->next) { if(xmlStrcmp(curAttr->name, (const xmlChar*) ID.c_str()) == 0) { bundleIdentifier = (const char*) curAttr->children->content; continue; } if(xmlStrcmp(curAttr->name, (const xmlChar*) CLASS.c_str()) == 0) { pluginClass = (const char*) curAttr->children->content; continue; } if(xmlStrcmp(curAttr->name, (const xmlChar*) VERSION.c_str()) == 0) { version = (const char*) curAttr->children->content; continue; } } SLM_ASSERT("bundle identifier is empty", !bundleIdentifier.empty()); if( ::fwRuntime::Runtime::getDefault()->findBundle(bundleIdentifier, Version(version))) { return bundle; } if(pluginClass.empty() == true) { bundle = ::boost::shared_ptr<Bundle>( new Bundle(location, bundleIdentifier, version) ); } else { bundle = ::boost::shared_ptr<Bundle>( new Bundle(location, bundleIdentifier, version, pluginClass) ); } // Processes all child nodes. xmlNodePtr curChild; for(curChild = node->children; curChild != 0; curChild = curChild->next) { // Skip non element nodes. if(curChild->type != XML_ELEMENT_NODE) { continue; } // Extension declaration. if(xmlStrcmp(curChild->name, (const xmlChar*) EXTENSION.c_str()) == 0) { ::boost::shared_ptr<Extension> extension(processExtension(curChild, bundle)); bundle->addExtension(extension); continue; } // Extension point declaration. if(xmlStrcmp(curChild->name, (const xmlChar*) EXTENSION_POINT.c_str()) == 0) { ::boost::shared_ptr<ExtensionPoint> point(processExtensionPoint(curChild, bundle)); bundle->addExtensionPoint(point); continue; } // Library declaration. if(xmlStrcmp(curChild->name, (const xmlChar*) LIBRARY.c_str()) == 0) { ::boost::shared_ptr<dl::Library> library(processLibrary(curChild)); bundle->addLibrary(library); continue; } // Requirement declaration. if(xmlStrcmp(curChild->name, (const xmlChar*) REQUIREMENT.c_str()) == 0) { const std::string requirement(processRequirement(curChild)); bundle->addRequirement(requirement); } // Point declaration. if(xmlStrcmp(curChild->name, (const xmlChar*) POINT.c_str()) == 0) { SLM_FATAL("Sorry, this xml element ( <point ... > </point> ) is depreciated (" + location.string() + ")" ); } } // Job's done. return bundle; }
static void notifyFrameFetched(JNIEnv *env, jobject thiz, int id, jbyteArray data) { SLM_TRACE_FUNC(); if (current_camera == NULL) { SLM_FATAL(" current_camera == NULL"); } else { jboolean isCopy; jbyte* data_ptr = env->GetByteArrayElements(data, &isCopy); unsigned char* argb = new unsigned char[g_width * g_height * 4 * sizeof(unsigned char)]; int size = g_width * g_height; int v_offset = size; int u_offset = size +1; int y1_1,y1_2,y1_3,y1_4; int y2_1,y2_2,y2_3,y2_4; int y3_1,y3_2,y3_3,y3_4; int y4_1,y4_2,y4_3,y4_4; int u_1,u_2,u_3,u_4; int v_1,v_2,v_3,v_4; for(int i = 0, k = 0; i < size; i += 8, k += 8) { //----------------------------------------------------------------------------- // indexes //----------------------------------------------------------------------------- int id1 = i; int id2 = i+2; int id3 = i+4; int id4 = i+6; int k1 = k; int k2 = k+2; int k3 = k+4; int k4 = k+6; //----------------------------------------------------------------------------- // yuv components //----------------------------------------------------------------------------- // index 1 y1_1 = data_ptr[id1 ]&0xff; y2_1 = data_ptr[id1+1]&0xff; y3_1 = data_ptr[g_width+id1 ]&0xff; y4_1 = data_ptr[g_width+id1+1]&0xff; u_1 = data_ptr[u_offset + k1]&0xff; v_1 = data_ptr[v_offset + k1]&0xff; u_1 -= 128; v_1 -= 128; // index 2 y1_2 = data_ptr[id2 ]&0xff; y2_2 = data_ptr[id2+1]&0xff; y3_2 = data_ptr[g_width+id2 ]&0xff; y4_2 = data_ptr[g_width+id2+1]&0xff; u_2 = data_ptr[u_offset + k2]&0xff; v_2 = data_ptr[v_offset + k2]&0xff; u_2 -= 128; v_2 -= 128; //index 3 y1_3 = data_ptr[id3 ]&0xff; y2_3 = data_ptr[id3+1]&0xff; y3_3 = data_ptr[g_width+id3 ]&0xff; y4_3 = data_ptr[g_width+id3+1]&0xff; u_3 = data_ptr[u_offset + k3]&0xff; v_3 = data_ptr[v_offset + k3]&0xff; u_3 -= 128; v_3 -= 128; //index 4 y1_4 = data_ptr[id4 ]&0xff; y2_4 = data_ptr[id4+1]&0xff; y3_4 = data_ptr[g_width+id4 ]&0xff; y4_4 = data_ptr[g_width+id4+1]&0xff; u_4 = data_ptr[u_offset + k4]&0xff; v_4 = data_ptr[v_offset + k4]&0xff; u_4 = u_4 - 128; v_4 = v_4 - 128; //----------------------------------------------------------------------------- // Convert to rgb //----------------------------------------------------------------------------- convertYUVtoRGB(y1_1, u_1, v_1, id1*4, argb); convertYUVtoRGB(y2_1, u_1, v_1, (id1+1)*4, argb); convertYUVtoRGB(y3_1, u_1, v_1, (g_width+id1)*4, argb); convertYUVtoRGB(y4_1, u_1, v_1, (g_width+id1+1)*4, argb); convertYUVtoRGB(y1_2, u_2, v_2, (id2)*4, argb); convertYUVtoRGB(y2_2, u_2, v_2, (id2+1)*4, argb); convertYUVtoRGB(y3_2, u_2, v_2, (g_width+id2)*4, argb); convertYUVtoRGB(y4_2, u_2, v_2, (g_width+id2+1)*4, argb); convertYUVtoRGB(y1_3, u_3, v_3, (id3)*4, argb); convertYUVtoRGB(y2_3, u_3, v_3, (id3+1)*4, argb); convertYUVtoRGB(y3_3, u_3, v_3, (g_width+id3)*4, argb); convertYUVtoRGB(y4_3, u_3, v_3, (g_width+id3+1)*4, argb); convertYUVtoRGB(y1_4, u_4, v_4, (id4)*4, argb); convertYUVtoRGB(y2_4, u_4, v_4, (id4+1)*4, argb); convertYUVtoRGB(y3_4, u_4, v_4, (g_width+id4)*4, argb); convertYUVtoRGB(y4_4, u_4, v_4, (g_width+id4+1)*4, argb); //----------------------------------------------------------------------------- if (i!=0 && (i+8)%g_width==0) { i += g_width; } } // call the fechFrame method to emit signal current_camera->fetchFrame(argb); env->ReleaseByteArrayElements(data, data_ptr, JNI_ABORT); } }