Esempio n. 1
0
BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
	for (uint32 i = 0; i < _surfaces.size(); i++) {
		if (scumm_stricmp(_surfaces[i]->getFileName(), filename.c_str()) == 0) {
			_surfaces[i]->_referenceCount++;
			return _surfaces[i];
		}
	}

	if (!BaseFileManager::getEngineInstance()->hasFile(filename)) {
		if (filename.size()) {
			_gameRef->LOG(0, "Missing image: '%s'", filename.c_str());
		}
		if (_gameRef->_debugDebugMode) {
			return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
		} else {
			return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
		}
	}

	BaseSurface *surface;
	surface = _gameRef->_renderer->createSurface();

	if (!surface) {
		return NULL;
	}

	if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) {
		delete surface;
		return NULL;
	} else {
		surface->_referenceCount = 1;
		_surfaces.push_back(surface);
		return surface;
	}
}
/**
 * Draws all game objects in screenObjects to the screen
 * screenObjects vector is only the object container
 * on the other hand objectSurfaces vector holds loaded images so as to
 * reduce system load every time. 
 */
bool GraphicsEngine::drawGameObjects(){
	if(screenObjects.size()==0)
		return false;
	for(int i=0;i<screenObjects.size();i++){
    	GameObject* temp=screenObjects[i];
    	if(!temp->isAnimating()){
    		addSurface(temp->getCords()->getX(),temp->getCords()->getY(),objectSurfaces[i],screen); 	
		}
		else{
    		addSurface(temp->getCords()->getX(),temp->getCords()->getY(),&objectSurfaces[i][reinterpret_cast<AnimatingGameObject *> (temp)->getAnimation()->getCurrentState()],screen);
		}
	}
	return true;	
}
void Installer<UserData>::install(DetElement component, PlacedVolume pv)   {
  Volume comp_vol = pv.volume();
  if ( comp_vol.isSensitive() )  {  
    Volume mod_vol = parentVolume(component);
    DD4hep::Geometry::PolyhedraRegular comp_shape(comp_vol.solid()), mod_shape(mod_vol.solid());

    if ( !comp_shape.isValid() || !mod_shape.isValid() )   {
      invalidInstaller("Components and/or modules are not Trapezoid -- invalid shapes");
    }
    else if ( !handleUsingCache(component,comp_vol) )  {
      DetElement par = component.parent();
      const TGeoHMatrix& m = par.worldTransformation();
      double dz = m.GetTranslation()[2];
      const double* trans = placementTranslation(component);
      double half_mod_thickness  = (mod_shape->GetZ(1)-mod_shape->GetZ(0))/2.0;
      double half_comp_thickness = (comp_shape->GetZ(1)-comp_shape->GetZ(0))/2.0;
      double si_position         = trans[2]+half_mod_thickness;
      double outer_thickness = half_mod_thickness - si_position;
      double inner_thickness = half_mod_thickness + si_position;
      Vector3D u(1.,0.,0.), v(0.,1.,0.), n(0.,0.,1.), o(100.,100.,0.);
      std::cout << " Module:    " << mod_shape.toString() << std::endl;
      std::cout << " Component: " << comp_shape.toString() << std::endl;
      std::cout << "dz:" << dz << " Si-pos:" << si_position 
                << " Mod-thickness:" << half_mod_thickness 
                << " Comp-thickness:" << half_comp_thickness 
                << std::endl;
      VolPlane surf(comp_vol,Type(Type::Sensitive,Type::Measurement1D),
                    inner_thickness, outer_thickness, u, v, n, o);
      addSurface(component,surf);
    }
  }
}
/**
 * Redraws the game objects to the screen
 * Last part of the game loop
 */
bool GraphicsEngine::refreshScreen(){
	uint start=SDL_GetTicks();
	addSurface(0,0,background,screen);
	(this->*funcToCall)();
	refreshTime=SDL_GetTicks()-start;
	return SDL_Flip(screen)!= -1;
}
Esempio n. 5
0
	void Sampler::addInParam ( 
        StreamWriter* sw, 
        std::vector<COLLADASW::Annotation>* surfaceAnnotations /*= 0*/, 
        std::vector<COLLADASW::Annotation>* samplerAnnotations /*= 0*/ ) const
	{
		if ( sw->getCOLLADAVersion() == StreamWriter::COLLADA_1_4_1 )
		{
			// Add the surface <newparam>
			ParamSurfaceType paramSurface ( sw );
			paramSurface.openParam ( mSurfaceSid );
            if ( surfaceAnnotations ) paramSurface.addAnnotations ( *surfaceAnnotations );
			addSurface ( sw );
			paramSurface.closeParam ();

			// Add the sampler <newparam>
			ParamSamplerType paramSampler ( sw );
			paramSampler.openParam ( mSamplerSid );
            if ( samplerAnnotations ) paramSampler.addAnnotations ( *samplerAnnotations );
			add_1_4_1 ( sw, mSurfaceSid );
			paramSampler.closeParam ();
		}
		else if ( sw->getCOLLADAVersion() == StreamWriter::COLLADA_1_5_0 )
		{
			// Add the sampler <newparam>
			ParamSamplerType paramSampler ( sw );
			paramSampler.openParam ( mSamplerSid );
            if ( surfaceAnnotations ) paramSampler.addAnnotations ( *surfaceAnnotations );
            if ( samplerAnnotations ) paramSampler.addAnnotations ( *samplerAnnotations );
			add_1_5_0( sw );
			paramSampler.closeParam ();
		}
	}
Esempio n. 6
0
NavigationScene::NavigationScene(NeverhoodEngine *vm, Module *parentModule, uint32 navigationListId, int navigationIndex, const byte *itemsTypes)
	: Scene(vm, parentModule), _itemsTypes(itemsTypes), _navigationIndex(navigationIndex), _smackerDone(false),
	_isWalkingForward(false), _isTurning(false), _smackerFileHash(0), _interactive(true), _leaveSceneAfter(false) {

	_navigationList = _vm->_staticData->getNavigationList(navigationListId);
	
	if (_navigationIndex < 0) {
		_navigationIndex = (int)getGlobalVar(V_NAVIGATION_INDEX);
		if (_navigationIndex >= (int)_navigationList->size())
			_navigationIndex = 0; 
	}
	setGlobalVar(V_NAVIGATION_INDEX, _navigationIndex);
	
	SetUpdateHandler(&NavigationScene::update);
	SetMessageHandler(&NavigationScene::handleMessage);
	
	_smackerPlayer = new SmackerPlayer(_vm, this, (*_navigationList)[_navigationIndex].fileHash, true, true);	
	addEntity(_smackerPlayer);
	addSurface(_smackerPlayer->getSurface());
	
	createMouseCursor();

	_vm->_screen->clear();
	_vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());

	sendMessage(_parentModule, 0x100A, _navigationIndex);

}
Esempio n. 7
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    m_piechart=new Cpiechart;
    m_histogram=new Chistogram;
    m_linechart=new Clinechart;


    RealTimeDemo * realTimeDemo= new RealTimeDemo;

    ui->tabWidget->clear();
    ui->tabWidget->addTab(m_piechart,"饼图");
    ui->tabWidget->addTab(m_histogram,"柱状图");
    ui->tabWidget->addTab(m_linechart,"折线图");
    ui->tabWidget->addTab(addAngularMeter(),"角表");
    ui->tabWidget->addTab(addSurface(),"表面能量密度-3D");
    //  ui->tabWidget->addTab(realTimeDemo,"realTimeDemo");
    ui->tabWidget->addTab(addLineWithErrorSymbols(),"LineWithErrorSymbols");
    ui->tabWidget->addTab(addSwapXY(),"swapXY");

    ui->tabWidget->addTab(addLinearMeters(),"温度计");
    ui->tabWidget->addTab(addPyramid(),"金字塔");
    ui->tabWidget->addTab(addPolar(),"雷达图");
}
/**
 * Draws all widgets to the screen..
 */
void GraphicsEngine::drawWidgets(){
	for(int i=0;i<widgets.size();i++){
		Widget* temp=widgets[i];
		temp->updateSurface();
		addSurface(temp->getCords()->getX(),temp->getCords()->getY(),temp->getSurface(),screen);
	}
}
Esempio n. 9
0
/// Get a surface by its name. It will be created if it does not yet exist
UIWindow* UICanvas::operator[](const String& name)
{
	UIWindow* surface = getLayer(name);
	if(!surface)
	{
		surface = addSurface(name);
	}

	return surface;
}
Esempio n. 10
0
/**
 * @brief Loads Bitmap Fonts Images from Files
 * @param fontName
 * @return
 */
bool SurfaceManager::loadBitmapFontImage()
{
    std::string path = getFontPath();
    path.append(m_currentFont);

    std::cout << "loading Font -> : " << path << std::endl;

    // Loading Bitmap first time, or reloading,  If already Exists remove it.
    if(surfaceExists(SURFACE_FONT))
    {
        delSurface(SURFACE_FONT);
    }

    // Load the Font into the Surface.
    surface_ptr fontSurface(
        new Surfaces(
            SDL_LoadBMP(path.c_str())
        )
    );

    if(!fontSurface->exists())
    {
        SDL_Log("loadBitmapImage() fontSurface font: %s", path.c_str());
        SDL_Delay(1500);
        assert(false);
    }

    // Convert and Add to Surface Manager.
    if(!fontSurface->convert())
    {
        SDL_Log("Error Converting Font Surface!");
        return false;
    }
    addSurface(SURFACE_FONT, fontSurface);

    return true;
    /*
     * WIP, Implement this!
     */
    /*
       // Redraw Cursor with new font!
       // When no data received, this is when we want to show the cursor!
       // Setup cursor in current x/y position Cursor.
       if(TheSequenceParser::Instance()->isCursorActive())
       {
           setupCursorChar();
           renderCursorOnScreen();
           drawTextureScreen();
       }

       m_previousFont = m_currentFont; // Current to Previous
       m_currentFont  = fontName;    // New to Current.
       return m_cachedSurface != nullptr;*/
}
SurfaceSet::SurfaceSet(QString filename, QString consname, QString labelname)
{
    qDebug() << "loading surface set: " << filename << " connections: " << consname << " labelname: " << labelname;

    QFile n(filename);
    if (!n.open(QIODevice::ReadOnly)) qDebug("set file unreadable");
    QTextStream ns(&n);
    QString nl;
    //TODO: Windows will have a problem with this
    QString trunk = QFileInfo(filename).path();
    while(!ns.atEnd()){
        nl = ns.readLine();
        if (!nl.startsWith("#")){
            QStringList sl = nl.split(" ");
            QString fullname = trunk+QDir::separator()+sl.at(0);
            float x = 0;
            float y = 0;
            float z = 0;
            if (sl.length()>1) x = sl.at(1).toFloat();
            if (sl.length()>2) y = sl.at(2).toFloat();
            if (sl.length()>3) z = sl.at(3).toFloat();
            QVector3D s(x,y,z);
            qDebug() << "adding Surface: " << fullname << " shift: " << s;
            addSurface(fullname,labelname, s);
        }
    }

    qDebug() << "surfaces added";

    cs = 0;
    colorsFrom = 0;
    geo = 0;
    norm = 0.5;
    glyphAlpha = 1;
    glyphRadius = 1;
    threshold = 1;
    minlength = 0;
    clear_depth = false;
    vectors = false;
    billboarding = false;
    size = 2.0;

    roi = new QSet<int>;

    displayList = NULL;
    updateDisplayList = false;

    selected = new QVector3D(0,0,0);
    selectedIndex = 0;

    qDebug() << "SurfaceSet done...";
}
Esempio n. 12
0
DiskplayerScene::DiskplayerScene(NeverhoodEngine *vm, Module *parentModule, int paletteIndex)
	: Scene(vm, parentModule), _diskIndex(0), _appearCountdown(0), _tuneInCountdown(0),
	_hasAllDisks(false), _dropKey(false), _inputDisabled(true), _updateStatus(kUSStopped) { 

	int availableDisksCount = 0;
	
	setBackground(0x8A000044);
	setPalette(kDiskplayerPaletteFileHashes[paletteIndex]);

	_ssPlayButton = insertSprite<DiskplayerPlayButton>(this);
	addCollisionSprite(_ssPlayButton);

	_asKey = insertSprite<AsDiskplayerSceneKey>();

	for (int i = 0; i < 20; i++) {
		_diskAvailable[i] = false;
		if (getSubVar(VA_IS_TAPE_INSERTED, i))
			availableDisksCount++;
	}

	for (int i = 0; i < availableDisksCount; i++)
		_diskAvailable[kDiskplayerInitArray[i] - 1] = true;

	for (int slotIndex = 0; slotIndex < 20; slotIndex++) {
		_diskSlots[slotIndex] = new DiskplayerSlot(_vm, this, slotIndex, _diskAvailable[slotIndex]);
		addEntity(_diskSlots[slotIndex]);
	}

	_hasAllDisks = availableDisksCount == 20;
	
	if (_hasAllDisks && !getGlobalVar(V_HAS_FINAL_KEY))
		_dropKey = true;

	_finalDiskSlot = new DiskplayerSlot(_vm, this, 20, false);
	addEntity(_finalDiskSlot);

	insertPuzzleMouse(0x000408A8, 20, 620);
	showMouse(false);

	_diskSmackerPlayer = new SmackerPlayer(_vm, this, 0x08288103, false, true);
	addEntity(_diskSmackerPlayer);
	addSurface(_diskSmackerPlayer->getSurface());
	_diskSmackerPlayer->setDrawPos(154, 86);
	_vm->_screen->setSmackerDecoder(_diskSmackerPlayer->getSmackerDecoder());

	_palette->usePalette();

	SetMessageHandler(&DiskplayerScene::handleMessage); 
	SetUpdateHandler(&DiskplayerScene::update); 
	_appearCountdown = 6;

}
Esempio n. 13
0
void UICanvas::showMessageBox(const String& message)
{
	Widget* modalBackground = new Widget();
	
	UIWindow* surface = addSurface("modal");
	surface->attach(modalBackground);
	modalBackground->setRect(surface->getRect());

	UILabel* label = new UILabel(message);
	label->setSize(700,50);
	//label->setCenter(modalBackground->getMiddlePosition());
	modalBackground->attach(label);
};
Esempio n. 14
0
/**
 * @brief Handle Converting Surface and Adding to SurfaceManager.
 * @param surface
 */
void SurfaceManager::convertAndAdd(int surfaceType, surface_ptr surface)
{
    // Convert the Pixel Format.
    if(surface->exists())
    {
        if(!surface->convert())
        {
            SDL_Log("Unable to create charSurface");
            assert(false);
        }

        // Success, add the Surface to the Manager
        addSurface(surfaceType, surface);
    }
    else
    {
        SDL_Log("Unable to create charSurface");
        assert(false);
    }
}
Esempio n. 15
0
tracking_window::tracking_window(QWidget *parent,ODFModel* new_handle,bool handle_release_) :
        QMainWindow(parent),handle(new_handle),handle_release(handle_release_),
        ui(new Ui::tracking_window),scene(*this,new_handle),slice(new_handle)

{

    ODFModel* odf_model = (ODFModel*)handle;
    FibData& fib_data = odf_model->fib_data;

    odf_size = fib_data.fib.odf_table.size();
    odf_face_size = fib_data.fib.odf_faces.size();
    has_odfs = fib_data.fib.has_odfs() ? 1:0;
    // check whether first index is "fa0"
    is_dti = (fib_data.view_item[0].name[0] == 'f');

    ui->setupUi(this);
    {
        setGeometry(10,10,800,600);

        ui->regionDockWidget->setMinimumWidth(0);
        ui->dockWidget->setMinimumWidth(0);
        ui->dockWidget_3->setMinimumWidth(0);
        ui->renderingLayout->addWidget(renderWidget = new RenderingTableWidget(*this,ui->renderingWidgetHolder,has_odfs));
        ui->centralLayout->insertWidget(1,glWidget = new GLWidget(renderWidget->getData("anti_aliasing").toInt(),
                                                                  *this,renderWidget,ui->centralwidget));
        ui->verticalLayout_3->addWidget(regionWidget = new RegionTableWidget(*this,ui->regionDockWidget));
        ui->tractverticalLayout->addWidget(tractWidget = new TractTableWidget(*this,ui->TractWidgetHolder));
        ui->graphicsView->setScene(&scene);
        ui->graphicsView->setCursor(Qt::CrossCursor);
        scene.statusbar = ui->statusbar;
        color_bar.reset(new color_bar_dialog(this));
    }

    // setup fa threshold
    {
        for(int index = 0;index < fib_data.fib.index_name.size();++index)
            ui->tracking_index->addItem((fib_data.fib.index_name[index]+" threshold").c_str());
        ui->tracking_index->setCurrentIndex(0);
        ui->step_size->setValue(fib_data.vs[0]/2.0);
    }

    // setup sliders
    {
        slice_no_update = true;
        ui->SagSlider->setRange(0,slice.geometry[0]-1);
        ui->CorSlider->setRange(0,slice.geometry[1]-1);
        ui->AxiSlider->setRange(0,slice.geometry[2]-1);
        ui->SagSlider->setValue(slice.slice_pos[0]);
        ui->CorSlider->setValue(slice.slice_pos[1]);
        ui->AxiSlider->setValue(slice.slice_pos[2]);

        ui->glSagBox->setRange(0,slice.geometry[0]-1);
        ui->glCorBox->setRange(0,slice.geometry[1]-1);
        ui->glAxiBox->setRange(0,slice.geometry[2]-1);
        ui->glSagBox->setValue(slice.slice_pos[0]);
        ui->glCorBox->setValue(slice.slice_pos[1]);
        ui->glAxiBox->setValue(slice.slice_pos[2]);
        slice_no_update = false;
        on_SliceModality_currentIndexChanged(0);

        for (unsigned int index = 0;index < fib_data.view_item.size(); ++index)
        {
            ui->sliceViewBox->addItem(fib_data.view_item[index].name.c_str());
            if(fib_data.view_item[index].is_overlay)
                ui->overlay->addItem(fib_data.view_item[index].name.c_str());
        }
        ui->sliceViewBox->setCurrentIndex(0);
        ui->overlay->setCurrentIndex(0);
        if(ui->overlay->count() == 1)
           ui->overlay->hide();
    }

    is_qsdr = !handle->fib_data.trans_to_mni.empty();

    // setup atlas
    if(!fa_template_imp.I.empty() && fib_data.vs[0] > 0.5 && !is_qsdr)
    {
        mi3_arg.scaling[0] = slice.voxel_size[0] / std::fabs(fa_template_imp.tran[0]);
        mi3_arg.scaling[1] = slice.voxel_size[1] / std::fabs(fa_template_imp.tran[5]);
        mi3_arg.scaling[2] = slice.voxel_size[2] / std::fabs(fa_template_imp.tran[10]);
        image::reg::align_center(slice.source_images,fa_template_imp.I,mi3_arg);
        mi3.reset(new manual_alignment(this,slice.source_images,fa_template_imp.I,mi3_arg));
        is_qsdr = false;
    }
    else
        ui->actionManual_Registration->setEnabled(false);
    ui->actionConnectometry->setEnabled(handle->fib_data.fib.has_odfs() && is_qsdr);
    for(int index = 0;index < atlas_list.size();++index)
        ui->atlasListBox->addItem(atlas_list[index].name.c_str());


    {
        if(is_dti)
            ui->actionQuantitative_anisotropy_QA->setText("Save FA...");
        for (int index = fib_data.other_mapping_index; index < fib_data.view_item.size(); ++index)
            {
                std::string& name = fib_data.view_item[index].name;
                QAction* Item = new QAction(this);
                Item->setText(QString("Save %1...").arg(name.c_str()));
                Item->setData(QString(name.c_str()));
                Item->setVisible(true);
                connect(Item, SIGNAL(triggered()),tractWidget, SLOT(save_tracts_data_as()));
                ui->menuSave->addAction(Item);
            }
    }

    // opengl
    {
        connect(renderWidget->treemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                glWidget,SLOT(updateGL()));
        connect(ui->tbDefaultParam,SIGNAL(clicked()),renderWidget,SLOT(setDefault()));
        connect(ui->tbDefaultParam,SIGNAL(clicked()),glWidget,SLOT(updateGL()));

        connect(ui->glSagSlider,SIGNAL(valueChanged(int)),this,SLOT(glSliderValueChanged()));
        connect(ui->glCorSlider,SIGNAL(valueChanged(int)),this,SLOT(glSliderValueChanged()));
        connect(ui->glAxiSlider,SIGNAL(valueChanged(int)),this,SLOT(glSliderValueChanged()));

        connect(ui->glSagCheck,SIGNAL(stateChanged(int)),glWidget,SLOT(updateGL()));
        connect(ui->glCorCheck,SIGNAL(stateChanged(int)),glWidget,SLOT(updateGL()));
        connect(ui->glAxiCheck,SIGNAL(stateChanged(int)),glWidget,SLOT(updateGL()));

        connect(ui->glSagView,SIGNAL(clicked()),this,SLOT(on_SagView_clicked()));
        connect(ui->glCorView,SIGNAL(clicked()),this,SLOT(on_CorView_clicked()));
        connect(ui->glAxiView,SIGNAL(clicked()),this,SLOT(on_AxiView_clicked()));

        connect(ui->addSlices,SIGNAL(clicked()),this,SLOT(on_actionInsert_T1_T2_triggered()));
        connect(ui->actionAdd_surface,SIGNAL(triggered()),glWidget,SLOT(addSurface()));
        connect(ui->SliceModality,SIGNAL(currentIndexChanged(int)),glWidget,SLOT(updateGL()));
        connect(ui->actionSave_Screen,SIGNAL(triggered()),glWidget,SLOT(catchScreen()));
        connect(ui->actionSave_3D_screen_in_high_resolution,SIGNAL(triggered()),glWidget,SLOT(catchScreen2()));
        connect(ui->actionLoad_Camera,SIGNAL(triggered()),glWidget,SLOT(loadCamera()));
        connect(ui->actionSave_Camera,SIGNAL(triggered()),glWidget,SLOT(saveCamera()));
        connect(ui->actionLoad_mapping,SIGNAL(triggered()),glWidget,SLOT(loadMapping()));
        connect(ui->actionSave_mapping,SIGNAL(triggered()),glWidget,SLOT(saveMapping()));
        connect(ui->actionSave_Rotation_Images,SIGNAL(triggered()),glWidget,SLOT(saveRotationSeries()));
        connect(ui->actionSave_Left_Right_3D_Image,SIGNAL(triggered()),glWidget,SLOT(saveLeftRight3DImage()));
    }
    // scene view
    {
        connect(ui->SagSlider,SIGNAL(valueChanged(int)),this,SLOT(SliderValueChanged()));
        connect(ui->CorSlider,SIGNAL(valueChanged(int)),this,SLOT(SliderValueChanged()));
        connect(ui->AxiSlider,SIGNAL(valueChanged(int)),this,SLOT(SliderValueChanged()));


        connect(&scene,SIGNAL(need_update()),&scene,SLOT(show_slice()));
        connect(&scene,SIGNAL(need_update()),glWidget,SLOT(updateGL()));
        connect(ui->fa_threshold,SIGNAL(valueChanged(double)),&scene,SLOT(show_slice()));
        connect(ui->contrast,SIGNAL(valueChanged(int)),&scene,SLOT(show_slice()));
        connect(ui->offset,SIGNAL(valueChanged(int)),&scene,SLOT(show_slice()));
        connect(ui->show_fiber,SIGNAL(clicked()),&scene,SLOT(show_slice()));
        connect(ui->show_pos,SIGNAL(clicked()),&scene,SLOT(show_slice()));
        connect(ui->show_lr,SIGNAL(clicked()),&scene,SLOT(show_slice()));

        connect(ui->zoom,SIGNAL(valueChanged(double)),&scene,SLOT(show_slice()));
        connect(ui->zoom,SIGNAL(valueChanged(double)),&scene,SLOT(center()));


        connect(ui->actionAxial_View,SIGNAL(triggered()),this,SLOT(on_AxiView_clicked()));
        connect(ui->actionCoronal_View,SIGNAL(triggered()),this,SLOT(on_CorView_clicked()));
        connect(ui->actionSagittal_view,SIGNAL(triggered()),this,SLOT(on_SagView_clicked()));


        connect(ui->actionSave_ROI_Screen,SIGNAL(triggered()),&scene,SLOT(catch_screen()));

        connect(ui->actionSave_Anisotrpy_Map_as,SIGNAL(triggered()),&scene,SLOT(save_slice_as()));


        connect(ui->overlay,SIGNAL(currentIndexChanged(int)),this,SLOT(on_sliceViewBox_currentIndexChanged(int)));

    }

    // regions
    {

        connect(regionWidget,SIGNAL(need_update()),&scene,SLOT(show_slice()));
        connect(regionWidget,SIGNAL(need_update()),glWidget,SLOT(updateGL()));



        connect(ui->whole_brain,SIGNAL(clicked()),regionWidget,SLOT(whole_brain()));

        connect(ui->view_style,SIGNAL(currentIndexChanged(int)),&scene,SLOT(show_slice()));

        //atlas
        connect(ui->addRegionFromAtlas,SIGNAL(clicked()),regionWidget,SLOT(add_atlas()));


        connect(ui->actionNewRegion,SIGNAL(triggered()),regionWidget,SLOT(new_region()));
        connect(ui->actionOpenRegion,SIGNAL(triggered()),regionWidget,SLOT(load_region()));
        connect(ui->actionSaveRegionAs,SIGNAL(triggered()),regionWidget,SLOT(save_region()));
        connect(ui->actionSave_Voxel_Data_As,SIGNAL(triggered()),regionWidget,SLOT(save_region_info()));
        connect(ui->actionDeleteRegion,SIGNAL(triggered()),regionWidget,SLOT(delete_region()));
        connect(ui->actionDeleteRegionAll,SIGNAL(triggered()),regionWidget,SLOT(delete_all_region()));


        // actions
        connect(ui->actionShift_X,SIGNAL(triggered()),regionWidget,SLOT(action_shiftx()));
        connect(ui->actionShift_X_2,SIGNAL(triggered()),regionWidget,SLOT(action_shiftnx()));
        connect(ui->actionShift_Y,SIGNAL(triggered()),regionWidget,SLOT(action_shifty()));
        connect(ui->actionShift_Y_2,SIGNAL(triggered()),regionWidget,SLOT(action_shiftny()));
        connect(ui->actionShift_Z,SIGNAL(triggered()),regionWidget,SLOT(action_shiftz()));
        connect(ui->actionShift_Z_2,SIGNAL(triggered()),regionWidget,SLOT(action_shiftnz()));

        connect(ui->actionFlip_X,SIGNAL(triggered()),regionWidget,SLOT(action_flipx()));
        connect(ui->actionFlip_Y,SIGNAL(triggered()),regionWidget,SLOT(action_flipy()));
        connect(ui->actionFlip_Z,SIGNAL(triggered()),regionWidget,SLOT(action_flipz()));

        connect(ui->actionThreshold,SIGNAL(triggered()),regionWidget,SLOT(action_threshold()));



        connect(ui->actionSmoothing,SIGNAL(triggered()),regionWidget,SLOT(action_smoothing()));
        connect(ui->actionErosion,SIGNAL(triggered()),regionWidget,SLOT(action_erosion()));
        connect(ui->actionDilation,SIGNAL(triggered()),regionWidget,SLOT(action_dilation()));
        connect(ui->actionNegate,SIGNAL(triggered()),regionWidget,SLOT(action_negate()));
        connect(ui->actionDefragment,SIGNAL(triggered()),regionWidget,SLOT(action_defragment()));

        connect(ui->actionCheck_all_regions,SIGNAL(triggered()),regionWidget,SLOT(check_all()));
        connect(ui->actionUnckech_all_regions,SIGNAL(triggered()),regionWidget,SLOT(uncheck_all()));

        connect(ui->actionWhole_brain_seeding,SIGNAL(triggered()),regionWidget,SLOT(whole_brain()));
        connect(ui->actionRegion_statistics,SIGNAL(triggered()),regionWidget,SLOT(show_statistics()));


    }
    // tracts
    {
        connect(ui->perform_tracking,SIGNAL(clicked()),tractWidget,SLOT(start_tracking()));
        connect(ui->stopTracking,SIGNAL(clicked()),tractWidget,SLOT(stop_tracking()));

        connect(tractWidget,SIGNAL(need_update()),glWidget,SLOT(makeTracts()));
        connect(tractWidget,SIGNAL(need_update()),glWidget,SLOT(updateGL()));

        connect(glWidget,SIGNAL(edited()),tractWidget,SLOT(edit_tracts()));
        connect(glWidget,SIGNAL(region_edited()),glWidget,SLOT(updateGL()));
        connect(glWidget,SIGNAL(region_edited()),&scene,SLOT(show_slice()));

        connect(ui->actionOpenTract,SIGNAL(triggered()),tractWidget,SLOT(load_tracts()));
        connect(ui->actionMerge_All,SIGNAL(triggered()),tractWidget,SLOT(merge_all()));
        connect(ui->actionCopyTrack,SIGNAL(triggered()),tractWidget,SLOT(copy_track()));
        connect(ui->actionDeleteTract,SIGNAL(triggered()),tractWidget,SLOT(delete_tract()));
        connect(ui->actionDeleteTractAll,SIGNAL(triggered()),tractWidget,SLOT(delete_all_tract()));

        connect(ui->actionOpen_Colors,SIGNAL(triggered()),tractWidget,SLOT(load_tracts_color()));
        connect(ui->actionSave_Tracts_Colors_As,SIGNAL(triggered()),tractWidget,SLOT(save_tracts_color_as()));

        connect(ui->actionUndo,SIGNAL(triggered()),tractWidget,SLOT(undo_tracts()));
        connect(ui->actionRedo,SIGNAL(triggered()),tractWidget,SLOT(redo_tracts()));
        connect(ui->actionTrim,SIGNAL(triggered()),tractWidget,SLOT(trim_tracts()));

        connect(ui->actionSet_Color,SIGNAL(triggered()),tractWidget,SLOT(set_color()));

        connect(ui->actionK_means,SIGNAL(triggered()),tractWidget,SLOT(clustering_kmeans()));
        connect(ui->actionEM,SIGNAL(triggered()),tractWidget,SLOT(clustering_EM()));
        connect(ui->actionHierarchical,SIGNAL(triggered()),tractWidget,SLOT(clustering_hie()));
        connect(ui->actionOpen_Cluster_Labels,SIGNAL(triggered()),tractWidget,SLOT(open_cluster_label()));

        //setup menu
        connect(ui->actionSaveTractAs,SIGNAL(triggered()),tractWidget,SLOT(save_tracts_as()));
        connect(ui->actionSave_All_Tracts_As,SIGNAL(triggered()),tractWidget,SLOT(save_all_tracts_as()));
        connect(ui->actionQuantitative_anisotropy_QA,SIGNAL(triggered()),tractWidget,SLOT(save_fa_as()));
        connect(ui->actionSave_End_Points_As,SIGNAL(triggered()),tractWidget,SLOT(save_end_point_as()));
        connect(ui->actionStatistics,SIGNAL(triggered()),tractWidget,SLOT(show_tracts_statistics()));

        connect(ui->track_up,SIGNAL(clicked()),tractWidget,SLOT(move_up()));
        connect(ui->track_down,SIGNAL(clicked()),tractWidget,SLOT(move_down()));

    }




    // recall the setting
    {

        QSettings settings;
        if(!default_geo.size())
            default_geo = saveGeometry();
        if(!default_state.size())
            default_state = saveState();
        restoreGeometry(settings.value("geometry").toByteArray());
        restoreState(settings.value("state").toByteArray());
        ui->turning_angle->setValue(settings.value("turning_angle",60).toDouble());
        ui->smoothing->setValue(settings.value("smoothing",0.0).toDouble());
        ui->min_length->setValue(settings.value("min_length",0.0).toDouble());
        ui->max_length->setValue(settings.value("max_length",500).toDouble());
        ui->tracking_method->setCurrentIndex(settings.value("tracking_method",0).toInt());
        ui->seed_plan->setCurrentIndex(settings.value("seed_plan",0).toInt());
        ui->initial_direction->setCurrentIndex(settings.value("initial_direction",0).toInt());
        ui->interpolation->setCurrentIndex(settings.value("interpolation",0).toInt());
        ui->tracking_plan->setCurrentIndex(settings.value("tracking_plan",0).toInt());
        ui->track_count->setValue(settings.value("track_count",2000).toInt());
        ui->thread_count->setCurrentIndex(settings.value("thread_count",0).toInt());

        ui->glSagCheck->setChecked(settings.value("SagSlice",1).toBool());
        ui->glCorCheck->setChecked(settings.value("CorSlice",1).toBool());
        ui->glAxiCheck->setChecked(settings.value("AxiSlice",1).toBool());
        ui->RenderingQualityBox->setCurrentIndex(settings.value("RenderingQuality",1).toInt());

        ui->view_style->setCurrentIndex((settings.value("view_style",0).toInt()));
        ui->RAS->setChecked(settings.value("RAS",0).toBool());
    }

    {
        scene.center();
        slice_no_update = false;
        copy_target = 0;
    }

    on_glAxiView_clicked();
    if(scene.neurology_convention)
        on_glAxiView_clicked();
    qApp->installEventFilter(this);
}
Esempio n. 16
0
void setConeData(double coneBaseRadius, double coneHeight)
{
  double h, h2, R, rh, rh2, H, halfH;
  POINT3D pt[100];
  int nPts, i, k, m, n;
  double a1, a2;
  double cosa1, cosa2, sina1, sina2;
  double aDelta;
  double hDelta;

  H = coneHeight;
  halfH = H / 2.0;
  R = coneBaseRadius;
  n = 30; // no of sampled points on circumference
  hDelta = 20;
  m = (int)(H / hDelta); // number of equi-spaced circles
  if (((int)H) > (int)(m*hDelta)) 
    m = m + 1;// adjustment for last leap
  aDelta = 2.0 * PI / n;

  for (i = 0; i < m; i++)
  {
    h = i * hDelta; // height from base
    rh = R * (1.0 - h/H);
    h2 = h + hDelta;
    rh2 = R * (1.0 - h2/H);
    for (k = 0; k < n; k++)
    {
      nPts = 0;
      a1 = k*aDelta;
      a2 = a1 + aDelta;
      cosa1 = cos(a1);
      cosa2 = cos(a2);
      sina1 = sin(a1);
      sina2 = sin(a2);
      // sampled point on the lower circumference 
      pt[nPts].x = rh * cosa1; 
      pt[nPts].y = rh * sina1;
      pt[nPts].z = halfH - h;
      nPts++;

      // another point on the lower circumference
      pt[nPts].x = rh * cosa2; 
      pt[nPts].y = rh * sina2;
      pt[nPts].z = halfH - h;
      nPts++;

      if (i == (m-1))
      {
        // add cone top for triangular planar patch
        pt[nPts].x = 0;
        pt[nPts].y = 0;
        pt[nPts].z = -halfH;
        nPts++;        
      }
      else
      {
        // 4-cornered planar patch, add 2 more points
        // sampled point on the upper circumference         
        pt[nPts].x = rh2 * cosa2;
        pt[nPts].y = rh2 * sina2;
        pt[nPts].z = halfH - h2;
        nPts++;

        // another point on the upper circumference
        pt[nPts].x = rh2 * cosa1;
        pt[nPts].y = rh2 * sina1;
        pt[nPts].z = halfH - h2;
        nPts++;
      }
      addSurface(pt, nPts);
    }
  }
  // add the base surface
  nPts = 0;
  for (k = 0; k < n; k++)
  {
    // point on the circumference of base
    pt[nPts].x = R * cos(k * aDelta);
    pt[nPts].y = R * sin(k * aDelta);
    pt[nPts].z = halfH;
    nPts++;
  }
  addSurface(pt, nPts);
}
Esempio n. 17
0
/// Adds a layer to this canvas for 3D controls
void UICanvas::addLayer3D(const String& name)
{
	addSurface(name);
}
Esempio n. 18
0
/// Push a new modal surface to the top, it will destroy itself once there are no more controls in it
void UICanvas::pushModalSurface()
{
	addSurface("auto_modal");
	top()->setModal(true);
}
Esempio n. 19
0
Background *Scene::addBackground(Background *background) {
    addEntity(background);
    addSurface(background->getSurface());
    return background;
}
Esempio n. 20
0
Sprite *Scene::addSprite(Sprite *sprite) {
    addEntity(sprite);
    addSurface(sprite->getSurface());
    return sprite;
}
Esempio n. 21
0
/**
 * Adds given surface to given positions..
 */
void GraphicsEngine::addSurface(int x, int y, SDL_Surface * source, SDL_Surface * destination){
	addSurface(x,y,source,destination,NULL);
}
Esempio n. 22
0
void Scene::setSurfacePriority(BaseSurface *surface, int priority) {
    surface->setPriority(priority);
    if (removeSurface(surface))
        addSurface(surface);
}
Esempio n. 23
0
SurfacesConfigDialog::SurfacesConfigDialog(const QVector<struct wsPCD> &collectionPoints,
																		 const QVector<std::string> &collectionAttributes,
																		 const QVector<struct wsWeatherDataPcdSurface> &collectionSurfaces,
																		 const wsProjectionParams &projection,
																		 QWidget *parent, Qt::WFlags f) : QDialog(parent, f), _parent(parent),

  _collectionPoints(collectionPoints),
  _collectionAttributes(collectionAttributes),
  _collectionSurfaces(collectionSurfaces),
  _projection(projection),
  _attributeListIsLoaded(false),
  _baseBox(0, 0, 0, 0)

{
  setupUi(this);

  // métodos de interpolação
  interpCmb->addItem(tr("Vizinho mais próximo"));
  interpCmb->addItem(tr("K-vizinhos mais próximos"));
  interpCmb->addItem(tr("K-vizinhos mais próximos ponderados"));
#ifndef _WIN64  
  interpCmb->addItem(tr("Superfície de tendência"));
#endif

  // Menus associados a botões
  QMenu* menuMask = new QMenu(tr("Máscaras"), _parent);
  menuMask->addAction(tr("%a - ano com dois digitos"));
  menuMask->addAction(tr("%A - ano com quatro digitos"));
  menuMask->addAction(tr("%d - dia com dois digitos"));
  menuMask->addAction(tr("%M - mes com dois digitos"));
  menuMask->addAction(tr("%h - hora com dois digitos"));
  menuMask->addAction(tr("%m - minuto com dois digitos"));
  menuMask->addAction(tr("%s - segundo com dois digitos"));

  fileAnaGridMaskBtn->setMenu(menuMask);
  fileAnaGridMaskBtn->setPopupMode(QToolButton::InstantPopup);

  // Coneta os sinais
  connect(menuMask, SIGNAL(triggered(QAction*)), SLOT(menuMaskClick(QAction*)));

  connect(surfaceList,    SIGNAL(currentRowChanged(int)),   SLOT(showSurfaceDetails(int)));
  connect(interpCmb,      SIGNAL(currentIndexChanged(int)), SLOT(interpolationChanged(int)));
  connect(resDegreeRadio, SIGNAL(toggled(bool)),            SLOT(resDegreeRadioToggled(bool)));

  connect(outputGridEdit,  SIGNAL(textEdited(const QString&)), SLOT(updateCurrentSurface()));
  connect(attributeCmb,    SIGNAL(activated(int)),             SLOT(updateCurrentSurface()));
  connect(interpCmb,       SIGNAL(activated(int)),             SLOT(updateCurrentSurface()));
  connect(neighborNumEdit, SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(powValueEdit,    SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(degreeCmb,       SIGNAL(activated(int)),             SLOT(updateCurrentSurface()));
  connect(x1Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(y1Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(x2Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(y2Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(resXEdit,        SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(resYEdit,        SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(resDegreeRadio,  SIGNAL(clicked(bool)),              SLOT(updateCurrentSurface()));
  connect(resMeterRadio,   SIGNAL(clicked(bool)),              SLOT(updateCurrentSurface()));

  connect(outputGridEdit,  SIGNAL(textEdited(const QString&)), SLOT(updateSurfaceList()));
  connect(outputGridEdit,  SIGNAL(editingFinished()),          SLOT(trimGridOutputName()));

  connect(addAttributeBtn,    SIGNAL(clicked()), SLOT(addSurface()));
  connect(removeAttributeBtn, SIGNAL(clicked()), SLOT(removeSurface()));
  connect(okBtn,              SIGNAL(clicked()), SLOT(checkAndAccept()));
  connect(cancelBtn,          SIGNAL(clicked()), SLOT(checkAndReject()));

  neighborNumEdit->setValidator(new QIntValidator(0, 9999, neighborNumEdit));
  powValueEdit->setValidator(new QIntValidator(0, 9999, powValueEdit));

  x1Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, x1Edit));
  y1Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, y1Edit));
  x2Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, x2Edit));
  y2Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, y2Edit));

  resXEdit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, resXEdit));
  resYEdit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, resYEdit));

  // Carrega as superfícies já cadastradas
  if(!collectionSurfaces.isEmpty())
  {
    loadAttributeList();
    updateSurfaceList(0);
  }
  else // Nenhuma cadastrada, desabilita a parte direita da interface
    clearSurfaceDetails();

  // Calcula o box padrão
  {
    TePointSet pointSet;
    for(int i = 0; i < _collectionPoints.size(); i++)
    {
      if(_collectionPoints.at(i).isActive)
      {
        TeCoord2D aux = TeCoord2D(_collectionPoints.at(i).longitude, _collectionPoints.at(i).latitude);
        TePoint p(aux);
        pointSet.add(p);
      }
    }

    if(pointSet.size() > 0)
    {
      std::auto_ptr<TeProjection> projection(TeProjectionFactory::make(wsUtils::ProjectionParams::teFromWs(_projection)));

      for(unsigned int i = 0; i < pointSet.size(); ++i)
      {
        if(pointSet[i].srid() == -1)
          pointSet[i].srid(projection->epsgCode());
      }

      // Atualiza o box padrão
      _baseBox = pointSet.box();
    }
  }

  // Grava configuração inicial
  _startConfig = _collectionSurfaces;
}
Esempio n. 24
0
SmackerPlayer *Scene::addSmackerPlayer(SmackerPlayer *smackerPlayer) {
    addEntity(smackerPlayer);
    addSurface(smackerPlayer->getSurface());
    return smackerPlayer;
}
Esempio n. 25
0
the::mesh::ptr Polygon2d::createMesh(strref name, float zOffset, bool flipTriangles)
{
	std::vector<std::vector<p2t::Point*>> polylines;
	std::vector<std::vector<p2t::Point*>> holes;

	std::vector<Vertex> engineVerts;
	std::vector<uint16_t> engineIndices;

	for(int i = 0;i<polygon.num_contours;i++)
	{
		std::vector<p2t::Point*> polyline;
		for(int j = 0; j < polygon.contour[i].num_vertices; j++)
			polyline.push_back(new p2t::Point(polygon.contour[i].vertex[j].x, polygon.contour[i].vertex[j].y));
		if(polygon.hole[i]==0)
		{
			polylines.push_back(polyline);
		}
		else
		{
			holes.push_back(polyline);
		}
	}

	for(auto i = 0u; i < polylines.size(); i++)
	{
		std::vector<p2t::Point*> polyline = polylines[i];

		p2t::CDT* cdt = new p2t::CDT(polyline);

		for(auto j = 0u; j < holes.size(); j++)
		{
			cdt->AddHole(holes[j]);
		}

		cdt->Triangulate();
		std::vector<p2t::Triangle*> currentOutput = cdt->GetTriangles();

		for(auto i = 0u; i < currentOutput.size(); i++)
		{
			p2t::Triangle *currentTriangle = currentOutput[i];
			Vertex v1 = {{static_cast<float>(currentTriangle->GetPoint(0)->x),static_cast<float>(currentTriangle->GetPoint(0)->y), zOffset}, {1, 1}, {0, 0, flipTriangles?-1.0f:1.0f}};
			Vertex v2 = {{static_cast<float>(currentTriangle->GetPoint(1)->x),static_cast<float>(currentTriangle->GetPoint(1)->y), zOffset}, {1, 1}, {0, 0, flipTriangles?-1.0f:1.0f}};
			Vertex v3 = {{static_cast<float>(currentTriangle->GetPoint(2)->x),static_cast<float>(currentTriangle->GetPoint(2)->y), zOffset}, {1, 1}, {0, 0, flipTriangles?-1.0f:1.0f}};
			int offset = engineVerts.size();

			int t1 = flipTriangles?1:2;
			int t2 = flipTriangles?2:1;

			engineIndices.push_back(offset+0);
			engineIndices.push_back(offset+t2);
			engineIndices.push_back(offset+t1);

			engineVerts.push_back(v1);
			engineVerts.push_back(v2);
			engineVerts.push_back(v3);
		}
		delete cdt;
	}

	for(auto i = 0u; i < polylines.size(); i++)
	{
		std::vector<p2t::Point*> &polyline = polylines[i];
		for(auto item:polyline)
			delete item;
	}
	for(auto i = 0u; i < holes.size(); i++)
	{
		std::vector<p2t::Point*> &hole = holes[i];
		for(auto item:hole)
			delete item;
	}

	auto g = std::make_shared<the::mesh>();
	g->setTag(name);
	g->addVertex(engineVerts);
	g->addSurface(std::move(the::surface(std::move(engineIndices), "plane")));
	g->bind();
	g->setMaterial(the::material::get("def::base"));
	g->setTexture(0, the::texture::get("def::base"));

	return g;
}