Example #1
0
BeingId NpcHandler::getNpc(Net::MessageIn &msg)
{
    if (msg.getId() == SMSG_NPC_CHOICE
        || msg.getId() == SMSG_NPC_MESSAGE
        || msg.getId() == SMSG_NPC_CHANGETITLE)
    {
        msg.readInt16("len");
    }

    const BeingId npcId = msg.readBeingId("npc id");

    const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId);
    mDialog = nullptr;

    if (diag == NpcDialog::mNpcDialogs.end())
    {
        // Empty dialogs don't help
        if (msg.getId() == SMSG_NPC_CLOSE)
        {
            closeDialog(npcId);
            return npcId;
        }
        else if (msg.getId() == SMSG_NPC_NEXT)
        {
            nextDialog(npcId);
            return npcId;
        }
        else
        {
            mDialog = new NpcDialog(npcId);
            mDialog->postInit();
            mDialog->saveCamera();
            if (localPlayer)
                localPlayer->stopWalking(false);
            NpcDialog::mNpcDialogs[npcId] = mDialog;
        }
    }
    else
    {
        NpcDialog *const dialog = diag->second;
        if (mDialog && mDialog != dialog)
            mDialog->restoreCamera();
        mDialog = dialog;
        if (mDialog)
            mDialog->saveCamera();
    }
    return npcId;
}
Example #2
0
	//compute the camera path using the camera keyframes
	void computeCubicSplineCameraPath()
	{
		//Build the cubic splines
		CubicSpline splineEyePosition;
		CubicSpline splineLookAt;
		vector<int> keyIdFrame;
		//Add points CubicSpline
		for (unsigned int fc = 0; fc <= LarmorPhysx::ConfigManager::total_anim_steps; ++fc)
		{
			Camera cam = loadCamera(fc);
			if(cam.keyframe)
			{
				cout << "Add point to camera path: frame: " << fc << endl;
				splineEyePosition.addPoint(cam.eyePosition);
				splineLookAt.addPoint(cam.lookAt);
				keyIdFrame.push_back(fc);
			}
		}
		//compute paths
		splineEyePosition.compute();
		splineLookAt.compute();

		//draw camera path getting the points from the spline objects
		for(int kf = 0; kf < keyIdFrame.size()-1; kf++)
		{
			int fc0 = keyIdFrame.at(kf);
			int fc1 = keyIdFrame.at(kf+1);
			int framesInterval = fc1 - fc0;
			double frameStep = 1.0L / framesInterval;
			double cubicPos = 0.0;

			cout << "interpolation from keyframe: " << fc0 << endl;
			for(int pf = fc0+1; pf < fc1; pf++)
			{
				cout << "interpolation frame: " << pf << endl;
				cubicPos += frameStep;
				LVector3 eyePosition = splineEyePosition.getPoint(kf, cubicPos);
				LVector3 lookAt = splineLookAt.getPoint(kf, cubicPos);

				//Create the Camera object and save
				Camera camera;
				camera.idFrame = pf;
				camera.eyePosition = eyePosition;
				camera.lookAt = lookAt;
				camera.keyframe = false;
				//Save camera
				saveCamera(camera);
			}
			cout << "interpolation to keyframe: " << fc1 << endl;
		}
	}
void LVRMainWindow::connectSignalsAndSlots()
{
    QObject::connect(m_actionOpen, SIGNAL(activated()), this, SLOT(loadModel()));
    QObject::connect(m_actionExport, SIGNAL(activated()), this, SLOT(exportSelectedModel()));
    QObject::connect(treeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showTreeContextMenu(const QPoint&)));
    QObject::connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(restoreSliders(QTreeWidgetItem*, int)));
    QObject::connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(setModelVisibility(QTreeWidgetItem*, int)));

    QObject::connect(m_actionQuit, SIGNAL(activated()), qApp, SLOT(quit()));

    QObject::connect(m_actionShowColorDialog, SIGNAL(activated()), this, SLOT(showColorDialog()));
    QObject::connect(m_actionRenameModelItem, SIGNAL(activated()), this, SLOT(renameModelItem()));
    QObject::connect(m_actionDeleteModelItem, SIGNAL(activated()), this, SLOT(deleteModelItem()));
    QObject::connect(m_actionExportModelTransformed, SIGNAL(activated()), this, SLOT(exportSelectedModel()));

    QObject::connect(m_actionReset_Camera, SIGNAL(activated()), this, SLOT(updateView()));
    QObject::connect(m_actionStore_Current_View, SIGNAL(activated()), this, SLOT(saveCamera()));
    QObject::connect(m_actionRecall_Stored_View, SIGNAL(activated()), this, SLOT(loadCamera()));
    QObject::connect(m_actionCameraPathTool, SIGNAL(activated()), this, SLOT(openCameraPathTool()));

    QObject::connect(m_actionEstimate_Normals, SIGNAL(activated()), this, SLOT(estimateNormals()));
    QObject::connect(m_actionMarching_Cubes, SIGNAL(activated()), this, SLOT(reconstructUsingMarchingCubes()));
    QObject::connect(m_actionPlanar_Marching_Cubes, SIGNAL(activated()), this, SLOT(reconstructUsingPlanarMarchingCubes()));
    QObject::connect(m_actionExtended_Marching_Cubes, SIGNAL(activated()), this, SLOT(reconstructUsingExtendedMarchingCubes()));

    QObject::connect(m_actionPlanar_Optimization, SIGNAL(activated()), this, SLOT(optimizePlanes()));
    QObject::connect(m_actionRemove_Artifacts, SIGNAL(activated()), this, SLOT(removeArtifacts()));

    QObject::connect(m_actionRemove_Outliers, SIGNAL(activated()), this, SLOT(removeOutliers()));
    QObject::connect(m_actionMLS_Projection, SIGNAL(activated()), this, SLOT(applyMLSProjection()));

    QObject::connect(m_actionICP_Using_Manual_Correspondance, SIGNAL(activated()), this, SLOT(manualICP()));

    QObject::connect(m_menuAbout, SIGNAL(triggered(QAction*)), this, SLOT(showAboutDialog(QAction*)));

    QObject::connect(m_correspondanceDialog->m_dialog, SIGNAL(accepted()), m_pickingInteractor, SLOT(correspondenceSearchOff()));
    QObject::connect(m_correspondanceDialog->m_dialog, SIGNAL(accepted()), this, SLOT(alignPointClouds()));
    QObject::connect(m_correspondanceDialog->m_dialog, SIGNAL(rejected()), m_pickingInteractor, SLOT(correspondenceSearchOff()));
    QObject::connect(m_correspondanceDialog, SIGNAL(addArrow(LVRVtkArrow*)), this, SLOT(addArrow(LVRVtkArrow*)));
    QObject::connect(m_correspondanceDialog, SIGNAL(removeArrow(LVRVtkArrow*)), this, SLOT(removeArrow(LVRVtkArrow*)));
    QObject::connect(m_correspondanceDialog, SIGNAL(disableCorrespondenceSearch()), m_pickingInteractor, SLOT(correspondenceSearchOff()));
    QObject::connect(m_correspondanceDialog, SIGNAL(enableCorrespondenceSearch()), m_pickingInteractor, SLOT(correspondenceSearchOn()));

    QObject::connect(m_actionShow_Points, SIGNAL(toggled(bool)), this, SLOT(togglePoints(bool)));
    QObject::connect(m_actionShow_Normals, SIGNAL(toggled(bool)), this, SLOT(toggleNormals(bool)));
    QObject::connect(m_actionShow_Mesh, SIGNAL(toggled(bool)), this, SLOT(toggleMeshes(bool)));
    QObject::connect(m_actionShow_Wireframe, SIGNAL(toggled(bool)), this, SLOT(toggleWireframe(bool)));
    QObject::connect(m_actionShowBackgroundSettings, SIGNAL(activated()), this, SLOT(showBackgroundDialog()));

    QObject::connect(m_horizontalSliderPointSize, SIGNAL(valueChanged(int)), this, SLOT(changePointSize(int)));
    QObject::connect(m_horizontalSliderTransparency, SIGNAL(valueChanged(int)), this, SLOT(changeTransparency(int)));

    QObject::connect(m_comboBoxShading, SIGNAL(currentIndexChanged(int)), this, SLOT(changeShading(int)));

    QObject::connect(m_buttonCameraPathTool, SIGNAL(pressed()), this, SLOT(openCameraPathTool()));
    QObject::connect(m_buttonCreateMesh, SIGNAL(pressed()), this, SLOT(reconstructUsingMarchingCubes()));
    QObject::connect(m_buttonExportData, SIGNAL(pressed()), this, SLOT(exportSelectedModel()));
    QObject::connect(m_buttonTransformModel, SIGNAL(pressed()), this, SLOT(showTransformationDialog()));

    QObject::connect(m_pickingInteractor, SIGNAL(firstPointPicked(double*)),m_correspondanceDialog, SLOT(firstPointPicked(double*)));
    QObject::connect(m_pickingInteractor, SIGNAL(secondPointPicked(double*)),m_correspondanceDialog, SLOT(secondPointPicked(double*)));

    QObject::connect(this, SIGNAL(correspondenceDialogOpened()), m_pickingInteractor, SLOT(correspondenceSearchOn()));
}
Example #4
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);
}
Example #5
0
	void saveCamera(Camera &camera)
	{
		std::stringstream fileName;
		fileName << ConfigManager::scene_output_directory << FILE_SEPARATOR_CHAR << CAMERA_FILE_NAME << camera.idFrame << SERIAL_EXTENSION_FILENAME;
		saveCamera(camera, fileName.str().c_str());
	}
Example #6
0
//Create a CGLWin widget
CGLWin::CGLWin(void):
	QMainWindow( 0, "View3D", WDestructiveClose), 
	m_pListViews(NULL)
{
	int i;

	// Data members;
	CGLDrawParms tDraw;
	_drawParms = tDraw;

	m_nTimeDelay = 0;

	for (i=0; i<VIEW3D_MAX_OBJ_COUNT; i++) _pCia3dObjs[i] = NULL;

	// setup printer
	m_pPrinter = new QPrinter;

	// GUI members, create a toolbar;
	m_pToolBar = _createToolBar();		

    // populate a menu with all actions
	m_pMenuBar = menuBar();
	assert(m_pMenuBar!=NULL);

	//====================File options ==========================
	{
		QPopupMenu * file = new QPopupMenu( this );
		menuBar()->insertItem( "&File  ", file );
		_fileNewAction->addTo( file );
		_fileOpenAction->addTo( file );
		_fileSaveAction->addTo( file );
		file->insertSeparator();
		file->insertItem( "Open Background", this,  SLOT(openBackgroundImage()), NULL);
		file->insertItem( "Load Camera", this,  SLOT(loadCamera()), NULL);
		file->insertItem( "Save Camera", this,  SLOT(saveCamera()), NULL);
		file->insertSeparator();	//===========================
		file->insertItem( "Export Povray", this,  SLOT(exportPovray()), NULL);
		file->insertItem( "Export STL", this,  SLOT(saveSTLFile()), NULL);
		file->insertItem( "Export TXT", this,  SLOT(saveTXTFile()), NULL);
		file->insertItem( "Export EPS", this,  SLOT(exportEps()), NULL);
	    file->insertSeparator();	//===========================
		_filePrintAction->addTo( file );
	    file->insertSeparator();	//===========================
		file->insertItem( "E&xit", qApp,  SLOT(closeAllWindows()), NULL);
	}


	//================ Tools Options ================================
	{
		QPopupMenu * pMenuTools = new QPopupMenu( this );
		menuBar()->insertItem( "&Tools", pMenuTools );
		pMenuTools->insertItem( "Show Entire Scene", this,  SLOT(show_entirescene()));
		pMenuTools->insertItem( "Dupe Current Object", this,  SLOT(dupe_currentobj()));
		pMenuTools->insertItem( "Dupe Current Object N", this,  SLOT(dupe_currentobjN()));

		{// Animation options
			pMenuTools->insertSeparator();	//=======================
			QPopupMenu * pAnimOption = new QPopupMenu( this );
			pMenuTools->insertItem( "&Prepare Animation", pAnimOption);
			pAnimOption->insertItem( "Setup", this,  SLOT(create_animation()));

		    QAction* startAction = new QAction(QPixmap(play_xpm), "&Start Animation", Qt::Key_F10, this);
			connect(startAction, SIGNAL(activated()), this, SLOT(startAnimation()));
		    startAction->addTo( pAnimOption );

			pAnimOption->insertItem( "Stop Animation", this,  SLOT(stopAnimation()), Qt::Key_F11);
			pAnimOption->insertItem( "Change Delay Time", this,  SLOT(editDelayTime()));

			{//toggle fast draw mode
				m_pActRepeatPlay = new QAction("Repeat", CTRL+Key_T, this);
				connect(m_pActRepeatPlay, SIGNAL(activated()), this, SLOT(toggleRepeatPlay()));
				m_pActRepeatPlay->setToggleAction(true);
				m_pActRepeatPlay->setOn(false);
				m_pActRepeatPlay->addTo( pAnimOption );
			}
		}
		pMenuTools->insertSeparator();	//=======================
		{// Stereo options
			QPopupMenu * pStereoOption = new QPopupMenu( this );
			pMenuTools->insertItem( "&Stereo", pStereoOption);

			QAction* m_pActToggleStereo = new QAction("Stereo Mode", Qt::Key_F12, this);
			connect(m_pActToggleStereo, SIGNAL(activated()), this, SLOT(toggleStereo()));
			m_pActToggleStereo->setToggleAction(true);
			m_pActToggleStereo->setOn(false);
			m_pActToggleStereo->addTo( pStereoOption );

			pStereoOption->insertItem( "Increase Eye Distance", this,  SLOT(incEyeDistance()), Qt::Key_Plus);
			pStereoOption->insertItem( "Decrease Eye Distance", this,  SLOT(decEyeDistance()), Qt::Key_Minus);
		}

		//pMenuTools->insertItem( "Rotation Axis", this,  SLOT(InputRotationAxis()), NULL);
		//pMenuTools->insertItem( "Mirror Plane", this,  SLOT(InputMirrorPlane()), NULL);
		//pMenuTools->insertSeparator();
		//pMenuTools->insertItem( "Vector Hidden Line Removal", this,  SLOT(hidden_line()), CTRL+Key_H);
		//pMenuTools->insertSeparator();	//=======================

		pMenuTools->insertSeparator();	//=======================
		pMenuTools->insertItem( "Set Mirror Plane", this,  SLOT(InputMirrorPlane()));
		pMenuTools->insertItem( "Set Rotation Axis", this,  SLOT(InputRotationAxis()));
	}

	//================ Rendering options ================================
	{
		QPopupMenu * pMenuOption = new QPopupMenu( this );
		menuBar()->insertItem( "&Options", pMenuOption );
		pMenuOption->insertItem( "Global Setting", this,  SLOT(OptionGlobalSetting()));
		pMenuOption->insertItem( "Surface Rendering", this,  SLOT(OptionRendering()));
		pMenuOption->insertItem( "Volume Rendering", this,  SLOT(OptionVolumeRendering()));
		pMenuOption->insertSeparator();	//=======================
		{
			QPopupMenu * pPickOption = new QPopupMenu( this );
			pMenuOption->insertItem( "&Picking Types", pPickOption);
			pPickOption->insertItem( "Pick an Object", this,  SLOT(set_obj_picking()));
			pPickOption->insertItem( "Pick a Polygon", this,  SLOT(set_face_picking()));
			pPickOption->insertItem( "Pick a Line", this,  SLOT(set_line_picking()));
		}

		QAction* act_mirroring = new QAction("Mirroring", 0, this);
		connect( act_mirroring, SIGNAL(activated()), this, SLOT(OptionMirroring()));
		act_mirroring->setToggleAction(true);
		act_mirroring->setOn(false);
		act_mirroring->addTo( pMenuOption );
		m_pMirroringAction = act_mirroring;

		QPopupMenu * pRotOption = new QPopupMenu( this );
		pMenuOption->insertItem( "&Rotation Types", pRotOption);
		QAction* act_rot0obj = new QAction("Rotate 90 Degree", 0, this);
		connect( act_rot0obj, SIGNAL(activated()), this, SLOT(OptionRotate90()));
		act_rot0obj->addTo( pRotOption );
		QAction* act_rot1obj = new QAction("Rotate 180 Degree", 0, this);
		connect( act_rot1obj, SIGNAL(activated()), this, SLOT(OptionRotate180()));
		act_rot1obj->addTo( pRotOption );
		QAction* act_rot2obj = new QAction("Rotate 270 Degree", 0, this);
		connect( act_rot2obj, SIGNAL(activated()), this, SLOT(OptionRotate270()));
		act_rot2obj->addTo( pRotOption );
		m_pRot90Action = act_rot0obj;
		m_pRot180Action = act_rot1obj;
		m_pRot270Action = act_rot2obj;
		m_pRot90Action->setToggleAction(true);
		m_pRot90Action->setOn(false);
		m_pRot180Action->setToggleAction(true);
		m_pRot180Action->setOn(false);
		m_pRot270Action->setToggleAction(true);
		m_pRot270Action->setOn(false);

		//show background image buttion
		QAction* act_showbgimg = new QAction("Background Image", 0, this);
		connect( act_showbgimg, SIGNAL(activated()), this, SLOT(ShowBackgroundImage()));
		act_showbgimg->setToggleAction(true);
		act_showbgimg->setOn(false);
		act_showbgimg->addTo( pMenuOption );
		m_pBGImageAction = act_showbgimg;

		//show floor plane buttion
		QAction* act_showfloor = new QAction(QString::fromLocal8Bit("Floor Plane"), 0, this);
		connect( act_showfloor, SIGNAL(activated()), this, SLOT(ShowFloor()));
		act_showfloor->setToggleAction(true);
		act_showfloor->setOn(false);
		act_showfloor->addTo( pMenuOption );
		m_pFloorAction = act_showfloor;

		{//Toggle fast draw mode
			m_pActFastDraw = new QAction("Fast Drawing", 0, this);
			connect(m_pActFastDraw, SIGNAL(activated()), this, SLOT(toggleFastDraw()));
			m_pActFastDraw->setToggleAction(true);
			m_pActFastDraw->setOn(false);
			m_pActFastDraw->addTo( pMenuOption );
		}

	}


	//========change opengl window size ==========================
	{
		QPopupMenu * pMenuGLWinsize = new QPopupMenu( this );
		menuBar()->insertItem( "&Window", pMenuGLWinsize );
		pMenuGLWinsize->insertItem( "320x200", this,  SLOT(setGLWinSize320x200()), CTRL+Qt::Key_3);
		pMenuGLWinsize->insertItem( "400x400", this,  SLOT(setGLWinSize400x400()), CTRL+Qt::Key_4);
		pMenuGLWinsize->insertItem( "500x400", this,  SLOT(setGLWinSize500x400()), CTRL+Qt::Key_5);
		pMenuGLWinsize->insertItem( "500x500", this,  SLOT(setGLWinSize500x500()), CTRL+Qt::Key_2 );
		pMenuGLWinsize->insertItem( "640x480", this,  SLOT(setGLWinSize640x480()), CTRL+Qt::Key_6);
		pMenuGLWinsize->insertItem( "800x600", this,  SLOT(setGLWinSize800x600()), CTRL+Qt::Key_8);
		pMenuGLWinsize->insertItem( "1024x768", this,  SLOT(setGLWinSize1024x768()), CTRL+Qt::Key_1);
		pMenuGLWinsize->insertSeparator();
		pMenuGLWinsize->insertItem( "Swap Width/Height", this,  SLOT(swapWidthHeight()), CTRL+Key_W);
		pMenuGLWinsize->insertItem( "Input Width/Height", this,  SLOT(inputWidthHeight()), CTRL+Key_I);
	}


/*
	{
		QPopupMenu * pPopMenu = new QPopupMenu( this );
		menuBar()->insertItem( "&My Research", pPopMenu );
		pPopMenu->insertItem( "Bar Recons", this,  SLOT(detail_recon_bar()));
		pPopMenu->insertItem( "Vase Recons", this,  SLOT(detail_recon_vase()));
		pPopMenu->insertSeparator();
		pPopMenu->insertItem( "Letter Size Plate", this,  SLOT(detail_recon_a4plate()));
		pPopMenu->insertSeparator();
		pPopMenu->insertItem( "Detail Recon Dialog", this,  SLOT(detail_recon_anyobj()));
	} 
*/

	//================ end Rendering options ================================
	QGLFormat format;
	format.setStereo( true );
    m_pGLUIWin = new Viewer(format, this, "Viewer3D"); 
	assert(m_pGLUIWin!=NULL);
    statusBar()->setFixedHeight( fontMetrics().height() + 6 );
    statusBar()->message( "Viewer ready", 3000 );

    setCentralWidget(m_pGLUIWin);
	m_pGLUIWin->setDrawingData(&_drawParms);
	m_pGLUIWin->m_SceneGraph.hookObject(m_pGLUIWin);
	m_pGLUIWin->m_SceneGraph.hookGLWindow(m_pGLUIWin);

	//================ dock window==================
	QString appDir;
    m_pFemBar=_createDockWidgetBar(this, appDir);

}