void FolderWindow::SetStructures(int folderIndex) { StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager(); Folder* folder = structureManager->GetFolderAt(folderIndex); m_folderIndex = folderIndex; int shift = 0; for( int ui = 0; ui < folder->structCount; ui++) { if(folder->folderStructs[(ui+shift)] == -1) { shift++; } int i = folder->folderStructs[(ui+shift)]; RNAStructure *strct = structureManager->GetStructure(i); AddStructure(strct->GetFilename(), i); } label(folder->folderName); char structLabel[MAX_BUFFER_SIZE]; snprintf(structLabel, MAX_BUFFER_SIZE - 1, " \n\n\n\n\n%s", folder->folderName); ConfigParser::nullTerminateString(structLabel); copy_label(structLabel); labelsize(1.25 * LOCAL_TEXT_SIZE); align(FL_ALIGN_TOP); }
void FolderWindow::SetStructures(int folderIndex) { StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager(); Folder* folder = structureManager->GetFolderAt(folderIndex); m_folderIndex = folderIndex; int shift = 0; for( int ui = 0; ui < folder->structCount; ui++) { if(folder->folderStructs[(ui+shift)] == -1) { shift++; } int i = folder->folderStructs[(ui+shift)]; RNAStructure *strct = structureManager->GetStructure(i); AddStructure(strct->GetFilename(), i); } this->label(folder->folderName); /*sprintf(title, "Folder: %-.48s", structureManager->GetFolderAt(folderIndex)->folderName); label(title);*/ }
/*May not be quite right, modified from orignial code*/ void StatsWindow::ClearTruthValues() { StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager(); Folder* folder = structureManager->GetFolderAt(folderIndex); int shift = 0; for(int i = 0; i < folder->structCount; i++) { if(folder->folderStructs[(i + shift)] == -1) shift++; if(folder->folderStructs[(i + shift)] != -1) { RNAStructure *structure = structureManager->GetStructure((i+shift)); if(!structure) continue; int length = structure->GetLength(); for (int j = 0; j < length; ++j) { structure->GetBaseAt(j)->m_truth = RNAStructure::TruePositive; } } } }
void DiagramWindow::draw() { Fl_Color priorColor = fl_color(); int priorFont = fl_font(); int priorFontSize = fl_size(); fl_color(color()); fl_rectf(0, 0, w(), h()); fl_color(priorColor); Fl_Window::draw(); // Get the structures. Be sure the reference structure is first. RNAStructure* sequences[3]; StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager(); for (int j = 0; j < 3; ++j) { if ((int)(m_menuItems[m_menus[j]->value()].user_data()) == -1) { sequences[j] = 0; } else { sequences[j] = structureManager->GetStructure((int)(m_menuItems[m_menus[j]->value()].user_data())); } } int numToDraw = 0; if (sequences[0]) { if (sequences[1]) { if (sequences[2]) { numToDraw = 3; DrawKey3(); } else { numToDraw = 2; DrawKey2(0, 1); } } else { if (sequences[2]) { sequences[1] = sequences[2]; DrawKey2(0, 2); numToDraw = 2; } else { DrawKey1(0); numToDraw = 1; } } } else { if (sequences[1]) { if (sequences[2]) { sequences[0] = sequences[1]; sequences[1] = sequences[2]; DrawKey2(1, 2); numToDraw = 2; } else { sequences[0] = sequences[1]; DrawKey1(1); numToDraw = 1; } } else { if (sequences[2]) { sequences[0] = sequences[2]; DrawKey1(2); numToDraw = 1; } else { numToDraw = 0; } } } if (m_redrawStructures) { { fl_begin_offscreen(m_offscreenImage[0]); RedrawBuffer(sequences, numToDraw, 2048); fl_read_image(m_imageData[0], 0, 0, 2048, 2048); fl_end_offscreen(); } { fl_begin_offscreen(m_offscreenImage[1]); RedrawBuffer(sequences, numToDraw, 1024); fl_read_image(m_imageData[1], 0, 0, 1024, 1024); fl_end_offscreen(); } m_glWindow->UpdateTexture(); m_redrawStructures = false; } m_glWindow->redraw(); fl_color(priorColor); fl_font(priorFont, priorFontSize); fl_line_style(0); }
void DiagramWindow::RebuildMenus() { // Create the menus, if they don't already exist. int activeMenuIndex[3]; bool activeSet[3]; if (!m_menus[0]) { this->begin(); Fl_Box* label = new Fl_Box(ms_menu_minx[0], 0, ms_menu_width, 25, "Structure 1"); label->labelcolor(FL_WHITE); label = new Fl_Box(ms_menu_minx[1], 0, ms_menu_width, 25, "Structure 2"); label->labelcolor(FL_WHITE); label = new Fl_Box(ms_menu_minx[2], 0, ms_menu_width, 25, "Structure 3"); label->labelcolor(FL_WHITE); m_menus[0] = new Fl_Choice(ms_menu_minx[0], 25, ms_menu_width, 25); m_menus[1] = new Fl_Choice(ms_menu_minx[1], 25, ms_menu_width, 25); m_menus[2] = new Fl_Choice(ms_menu_minx[2], 25, ms_menu_width, 25); m_menus[0]->callback(MenuCallback); m_menus[1]->callback(MenuCallback); m_menus[2]->callback(MenuCallback); activeMenuIndex[0] = -1; activeMenuIndex[1] = -1; activeMenuIndex[2] = -1; activeSet[0] = false; activeSet[1] = false; activeSet[2] = false; this->end(); } else { // Cache the current active index, if any for (int j = 0; j < 3; ++j) { activeMenuIndex[j] = (int)m_menus[j]->mvalue()->user_data(); activeSet[j] = false; } } // Remove any unnecessary menu items for (int i = m_structures.size() + 1; i < m_menuItemsSize; ++i) { m_menuItems[i].label(0); } // Reallocate if necessary if ((int)m_structures.size() + 2 > m_menuItemsSize) { m_menuItemsSize = m_structures.size() + 2; free(m_menuItems); m_menuItems = (Fl_Menu_Item*)malloc(sizeof(Fl_Menu_Item) * m_menuItemsSize); m_menuItems[0].label("None"); m_menuItems[0].shortcut(0); m_menuItems[0].user_data((void*)-1); for (int i = 0; i < m_menuItemsSize; ++i) { m_menuItems[i].callback((Fl_Callback*)0); m_menuItems[i].labeltype(FL_NORMAL_LABEL); m_menuItems[i].labelsize(m_menus[0]->textsize()); m_menuItems[i].labelcolor(FL_BLACK); m_menuItems[i].labelfont(m_menus[0]->textfont()); m_menuItems[i].flags = 0; } m_menus[0]->menu(m_menuItems); m_menus[1]->menu(m_menuItems); m_menus[2]->menu(m_menuItems); } // Add entries StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager(); for (unsigned int ui = 0; ui < m_structures.size(); ++ui) { RNAStructure* structure = structureManager->GetStructure(m_structures[ui]); m_menuItems[ui + 1].label(structure->GetFilename()); m_menuItems[ui + 1].user_data((void*)m_structures[ui]); m_menuItems[ui + 1].shortcut(0); for (int j = 0; j < 3; ++j) { if (activeMenuIndex[j] == m_structures[ui]) { m_menus[j]->value(ui + 1); activeSet[j] = true; } } } // Reset active entries that have not already been set, and set the last entry to NULL label m_menuItems[m_structures.size() + 1].label(0); for (int j = 0; j < 3; ++j) { if (!activeSet[j]) { m_menus[j]->value(m_menuItems); } } }
/*May not be quite right, modified from orignial code*/ void StatsWindow::UpdateTruthValues() { if (referenceIndex == -1) { ClearTruthValues(); return; } StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager(); Folder* folder = structureManager->GetFolderAt(folderIndex); RNAStructure* refStructure = structureManager->GetStructure(referenceIndex); int length = refStructure->GetLength(); for (int j = 0; j < length; ++j) { refStructure->GetBaseAt(j)->m_truth = RNAStructure::TruePositive; } int shift = 0; for (int i = 0; i < folder->structCount; ++i) { if(folder->folderStructs[(i + shift)] == -1) shift++; if(folder->folderStructs[(i + shift)] != -1) { RNAStructure* otherStructure = structureManager->GetStructure((i+shift)); if (!otherStructure || otherStructure == refStructure) continue; for (int j = 0; j < length; ++j) { RNAStructure::BaseData* refBase = refStructure->GetBaseAt(j); RNAStructure::BaseData* otherBase = otherStructure->GetBaseAt(j); if (refBase->m_pair == RNAStructure::UNPAIRED) { if (otherBase->m_pair == RNAStructure::UNPAIRED) { otherBase->m_truth = RNAStructure::TrueNegative; } else { otherBase->m_truth = RNAStructure::FalsePositive; } } else { if (otherBase->m_pair == RNAStructure::UNPAIRED) { otherBase->m_truth = RNAStructure::FalseNegative; } else if (otherBase->m_pair == refBase->m_pair) { otherBase->m_truth = RNAStructure::TruePositive; } else { otherBase->m_truth = RNAStructure::FalsePositive; } } } } } }
void DrawingWindow::draw() { Fl_Double_Window::draw(); if (m_activeIndices.empty()) return; // Get the structures. Be sure the reference structure is first. RNAStructure** sequences = (RNAStructure**)malloc(sizeof(RNAStructure*) * m_activeIndices.size()); StructureManager* structureManager = RNAStructViz::GetStructureManager(); int posn = 0; for (unsigned int i = 0; i < m_activeIndices.size(); ++i) { if (m_activeIndices[i] == structureManager->GetReferenceStructure()) { sequences[posn++] = structureManager->GetStructure(m_activeIndices[i]); } } for (unsigned int i = 0; i < m_activeIndices.size(); ++i) { if (m_activeIndices[i] != structureManager->GetReferenceStructure()) { sequences[posn++] = structureManager->GetStructure(m_activeIndices[i]); } } fl_color(FL_BLACK); // Draw the circle of bases int numBases = sequences[0]->GetLength(); float angleDelta = (M_PI * 2.0f - 0.2f) / (float)numBases; float centerX = (float)w() / 2.0f; float centerY = (float)h() / 2.0f; float radius = centerX < centerY ? centerX - 20.f : centerY - 20.f; float angle = 1.5f * M_PI - 0.1f; for (int i = 0; i < numBases; ++i) { float xPosn = centerX + cos(angle) * radius; float yPosn = centerY - sin(angle) * radius; switch (sequences[0]->GetBaseAt(i)->m_base) { case RNAStructure::A: fl_draw("A", xPosn, yPosn); break; case RNAStructure::C: fl_draw("C", xPosn, yPosn); break; case RNAStructure::G: fl_draw("G", xPosn, yPosn); break; case RNAStructure::U: fl_draw("U", xPosn, yPosn); break; } angle -= angleDelta; fl_point((int)xPosn, (int)yPosn); } // Clean up free(sequences); }
InputWindow::InputWindow(int w, int h, const char *label, const char *defaultName, InputWindowType type, int folderIndex) : Fl_Window(MAX(w, 445), h, label), cbUseDefaultNames(NULL), ctFileChooser(NULL), userWindowStatus(OK), fileSelectionIndex(-1) { string = (char*)malloc(sizeof(char)*90); color(GUI_WINDOW_BGCOLOR); set_modal(); windowType = type; inputText = (char *) malloc(MAX_BUFFER_SIZE * sizeof(char)); if(type == InputWindow::FILE_INPUT) { strncpy(inputText, defaultName, MAX_BUFFER_SIZE - 1); inputText[MAX_BUFFER_SIZE - 1] = '\0'; char *extPtr = strrchr(inputText, '.'); if(extPtr != NULL) { *extPtr = '\0'; } char *filenameStartPtr = strrchr(inputText, '/'); int fnameStartPos; if(filenameStartPtr != NULL) { fnameStartPos = filenameStartPtr - inputText; } else { fnameStartPos = 0; } char saveDirInfo[MAX_BUFFER_SIZE]; snprintf(saveDirInfo, fnameStartPos + 1, "%s", inputText); sprintf(string, "Export to Directory: %s", saveDirInfo); input = new Fl_Input(25, 50, 235, 30); input->when(FL_WHEN_ENTER_KEY); input->value(filenameStartPtr + 1); Fl_Box *box = new Fl_Box(110, 20, 100, 30, (const char*)string); box->box(FL_NO_BOX); box->align(FL_ALIGN_CENTER); Fl_Box *fileExtBox = new Fl_Box(260,50,30,30,".csv"); Fl_Button *button = new Fl_Button(305, 50, 110, 30, "Export to CSV @->"); button->callback(InputCallback, (void*)0); button->set_active(); input->callback(InputCallback, (void*)0); callback(CloseCallback); } else if(type == InputWindow::FOLDER_INPUT) { std::string actualStructName = ExtractStructureNameFromCTName(defaultName); const char *actualStructNameCStr = actualStructName.c_str(); strncpy(inputText, actualStructNameCStr, actualStructName.size() + 1); ConfigParser::nullTerminateString(inputText, actualStructName.size()); sprintf(string, "Creating new folder for the CT structure %s", defaultName); input = new Fl_Input(160, 50, 250, 30, "@fileopen New Folder Name:"); input->when(FL_WHEN_ENTER_KEY); input->maximum_size(60); input->value(inputText); input->color(GUI_BGCOLOR); input->textcolor(GUI_BTEXT_COLOR); Fl_Box *box = new Fl_Box(50, 1, 350, 40, (const char*) string); box->box(FL_OSHADOW_BOX); box->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_WRAP); box->color(GUI_BGCOLOR); box->labelcolor(GUI_BTEXT_COLOR); Fl_Button *button = new Fl_Button(340, 50, 100, 30, "Add Folder @|>"); button->callback(InputCallback, (void*)0); button->labelcolor(GUI_BTEXT_COLOR); button->set_active(); input->callback(InputCallback, (void*)0); input->labelcolor(GUI_TEXT_COLOR); const char *cbText = " Use only default names for structure folders"; cbUseDefaultNames = new Fl_Check_Button(30, 100, 375, 30, cbText); cbUseDefaultNames->box(FL_ROUND_UP_BOX); cbUseDefaultNames->color(GUI_BGCOLOR); cbUseDefaultNames->labelcolor(GUI_BTEXT_COLOR); cbUseDefaultNames->down_color(GUI_WINDOW_BGCOLOR); cbUseDefaultNames->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CENTER); callback(CloseCallback); } else { const char *windowDisplayMsg = "Which CT file structure for the organism\ndo you want to display?"; Fl_Box *box = new Fl_Box(75, 5, 300, 40, windowDisplayMsg); box->box(FL_RSHADOW_BOX); box->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_WRAP); box->color(GUI_BGCOLOR); box->labelcolor(GUI_BTEXT_COLOR); Fl_Button *displayButton = new Fl_Button(100, 100, 200, 30, "Display Zoomed Region @|>"); displayButton->callback(DisplayCTFileCallback, (void*)0); displayButton->color(GUI_BGCOLOR); displayButton->labelcolor(GUI_BTEXT_COLOR); displayButton->set_active(); //displayButton->shortcut(FL_Enter); Fl_Button *cancelButton = new Fl_Button(310, 100, 75, 30, "Cancel @1+"); cancelButton->callback(CancelCallback); cancelButton->color(GUI_BGCOLOR); cancelButton->labelcolor(GUI_BTEXT_COLOR); ctFileChooser = new Fl_Choice(175, 55, 215, 30, "Choose CT Structure: "); ctFileChooser->color(GUI_BGCOLOR); ctFileChooser->labelcolor(GUI_BTEXT_COLOR); StructureManager *structManager = RNAStructViz::GetInstance()->GetStructureManager(); Folder *curFolder = structManager->GetFolderAt(folderIndex); for(int s = 0; s < curFolder->structCount; s++) { RNAStructure *rnaStruct = structManager->GetStructure(curFolder->folderStructs[s]); const char *ctFileName = rnaStruct->GetFilename(); ctFileChooser->add(ctFileName); } ctFileChooser->value(0); } show(); if(type != InputWindow::FOLDER_INPUT || !GUI_USE_DEFAULT_FOLDER_NAMES) { show(); } else { show(); InputCallback((Fl_Widget *) cbUseDefaultNames, (void *) NULL); } }