VimridViewer::VimridViewer( VimridSettings &settings) : GlutApplication(settings), //StereoApplication(5.0, 60.0, 45.0, 5.5) // original from cube demos //StereoApplication(5.0, 60.0, 12.75, 1.35), // initial values (broken matrix) StereoApplication(5.0, 60.0, 15, 0.3), // best values for see3d theatre mDicomClient(DICOM_HOST, DICOM_PORT), mDicomResult(NULL), mDicomLoadingScreen(NULL), mMainMenu(NULL), mCameraPushedBack(false), mFilterMode(VV_FM_None), mDicomLoadCancel(false), mAlphaEnabled(true), mMenuAutoShown(false) { Title = "ViMRID Viewer"; EnableCursor = false; RenderFps = true; RenderCameraPosition = true; RenderDragInfo = true; RenderMouseInfo = true; RenderTrackdInfo = true; RenderStatusTextOnFinish = false; EnableRenderStatusText = false; if (GetUtility().IsTrackdEnabled()) { RenderTrackdInfo = true; } // Use the DICOM TCP client for downloading DICOM files. mDicomClient.SetDownloadCallback(_handleDownload); }
void UpdateIndexUtility(storage::DataTable* table, const std::vector<sample_frequency_map_entry>& list) { oid_t index_count = table->GetIndexCount(); for (oid_t index_itr = 0; index_itr < index_count; index_itr++) { // Get index auto index = table->GetIndex(index_itr); auto index_metadata = index->GetMetadata(); auto index_key_attrs = index_metadata->GetKeyAttrs(); std::set<oid_t> index_set(index_key_attrs.begin(), index_key_attrs.end()); // Get current index utility auto current_index_utility = GetCurrentIndexUtility(index_set, list); auto average_index_utility = index_metadata->GetUtility(); LOG_TRACE("Average index utility %5.2lf", average_index_utility); LOG_TRACE("Current index utility %5.2lf", current_index_utility); // alpha (weight for old samples) double alpha = 0.2; // Update index utility auto updated_average_index_utility = alpha * current_index_utility + (1 - alpha) * average_index_utility; index_metadata->SetUtility(updated_average_index_utility); LOG_TRACE("Updated index utility %5.2lf :: %s", updated_average_index_utility, index_metadata->GetInfo().c_str()); } }
void IndexTuner::DropIndexes(storage::DataTable* table) { oid_t index_count = table->GetIndexCount(); // Go over indices oid_t index_itr; for (index_itr = 0; index_itr < index_count; index_itr++) { auto index = table->GetIndex(index_itr); auto index_metadata = index->GetMetadata(); auto average_index_utility = index_metadata->GetUtility(); auto index_oid = index->GetOid(); // Check if index utility below threshold and drop if needed if (average_index_utility < index_utility_threshold) { LOG_TRACE("Dropping index : %s", index_metadata->GetInfo().c_str()); table->DropIndexWithOid(index_oid); // Update index count index_count = table->GetIndexCount(); } } }
CIDNet* CreateRandomIDNet(int num_nodes, int num_indep_nodes, int max_size_family, int num_decision_nodes, int max_num_states_chance_nodes, int max_num_states_decision_nodes, int min_utility, int max_utility, bool is_uniform_start_policy) { PNL_CHECK_RANGES(num_decision_nodes, 1, num_nodes-1); PNL_CHECK_LEFT_BORDER(max_num_states_chance_nodes, 1); PNL_CHECK_LEFT_BORDER(max_num_states_decision_nodes, 1); PNL_CHECK_LEFT_BORDER(max_utility, min_utility); CGraph* pGraph = CreateRandomAndSpecificForIDNetGraph(num_nodes, num_indep_nodes, max_size_family); if (!pGraph->IsDAG()) { PNL_THROW(CInconsistentType, " the graph should be a DAG "); } if (!pGraph->IsTopologicallySorted()) { PNL_THROW(CInconsistentType, " the graph should be sorted topologically "); } if (pGraph->NumberOfConnectivityComponents() > 1) { PNL_THROW(CInconsistentType, " the graph should be linked "); } int i, j, k; CNodeType *nodeTypes = new CNodeType [num_nodes]; intVector nonValueNodes(0); intVector posibleDecisionNodes(0); nonValueNodes.resize(0); posibleDecisionNodes.resize(0); for (i = 0; i < num_nodes; i++) { if (pGraph->GetNumberOfChildren(i) == 0) { nodeTypes[i].SetType(1, 1, nsValue); } else { nonValueNodes.push_back(i); posibleDecisionNodes.push_back(i); } } int ind_decision_node; int num_states; int index; int node; intVector neighbors(0); neighborTypeVector neigh_types(0); num_decision_nodes = (num_decision_nodes > posibleDecisionNodes.size()) ? posibleDecisionNodes.size() : num_decision_nodes; for (i = 0; (i < num_decision_nodes) && (posibleDecisionNodes.size()>0); i++) { ind_decision_node = rand() % posibleDecisionNodes.size(); node = posibleDecisionNodes[ind_decision_node]; num_states = GetRandomNumberOfStates(max_num_states_decision_nodes); nodeTypes[node].SetType(1, num_states, nsDecision); index = -1; for (j = 0; j < nonValueNodes.size(); j++) { if (nonValueNodes[j] == node) { index = j; break; } } if (index != -1) nonValueNodes.erase(nonValueNodes.begin() + index); posibleDecisionNodes.erase(posibleDecisionNodes.begin() + ind_decision_node); pGraph->GetNeighbors(node, &neighbors, &neigh_types); for (j = 0; j < neighbors.size(); j++) { index = -1; for (k = 0; k < posibleDecisionNodes.size(); k++) { if (neighbors[j] == posibleDecisionNodes[k]) { index = k; break; } } if (index != -1) posibleDecisionNodes.erase(posibleDecisionNodes.begin() + index); } } for (i = 0; i < nonValueNodes.size(); i++) { num_states = GetRandomNumberOfStates(max_num_states_chance_nodes); nodeTypes[nonValueNodes[i]].SetType(1, num_states, nsChance); } int *nodeAssociation = new int[num_nodes]; for (i = 0; i < num_nodes; i++) { nodeAssociation[i] = i; } CIDNet *pIDNet = CIDNet::Create(num_nodes, num_nodes, nodeTypes, nodeAssociation, pGraph); pGraph = pIDNet->GetGraph(); CModelDomain* pMD = pIDNet->GetModelDomain(); CFactor **myParams = new CFactor*[num_nodes]; int *nodeNumbers = new int[num_nodes]; int **domains = new int*[num_nodes]; intVector parents(0); for (i = 0; i < num_nodes; i++) { nodeNumbers[i] = pGraph->GetNumberOfParents(i) + 1; domains[i] = new int[nodeNumbers[i]]; pGraph->GetParents(i, &parents); for (j = 0; j < parents.size(); j++) { domains[i][j] = parents[j]; } domains[i][nodeNumbers[i]-1] = i; } pIDNet->AllocFactors(); for (i = 0; i < num_nodes; i++) { myParams[i] = CTabularCPD::Create(domains[i], nodeNumbers[i], pMD); } float **data = new float*[num_nodes]; int size_data; int num_states_node; int num_blocks; intVector size_nodes(0); float belief, sum_beliefs; for (i = 0; i < num_nodes; i++) { size_data = 1; size_nodes.resize(0); for (j = 0; j < nodeNumbers[i]; j++) { size_nodes.push_back(pIDNet->GetNodeType(domains[i][j])->GetNodeSize()); size_data *= size_nodes[j]; } num_states_node = size_nodes[size_nodes.size() - 1]; num_blocks = size_data / num_states_node; data[i] = new float[size_data]; switch (pIDNet->GetNodeType(i)->GetNodeState()) { case nsChance: { for (j = 0; j < num_blocks; j++) { sum_beliefs = 0.0; for (k = 0; k < num_states_node - 1; k++) { belief = GetBelief(1.0f - sum_beliefs); data[i][j * num_states_node + k] = belief; sum_beliefs += belief; } belief = 1.0f - sum_beliefs; data[i][j * num_states_node + num_states_node - 1] = belief; } break; } case nsDecision: { if (is_uniform_start_policy) { belief = 1.0f / float(num_states_node); for (j = 0; j < num_blocks; j++) { sum_beliefs = 0.0; for (k = 0; k < num_states_node - 1; k++) { data[i][j * num_states_node + k] = belief; sum_beliefs += belief; } data[i][j * num_states_node + num_states_node - 1] = 1.0f - sum_beliefs; } } else { for (j = 0; j < num_blocks; j++) { sum_beliefs = 0.0; for (k = 0; k < num_states_node - 1; k++) { belief = GetBelief(1.0f - sum_beliefs); data[i][j * num_states_node + k] = belief; sum_beliefs += belief; } belief = 1.0f - sum_beliefs; data[i][j * num_states_node + num_states_node - 1] = belief; } } break; } case nsValue: { for (j = 0; j < num_blocks; j++) { data[i][j] = float(GetUtility(min_utility, max_utility)); } break; } } } for (i = 0; i < num_nodes; i++) { myParams[i]->AllocMatrix(data[i], matTable); pIDNet->AttachFactor(myParams[i]); } delete [] nodeTypes; delete [] nodeAssociation; return pIDNet; }
void VimridViewer::OnControlSelectRelease(Control &control) { // HACK: Comparing text when pointer should be compared. if ((control.GetName() == "loadDicomSet1Button") || (control.GetName() == "loadDicomSet2Button") || (control.GetName() == "loadDicomSet3Button") || (control.GetName() == "loadDicomSet4Button")) { const Button *buttonPtr = dynamic_cast<const Button*>(&control); mDicomClient.DownloadAsync(buttonPtr->GetText()); } // HACK: Comparing text when pointer should be compared. if (control.GetName() == "toggleStatusButton") { EnableRenderStatusText = !EnableRenderStatusText; } // Cancel loading of DICOM data. if (&control == mFilterLoadingScreenCancelButton) { mDicomLoadCancel = true; } // Turns transparency on and off. if (&control == mToggleAlphaButton) { mAlphaEnabled = !mAlphaEnabled; } if (&control == mFilterRestoreButton) { pthread_create(&mFilterRestoreThread, NULL, _filterRestore, NULL); } /* HACK: If any other button pressed, filter mode is reset. This * conveniently does the same thing as what the cancel button does * so it works fine for the time being, but this should only really * be reset on specific scenarios (such as cancel button press). */ mFilterMode = VV_FM_None; if (&control == mSobelXNormalButton) { mFilterMode = VV_FM_SobelXNormal; } else if (&control == mSobelYNormalButton) { mFilterMode = VV_FM_SobelYNormal; } else if (&control == mSobelXYNormalButton) { mFilterMode = VV_FM_SobelXYNormal; } else if (&control == mSobelXYScopedButton) { mFilterMode = VV_FM_SobelXYScoped; } // Once filter mode potentially set, check and if it is, process! if (mFilterMode != VV_FM_None) { pthread_create(&mProcessorThread, NULL, _processImages, NULL); } if (&control == mToggleStereoButton) { if (IsStereoEnabled()) { DisableStereo(); } else { EnableStereo(); } } if (&control == mToggleTrackdButton) { VimridMenu &mainMenu = *mMainMenu; if (GetUtility().IsTrackdEnabled()) { GetUtility().DisableTrackd(); GetUiContainer().ResetCursor(); if (mainMenu.HasToggleMode(UI_MTM_CENTRE_CURSOR)) { mainMenu.RemoveToggleMode(UI_MTM_CENTRE_CURSOR); } } else { GetUtility().EnableTrackd(); GetUiContainer().CentreCursor(*mMainMenu); if (!mainMenu.HasToggleMode(UI_MTM_CENTRE_CURSOR)) { mainMenu.AddToggleMode(UI_MTM_CENTRE_CURSOR); } } } if (&control == mExitVimridButton) { Exit(); } }
void VimridViewer::setupInterface() { const VColour4F buttonBackground = VColour4F(0.85, 0.85, 0.87, 0.7); const VColour4F buttonTextColour = VColour4F(0.2, 0.2, 0.22, 1.0); const VColour4F labelTextColour = VColour4F(0.8, 0.8, 0.8, 1.0); mMainMenu = new VimridMenu(*this); VimridMenu &mainMenu = *mMainMenu; mainMenu.SetName("mainMenu"); mainMenu.SetSize(VSizeF(230,380)); mainMenu.AddToggleMode(UI_MTM_HIDE); mainMenu.AddToggleMode(UI_MTM_SHOW); GetUiContainer().AddChild(mainMenu); if (GetUtility().IsTrackdEnabled()) { /* When trackd is enabled, centre the cursor in the middle of the * menu so the user doesn't need to move it to the menu area manually. */ mainMenu.AddToggleMode(UI_MTM_CENTRE_CURSOR); } VSizeF buttonSize = VSizeF(mainMenu.GetSize().Width - 10, 40); VimridMenu &dicomMenu = *new VimridMenu(*this); dicomMenu.SetName("dicomMenu"); dicomMenu.SetSize(VSizeF(300,230)); dicomMenu.AddToggleMode(UI_MTM_HIDE); GetUiContainer().AddChild(dicomMenu); VimridMenu &filterMenu = *new VimridMenu(*this); filterMenu.SetName("filtersMenu"); filterMenu.SetSize(VSizeF(300,280)); filterMenu.AddToggleMode(UI_MTM_HIDE); GetUiContainer().AddChild(filterMenu); mDicomLoadingScreen = new VimridMenu(*this); VimridMenu &dicomLoadingScreen = *mDicomLoadingScreen; dicomLoadingScreen.SetName("dicomLoadingScreen"); dicomLoadingScreen.SetSize(VSizeF(210,95)); dicomLoadingScreen.AddToggleMode(UI_MTM_SUSPEND); GetUiContainer().AddChild(dicomLoadingScreen); mFilterLoadingScreen = new VimridMenu(*this); VimridMenu &filterLoadingScreen = *mFilterLoadingScreen; filterLoadingScreen.SetName("filterLoadingScreen"); filterLoadingScreen.SetSize(VSizeF(210,95)); filterLoadingScreen.AddToggleMode(UI_MTM_SUSPEND); GetUiContainer().AddChild(filterLoadingScreen); Label &mainTitleLabel = *new Label("ViMRID - Main Menu"); mainTitleLabel.SetPosition(VPoint2f(5, 7)); mainTitleLabel.SetTextColour(labelTextColour); mainMenu.AddChild(mainTitleLabel); Button &loadDicomButton = *new Button("Load DICOM Data"); loadDicomButton.SetName("loadDicomButton"); loadDicomButton.SetPosition(VPoint2f(5, 35)); loadDicomButton.SetSize(buttonSize); loadDicomButton.SetBackground(buttonBackground); loadDicomButton.SetTextColour(buttonTextColour); loadDicomButton.SetShowControl(dicomMenu); loadDicomButton.AddSelectAction(UI_BSA_HIDE_PARENT); loadDicomButton.AddSelectAction(UI_BSA_SHOW_CONTROL); mainMenu.AddChild(loadDicomButton); mFilterMenuButton = new Button("Apply Image Filters"); Button &filterMenuButton = *mFilterMenuButton; filterMenuButton.SetName("filterMenuButton"); filterMenuButton.SetPosition(VPoint2f(5, 85)); filterMenuButton.SetSize(buttonSize); filterMenuButton.SetBackground(buttonBackground); filterMenuButton.SetTextColour(buttonTextColour); filterMenuButton.SetShowControl(filterMenu); filterMenuButton.AddSelectAction(UI_BSA_HIDE_PARENT); filterMenuButton.AddSelectAction(UI_BSA_SHOW_CONTROL); filterMenuButton.Disable(); mainMenu.AddChild(filterMenuButton); Button &toggleStatusButton = *new Button("Toggle Status Text"); toggleStatusButton.SetName("toggleStatusButton"); toggleStatusButton.SetPosition(VPoint2f(5, 135)); toggleStatusButton.SetSize(buttonSize); toggleStatusButton.SetBackground(buttonBackground); toggleStatusButton.SetTextColour(buttonTextColour); mainMenu.AddChild(toggleStatusButton); mToggleStereoButton = new Button("Toggle Stereography"); Button &toggleStereoButton = *mToggleStereoButton; toggleStereoButton.SetName("toggleStereoButton"); toggleStereoButton.SetPosition(VPoint2f(5, 185)); toggleStereoButton.SetSize(buttonSize); toggleStereoButton.SetBackground(buttonBackground); toggleStereoButton.SetTextColour(buttonTextColour); mainMenu.AddChild(toggleStereoButton); mToggleTrackdButton = new Button("Toggle Motion Sensing"); Button &toggleTrackdButton = *mToggleTrackdButton; toggleTrackdButton.SetName("toggleTrackdButton"); toggleTrackdButton.SetPosition(VPoint2f(5, 235)); toggleTrackdButton.SetSize(buttonSize); toggleTrackdButton.SetBackground(buttonBackground); toggleTrackdButton.SetTextColour(buttonTextColour); mainMenu.AddChild(toggleTrackdButton); // Disable motion sensor toggle if disabled. if (!GetUtility().IsTrackdSupported()) { toggleTrackdButton.Disable(); } mToggleAlphaButton = new Button("Toggle Transparency"); Button &toggleAlphaButton = *mToggleAlphaButton; toggleAlphaButton.SetName("toggleAlphaButton"); toggleAlphaButton.SetPosition(VPoint2f(5, 285)); toggleAlphaButton.SetSize(buttonSize); toggleAlphaButton.SetBackground(buttonBackground); toggleAlphaButton.SetTextColour(buttonTextColour); mainMenu.AddChild(toggleAlphaButton); mExitVimridButton = new Button("Exit ViMRID"); Button &exitVimridButton = *mExitVimridButton; exitVimridButton.SetName("exitVimridButton"); exitVimridButton.SetPosition(VPoint2f(5, 335)); exitVimridButton.SetSize(buttonSize); exitVimridButton.SetBackground(buttonBackground); exitVimridButton.SetTextColour(buttonTextColour); mainMenu.AddChild(exitVimridButton); Label &dicomTitleLabel = *new Label("ViMRID - Load DICOM Data"); dicomTitleLabel.SetPosition(VPoint2f(5, 7)); dicomTitleLabel.SetTextColour(labelTextColour); dicomMenu.AddChild(dicomTitleLabel); Button &loadDicomSet1Button = *new Button("SDY00000/SRS00000"); loadDicomSet1Button.SetName("loadDicomSet1Button"); loadDicomSet1Button.SetPosition(VPoint2f(5, 35)); loadDicomSet1Button.SetSize(VSizeF(dicomMenu.GetSize().Width - 10, 40)); loadDicomSet1Button.SetBackground(buttonBackground); loadDicomSet1Button.SetTextColour(buttonTextColour); loadDicomSet1Button.SetShowControl(dicomLoadingScreen); loadDicomSet1Button.AddSelectAction(UI_BSA_HIDE_PARENT); loadDicomSet1Button.AddSelectAction(UI_BSA_SHOW_CONTROL); dicomMenu.AddChild(loadDicomSet1Button); Button &loadDicomSet2Button = *new Button("SDY00000/SRS00001"); loadDicomSet2Button.SetName("loadDicomSet2Button"); loadDicomSet2Button.SetPosition(VPoint2f(5, 85)); loadDicomSet2Button.SetSize(VSizeF(dicomMenu.GetSize().Width - 10, 40)); loadDicomSet2Button.SetBackground(buttonBackground); loadDicomSet2Button.SetTextColour(buttonTextColour); loadDicomSet2Button.SetShowControl(dicomLoadingScreen); loadDicomSet2Button.AddSelectAction(UI_BSA_HIDE_PARENT); loadDicomSet2Button.AddSelectAction(UI_BSA_SHOW_CONTROL); dicomMenu.AddChild(loadDicomSet2Button); Button &loadDicomSet3Button = *new Button("SDY00001/SRS00000"); loadDicomSet3Button.SetName("loadDicomSet3Button"); loadDicomSet3Button.SetPosition(VPoint2f(5, 135)); loadDicomSet3Button.SetSize(VSizeF(dicomMenu.GetSize().Width - 10, 40)); loadDicomSet3Button.SetBackground(buttonBackground); loadDicomSet3Button.SetTextColour(buttonTextColour); loadDicomSet3Button.SetShowControl(dicomLoadingScreen); loadDicomSet3Button.AddSelectAction(UI_BSA_HIDE_PARENT); loadDicomSet3Button.AddSelectAction(UI_BSA_SHOW_CONTROL); dicomMenu.AddChild(loadDicomSet3Button); Button &loadDicomSet4Button = *new Button("SDY00001/SRS00001"); loadDicomSet4Button.SetName("loadDicomSet4Button"); loadDicomSet4Button.SetPosition(VPoint2f(5, 185)); loadDicomSet4Button.SetSize(VSizeF(dicomMenu.GetSize().Width - 10, 40)); loadDicomSet4Button.SetBackground(buttonBackground); loadDicomSet4Button.SetTextColour(buttonTextColour); loadDicomSet4Button.SetShowControl(dicomLoadingScreen); loadDicomSet4Button.AddSelectAction(UI_BSA_HIDE_PARENT); loadDicomSet4Button.AddSelectAction(UI_BSA_SHOW_CONTROL); dicomMenu.AddChild(loadDicomSet4Button); Label &dicomLoadingScreenLabel = *new Label("Loading DICOM data..."); dicomLoadingScreenLabel.SetPosition(VPoint2f(10, 10)); dicomLoadingScreenLabel.SetTextColour(labelTextColour); dicomLoadingScreen.AddChild(dicomLoadingScreenLabel); Button &dicomLoadingScreenCancelButton = *new Button("Cancel"); dicomLoadingScreenCancelButton.SetName("dicomLoadingScreenCancelButton"); dicomLoadingScreenCancelButton.SetPosition(VPoint2f(65, 40)); dicomLoadingScreenCancelButton.SetSize(VSizeF(75, 40)); dicomLoadingScreenCancelButton.SetBackground(buttonBackground); dicomLoadingScreenCancelButton.SetTextColour(buttonTextColour); dicomLoadingScreenCancelButton.SetShowControl(dicomMenu); dicomLoadingScreenCancelButton.AddSelectAction(UI_BSA_HIDE_PARENT); dicomLoadingScreenCancelButton.AddSelectAction(UI_BSA_SHOW_CONTROL); dicomLoadingScreen.AddChild(dicomLoadingScreenCancelButton); Label &filterMenuTitleLabel = *new Label("ViMRID - Apply Image Filters"); filterMenuTitleLabel.SetPosition(VPoint2f(5, 7)); filterMenuTitleLabel.SetTextColour(labelTextColour); filterMenu.AddChild(filterMenuTitleLabel); mSobelXNormalButton = new Button("Sobel X (Normal)"); Button &sobelXNormalButton = *mSobelXNormalButton; sobelXNormalButton.SetName("sobelXNormalButton"); sobelXNormalButton.SetPosition(VPoint2f(5, 35)); sobelXNormalButton.SetSize(VSizeF(filterMenu.GetSize().Width - 10, 40)); sobelXNormalButton.SetBackground(buttonBackground); sobelXNormalButton.SetTextColour(buttonTextColour); sobelXNormalButton.SetShowControl(filterLoadingScreen); sobelXNormalButton.AddSelectAction(UI_BSA_HIDE_PARENT); sobelXNormalButton.AddSelectAction(UI_BSA_SHOW_CONTROL); filterMenu.AddChild(sobelXNormalButton); mSobelYNormalButton = new Button("Sobel Y (Normal)"); Button &sobelYNormalButton = *mSobelYNormalButton; sobelYNormalButton.SetName("sobelYNormalButton"); sobelYNormalButton.SetPosition(VPoint2f(5, 85)); sobelYNormalButton.SetSize(VSizeF(filterMenu.GetSize().Width - 10, 40)); sobelYNormalButton.SetBackground(buttonBackground); sobelYNormalButton.SetTextColour(buttonTextColour); sobelYNormalButton.SetShowControl(filterLoadingScreen); sobelYNormalButton.AddSelectAction(UI_BSA_HIDE_PARENT); sobelYNormalButton.AddSelectAction(UI_BSA_SHOW_CONTROL); filterMenu.AddChild(sobelYNormalButton); mSobelXYNormalButton = new Button("Sobel X+Y (Normal)"); Button &sobelXYNormalButton = *mSobelXYNormalButton; sobelXYNormalButton.SetName("sobelXYNormalButton"); sobelXYNormalButton.SetPosition(VPoint2f(5, 135)); sobelXYNormalButton.SetSize(VSizeF(filterMenu.GetSize().Width - 10, 40)); sobelXYNormalButton.SetBackground(buttonBackground); sobelXYNormalButton.SetTextColour(buttonTextColour); sobelXYNormalButton.SetShowControl(filterLoadingScreen); sobelXYNormalButton.AddSelectAction(UI_BSA_HIDE_PARENT); sobelXYNormalButton.AddSelectAction(UI_BSA_SHOW_CONTROL); filterMenu.AddChild(sobelXYNormalButton); mSobelXYScopedButton = new Button("Sobel X+Y (Scoped)"); Button &sobelXYScopedButton = *mSobelXYScopedButton; sobelXYScopedButton.SetName("sobelXYScopedButton"); sobelXYScopedButton.SetPosition(VPoint2f(5, 185)); sobelXYScopedButton.SetSize(VSizeF(filterMenu.GetSize().Width - 10, 40)); sobelXYScopedButton.SetBackground(buttonBackground); sobelXYScopedButton.SetTextColour(buttonTextColour); sobelXYScopedButton.SetShowControl(filterLoadingScreen); sobelXYScopedButton.AddSelectAction(UI_BSA_HIDE_PARENT); sobelXYScopedButton.AddSelectAction(UI_BSA_SHOW_CONTROL); filterMenu.AddChild(sobelXYScopedButton); mFilterRestoreButton = new Button("Restore source image"); Button &filterRestoreButton = *mFilterRestoreButton; filterRestoreButton.SetName("filterRestoreButton"); filterRestoreButton.SetPosition(VPoint2f(5, 235)); filterRestoreButton.SetSize(VSizeF(filterMenu.GetSize().Width - 10, 40)); filterRestoreButton.SetBackground(buttonBackground); filterRestoreButton.SetTextColour(buttonTextColour); filterMenu.AddChild(filterRestoreButton); Label &filterLoadingScreenLabel = *new Label("Applying image filter..."); filterLoadingScreenLabel.SetPosition(VPoint2f(10, 10)); filterLoadingScreenLabel.SetTextColour(labelTextColour); filterLoadingScreen.AddChild(filterLoadingScreenLabel); mFilterLoadingScreenCancelButton = new Button("Cancel"); Button &filterLoadingScreenCancelButton = *mFilterLoadingScreenCancelButton; filterLoadingScreenCancelButton.SetName("filterLoadingScreenCancelButton"); filterLoadingScreenCancelButton.SetPosition(VPoint2f(65, 40)); filterLoadingScreenCancelButton.SetSize(VSizeF(75, 40)); filterLoadingScreenCancelButton.SetBackground(buttonBackground); filterLoadingScreenCancelButton.SetTextColour(buttonTextColour); filterLoadingScreenCancelButton.SetShowControl(filterMenu); filterLoadingScreenCancelButton.AddSelectAction(UI_BSA_HIDE_PARENT); filterLoadingScreenCancelButton.AddSelectAction(UI_BSA_SHOW_CONTROL); filterLoadingScreen.AddChild(filterLoadingScreenCancelButton); }
void VimridViewer::Update() { this->GlutApplication::Update(); // Calculate a general speed based on delta. VFloat deltaSpeed = GetUtility().GetDeltaTime() * 0.1; VPoint3f dragVector = getCameraDragVector(); VFloat mDragSpeed = 1; mCameraDragDelta = dragVector - mLastCameraDragVector; mCameraAnimationTarget += mCameraDragDelta * mDragSpeed * deltaSpeed; VFloat maximumY = 170.0; if (mCameraAnimationTarget.Y > maximumY) { mCameraAnimationTarget.Y = maximumY; } VFloat minimumY = 5.0; if (mCameraAnimationTarget.Y < minimumY) { mCameraAnimationTarget.Y = minimumY; } VFloat minZ = -25.0; if (mCameraAnimationTarget.Z < minZ) { mCameraAnimationTarget.Z = minZ; } VFloat maxZ = -7.5; if (mCameraAnimationTarget.Z > maxZ) { mCameraAnimationTarget.Z = maxZ; } const VFloat zSpeed = 0.03; const VFloat fpSpeed = 0.03; const VFloat esSpeed = 0.01; if (IsSpecialKeyPressed(GLUT_KEY_UP)) { mCameraAnimationTarget.Z += zSpeed * deltaSpeed; } if (IsSpecialKeyPressed(GLUT_KEY_DOWN)) { mCameraAnimationTarget.Z -= zSpeed * deltaSpeed; } if (IsSpecialKeyPressed(GLUT_KEY_PAGE_UP)) { GetFixationPoint() -= fpSpeed * deltaSpeed; } if (IsSpecialKeyPressed(GLUT_KEY_PAGE_DOWN)) { GetFixationPoint() += fpSpeed * deltaSpeed; } if (IsSpecialKeyPressed(GLUT_KEY_LEFT)) { GetEyeSeparation() -= esSpeed * deltaSpeed; } if (IsSpecialKeyPressed(GLUT_KEY_RIGHT)) { GetEyeSeparation() += esSpeed * deltaSpeed; } UpdateSprites(); GetMriVisualiser().Update(); // Keep checking to see if there are textures that need creating. if (GetTextureManager().IsCreatePending()) { GetTextureManager().CreateAll(); WRITE_DEBUG_TEXT("Textures were created."); } string te = (GetUtility().IsTrackdEnabled() ? "Enabled" : "Disabled"); string se = (IsStereoEnabled() ? "Enabled" : "Disabled"); ADD_STATUS_LINE( "[Motion Sensing: " << te << "] " << "[Stereography: " << se << "]"); VFloat fp = GetFixationPoint(); VFloat es = GetEyeSeparation(); ADD_STATUS_LINE( "[Fixation Point: " << fp << "] " << "[Eye Separation: " << es << "]"); ADD_STATUS_LINE("[Smooth Cursor: " << GetUtility().GetCursorPositionSmooth() << "]"); /* HACK: Big hack! This needs making more robust, currently it just * looks at the Y axis and the code is very difficult to modify. Should * also be abstracted out of this class. */ /*VFloat minimumY = 5.0; VFloat maximumY = 170.0; VPoint3f baseCamera = this->GlutApplication::GetCameraVector(); if (GetCameraVector().Y < minimumY) { // Only counter if the cursor was moved down. if ((mLastCameraVector.Y - GetCameraVector().Y) > 0) { // Record the amount that the user has over-stepped. mCameraCouteract.Y = baseCamera.Y - minimumY; } } if (GetCameraVector().Y > maximumY) { // Counter if moved upward. if ((mLastCameraVector.Y - GetCameraVector().Y) < 0) { mCameraCouteract.Y = baseCamera.Y - maximumY; } } ADD_STATUS_LINE("[Camera Counteract: " << mCameraCouteract << "]"); mLastCameraVector = GetCameraVector();*/ /* Smoothly move the camera toward the target based on delta time so * it's constant over all computers. Don't bother altering if the sync * is only off by 0.1 point (otherwise camera twich occurs). */ VPoint3f animateDistance = mCameraAnimationTarget - mCameraAnimationBuffer; //if ((trimSync > VPoint3f(0.1, 0.1, 0.1)) || (trimSync < VPoint3f(-0.1, -0.1, -0.1))) { const VFloat animateSpeed = 0.05; mCameraAnimationBuffer += animateDistance * animateSpeed * deltaSpeed; } mLastCameraDragVector = dragVector; if (!mMenuAutoShown) { // Reset cursor so it appears centered in menu. GetUtility().ResetCursor(); // Show during init to ensure UI container has been setup. mMainMenu->Show(); mMenuAutoShown = true; } }