コード例 #1
0
ファイル: Contours.cpp プロジェクト: VruiVTK/VolumeViewer
/*
 * createButtonBox - Create a box to hold buttons.
 *
 * parameter colorMapDialog - GLMotif::RowColumn * &
 * return - GLMotif::RowColumn *
 */
GLMotif::RowColumn * Contours::createButtonBox(GLMotif::RowColumn * & colorMapDialog) {
    GLMotif::RowColumn * buttonBox = new GLMotif::RowColumn("ButtonBox", colorMapDialog, false);
    buttonBox->setOrientation(GLMotif::RowColumn::HORIZONTAL);
    GLMotif::ToggleButton * showContoursToggle = new GLMotif::ToggleButton(
      "ShowContoursToggle", buttonBox, "Show Contours");
    showContoursToggle->setToggle(true);
    showContoursToggle->getValueChangedCallbacks().add(this, &Contours::toggleSelectCallback);
    showContoursToggle->setToggleWidth(0.1f);
    GLMotif::Button * removeControlPointButton =
            new GLMotif::Button("RemoveControlPointButton", buttonBox, "Remove Control Point");
    removeControlPointButton->getSelectCallbacks().add(this, &Contours::removeControlPointCallback);
    return buttonBox;
}
コード例 #2
0
/*
 * createButtonBox - Create a box to hold buttons.
 *
 * parameter animationDialog - GLMotif::RowColumn*&
 * return - GLMotif::RowColumn*
 */
GLMotif::RowColumn* AnimationDialog::createButtonBox(
  GLMotif::RowColumn*& animationDialog)
{
  GLMotif::RowColumn* buttonBox =
    new GLMotif::RowColumn("ButtonBox", animationDialog, false);
  buttonBox->setOrientation(GLMotif::RowColumn::HORIZONTAL);
  buttonBox->setPacking(GLMotif::RowColumn::PACK_GRID);
  GLMotif::Button* firstButton = new GLMotif::Button(
    "First", buttonBox, "First Frame");
  firstButton->getSelectCallbacks().add(this,
    &AnimationDialog::renderFrameCallback);
  GLMotif::Button* previousButton = new GLMotif::Button(
    "Previous", buttonBox, "Previous Frame");
  previousButton->getSelectCallbacks().add(this,
    &AnimationDialog::renderFrameCallback);
  playButton = new GLMotif::Button(
    "PlayPause", buttonBox, "Play");
  playButton->getSelectCallbacks().add(this,
    &AnimationDialog::playPauseCallback);
  GLMotif::Button* nextButton = new GLMotif::Button(
    "Next", buttonBox, "Next Frame");
  nextButton->getSelectCallbacks().add(this,
    &AnimationDialog::renderFrameCallback);
  GLMotif::Button* lastButton = new GLMotif::Button(
    "Last", buttonBox, "Last Frame");
  lastButton->getSelectCallbacks().add(this,
    &AnimationDialog::renderFrameCallback);
  return buttonBox;
}
コード例 #3
0
ファイル: arfwindow.cpp プロジェクト: jvan/mycelia
ArfWindow::ArfWindow(Mycelia* application)
    : Window(application), layout(application->getDynamicLayout())
{
    window = new GLMotif::PopupWindow("AttributeWindow", Vrui::getWidgetManager(), "Layout Parameters");
    
    GLMotif::RowColumn* dialog = new GLMotif::RowColumn("ArfDialog", window, false);
    dialog->setNumMinorWidgets(3);
    
    // damping
    ParamPair p = VruiHelp::createParameter("Damping", -10, -1, layout->dampingConstant, dialog);
    dampingField = p.first;
    dampingSlider = p.second;
    dampingSlider->getValueChangedCallbacks().add(this, &ArfWindow::sliderCallback);
    
    // step size
    p = VruiHelp::createParameter("Step Size", 0.001, 0.05, layout->deltaTime, dialog);
    stepsizeField = p.first;
    stepsizeSlider = p.second;
    stepsizeSlider->getValueChangedCallbacks().add(this, &ArfWindow::sliderCallback);
    
    // beta
    p = VruiHelp::createParameter("Repulsion Falloff", -0.6, -0.1, layout->beta, dialog);
    betaField = p.first;
    betaSlider = p.second;
    betaSlider->getValueChangedCallbacks().add(this, &ArfWindow::sliderCallback);
    
    // strongly connected constant slider
    p = VruiHelp::createParameter("Strongly Connected Const", -5, -1, layout->stronglyConnectedSpringConstant, dialog);
    stronglyConnectedConstantField = p.first;
    stronglyConnectedConstantSlider = p.second;
    stronglyConnectedConstantSlider->getValueChangedCallbacks().add(this, &ArfWindow::sliderCallback);
    
    // connected constant slider
    p = VruiHelp::createParameter("Connected Const", -5, -1, layout->connectedSpringConstant, dialog);
    connectedConstantField = p.first;
    connectedConstantSlider = p.second;
    connectedConstantSlider->getValueChangedCallbacks().add(this, &ArfWindow::sliderCallback);
    
    // unconnected constant slider
    p = VruiHelp::createParameter("Unconnected Const", -5, -1, layout->unconnectedSpringConstant, dialog);
    unconnectedConstantField = p.first;
    unconnectedConstantSlider = p.second;
    unconnectedConstantSlider->getValueChangedCallbacks().add(this, &ArfWindow::sliderCallback);
    
    GLMotif::Button* navButton = new GLMotif::Button("NavButton", dialog, "Center Graph");
    navButton->getSelectCallbacks().add(application, &Mycelia::resetNavigationCallback);
    
    dialog->manageChild();
}
コード例 #4
0
void TerrainColorSettingsDialog::init()
{
  Dialog::init();

  const GLMotif::StyleSheet* style = Vrui::getWidgetManager()->getStyleSheet();

  colorPicker.setCloseButton(true);
  colorPicker.getColorPicker()->getColorChangedCallbacks().add(this, &TerrainColorSettingsDialog::colorChangedCallback);

  GLMotif::RowColumn* root = new GLMotif::RowColumn("TCSRoot", dialog, false);
  root->setNumMinorWidgets(2);

  GLMotif::Button* button = NULL;

//- Emissive Color
  new GLMotif::Label("TCSEmissive", root, "Emissive:");
  button = new GLMotif::Button("TSCEmissiveButton", root, "");
  button->setBackgroundColor(SETTINGS->terrainEmissiveColor);
  button->getSelectCallbacks().add(this, &TerrainColorSettingsDialog::colorButtonCallback);

//- Ambient Color
  new GLMotif::Label("TCSAmbient", root, "Ambient:");
  button = new GLMotif::Button("TSCAmbientButton", root, "");
  button->setBackgroundColor(SETTINGS->terrainAmbientColor);
  button->getSelectCallbacks().add(this, &TerrainColorSettingsDialog::colorButtonCallback);

//- Diffuse Color
  new GLMotif::Label("TCSDiffuse", root, "Diffuse:");
  button = new GLMotif::Button("TSCDiffuseButton", root, "");
  button->setBackgroundColor(SETTINGS->terrainDiffuseColor);
  button->getSelectCallbacks().add(this, &TerrainColorSettingsDialog::colorButtonCallback);

//- Specular Color
  new GLMotif::Label("TCSSpecular", root, "Specular:");
  button = new GLMotif::Button("TSCSpecularButton", root, "");
  button->setBackgroundColor(SETTINGS->terrainSpecularColor);
  button->getSelectCallbacks().add(this, &TerrainColorSettingsDialog::colorButtonCallback);

//- Specular Shininess
  new GLMotif::Label("TCSShininess", root, "Shininess:");
  GLMotif::RowColumn* shininessRoot = new GLMotif::RowColumn("TCSShininessRoot", root, false);
  shininessRoot->setNumMinorWidgets(2);

  GLMotif::Slider* slider = new GLMotif::Slider(
    "TCSShininessSlider",
    shininessRoot,
    GLMotif::Slider::HORIZONTAL,
    5.0 * style->fontHeight);
  slider->setValue(SETTINGS->terrainShininess);
  slider->setValueRange(0.0f, 128.0f, 1.0f);
  slider->getValueChangedCallbacks().add(this, &TerrainColorSettingsDialog::shininessChangedCallback);
  shininessField = new GLMotif::TextField(
    "SSShininessField",
    shininessRoot,
    3);
  shininessField->setPrecision(3);
  shininessField->setValue(SETTINGS->terrainShininess);

  shininessRoot->manageChild();

  root->manageChild();
}
コード例 #5
0
ファイル: mycelia.cpp プロジェクト: shwhalen/mycelia
Mycelia::Mycelia(int argc, char** argv, char** appDefaults)
    : Vrui::Application(argc, argv, appDefaults)
{
    // node layout / edge bundler
    dynamicLayout = new ArfLayout(this);
    staticLayout = new FruchtermanReingoldLayout(this);
    edgeBundler = new EdgeBundler(this);
    skipLayout = false;
    
    // node selection tool factory
    NodeSelectorFactory* selectorFactory = new NodeSelectorFactory(*Vrui::getToolManager(), this);
    Vrui::getToolManager()->addClass(selectorFactory, 0);
    
    // graph builder tool factory
    GraphBuilderFactory* builderFactory = new GraphBuilderFactory(*Vrui::getToolManager(), this);
    Vrui::getToolManager()->addClass(builderFactory, 0);
    
    // file submenu
    GLMotif::Popup* filePopup = new GLMotif::Popup("FilePopup", Vrui::getWidgetManager());
    GLMotif::SubMenu* fileSubMenu = new GLMotif::SubMenu("FileSubMenu", filePopup, false);
    
    GLMotif::Button* openFileButton = new GLMotif::Button("OpenFileButton", fileSubMenu, "Open...");
    openFileButton->getSelectCallbacks().add(this, &Mycelia::openFileCallback);
    
    GLMotif::Button* writeGraphButton = new GLMotif::Button("WriteGraphButton", fileSubMenu, "Save");
    writeGraphButton->getSelectCallbacks().add(this, &Mycelia::writeGraphCallback);
    
    // graph generators submenu
    GLMotif::Popup* generatorPopup = new GLMotif::Popup("GeneratorMenu", Vrui::getWidgetManager());
    generatorRadioBox = new GLMotif::RadioBox("GeneratorRadioBox", generatorPopup, false);
    generatorRadioBox->setSelectionMode(GLMotif::RadioBox::ATMOST_ONE);
    generatorRadioBox->getValueChangedCallbacks().add(this, &Mycelia::generatorCallback);
    
    erdosButton = new GLMotif::ToggleButton("ErdosButton", generatorRadioBox, "Random (Erdos-Renyi)");
    barabasiButton = new GLMotif::ToggleButton("BarabasiButton", generatorRadioBox, "Scale Free (Barabasi-Albert)");
    wattsButton = new GLMotif::ToggleButton("WattsButton", generatorRadioBox, "Small World (Watts-Strogatz)");
    
    // layout submenu
    GLMotif::Popup* layoutPopup = new GLMotif::Popup("LayoutPopup", Vrui::getWidgetManager());
    layoutRadioBox = new GLMotif::RadioBox("LayoutSubMenu", layoutPopup, false);
    layoutRadioBox->setSelectionMode(GLMotif::RadioBox::ALWAYS_ONE);
    layoutRadioBox->getValueChangedCallbacks().add(this, &Mycelia::resetLayoutCallback);
    
    staticButton = new GLMotif::ToggleButton("StaticButton", layoutRadioBox, "Static");
    dynamicButton = new GLMotif::ToggleButton("DynamicButton", layoutRadioBox, "Dynamic");
    layout = staticLayout;
    
    // render submenu
    GLMotif::Popup* renderPopup = new GLMotif::Popup("RenderPopup", Vrui::getWidgetManager());
    GLMotif::SubMenu* renderSubMenu = new GLMotif::SubMenu("RenderSubMenu", renderPopup, false);
    
    bundleButton = new GLMotif::ToggleButton("BundleButton", renderSubMenu, "Bundle Edges");
    bundleButton->getValueChangedCallbacks().add(this, &Mycelia::bundleCallback);
    
    nodeInfoButton = new GLMotif::ToggleButton("NodeInfoButton", renderSubMenu, "Show Node Information");
    nodeInfoButton->getValueChangedCallbacks().add(this, &Mycelia::nodeInfoCallback);
    
    nodeLabelButton = new GLMotif::ToggleButton("NodeLabelButton", renderSubMenu, "Show Node Labels");
    nodeLabelButton->setToggle(true);
    nodeLabelButton->getValueChangedCallbacks().add(this, &Mycelia::nodeLabelCallback);
    
    edgeLabelButton = new GLMotif::ToggleButton("EdgeLabelButton", renderSubMenu, "Show Edge Labels");
    edgeLabelButton->setToggle(true);
    edgeLabelButton->getValueChangedCallbacks().add(this, &Mycelia::nodeLabelCallback); // same callback
    
    componentButton = new GLMotif::ToggleButton("ComponentButton", renderSubMenu, "Show Only Selected Subgraph");
    componentButton->getValueChangedCallbacks().add(this, &Mycelia::componentCallback);
    
    // algorithms submenu
    GLMotif::Popup* algorithmsPopup = new GLMotif::Popup("AlgorithmsPopup", Vrui::getWidgetManager());
    GLMotif::SubMenu* algorithmsSubMenu = new GLMotif::SubMenu("AlgorithmsSubMenu", algorithmsPopup, false);
    
    shortestPathButton = new GLMotif::ToggleButton("ShortestPathButton", algorithmsSubMenu, "Shortest Path");
    shortestPathButton->getValueChangedCallbacks().add(this, &Mycelia::shortestPathCallback);
    
    spanningTreeButton = new GLMotif::ToggleButton("SpanningTreeButton", algorithmsSubMenu, "Spanning Tree");
    spanningTreeButton->getValueChangedCallbacks().add(this, &Mycelia::spanningTreeCallback);
    
    // plots submenu
    GLMotif::Popup* pythonPopup = new GLMotif::Popup("PythonPopup", Vrui::getWidgetManager());
    GLMotif::RadioBox* pythonSubMenu = new GLMotif::RadioBox("PythonSubMenu", pythonPopup, false);
    pythonSubMenu->setSelectionMode(GLMotif::RadioBox::ATMOST_ONE);
    pythonSubMenu->getValueChangedCallbacks().add(this, &Mycelia::pythonCallback);
    
    degreeButton = new GLMotif::ToggleButton("DegreeButton", pythonSubMenu, "Node Degree Distribution");
    centralityButton = new GLMotif::ToggleButton("CentralityButton", pythonSubMenu, "Node Betweenness Centrality");
    adjacencyButton = new GLMotif::ToggleButton("AdjacencyButton", pythonSubMenu, "Adjacency Matrix");
    lanetButton = new GLMotif::ToggleButton("LaNetButton", pythonSubMenu, "k-Core Hierarchical Layout");
    
    // main menu
    mainMenuPopup = new GLMotif::PopupMenu("MainMenuPopup", Vrui::getWidgetManager());
    mainMenuPopup->setTitle("Mycelia Network Visualizer");
    mainMenu = new GLMotif::Menu("MainMenu", mainMenuPopup, false);
    
    GLMotif::CascadeButton* fileCascade = new GLMotif::CascadeButton("FileCascade", mainMenu, "File");
    fileCascade->setPopup(filePopup);
    
    GLMotif::CascadeButton* generatorCascade = new GLMotif::CascadeButton("GeneratorCascade", mainMenu, "Generators");
    generatorCascade->setPopup(generatorPopup);
    
    GLMotif::CascadeButton* layoutCascade = new GLMotif::CascadeButton("LayoutCascade", mainMenu, "Layout");
    layoutCascade->setPopup(layoutPopup);
    
    GLMotif::CascadeButton* renderCascade = new GLMotif::CascadeButton("RenderCascade", mainMenu, "Rendering Options");
    renderCascade->setPopup(renderPopup);
    
    GLMotif::CascadeButton* algorithmsCascade = new GLMotif::CascadeButton("AlgorithmsCascade", mainMenu,  "Algorithms");
    algorithmsCascade->setPopup(algorithmsPopup);
    
    GLMotif::CascadeButton* pythonCascade = new GLMotif::CascadeButton("PythonCascade", mainMenu, "Python Plugins");
    pythonCascade->setPopup(pythonPopup);
    
    GLMotif::Button* clearButton = new GLMotif::Button("ClearButton", mainMenu, "Clear Screen");
    clearButton->getSelectCallbacks().add(this, &Mycelia::clearCallback);
    
    GLMotif::Button* navButton = new GLMotif::Button("NavButton", mainMenu, "Center Graph");
    navButton->getSelectCallbacks().add(this, &Mycelia::resetNavigationCallback);
    
    GLMotif::Button* layoutButton = new GLMotif::Button("LayoutButton", mainMenu, "Reset Layout");
    layoutButton->getSelectCallbacks().add(this, &Mycelia::resetLayoutCallback);
    
    fileSubMenu->manageChild();
    generatorRadioBox->manageChild();
    layoutRadioBox->manageChild();
    renderSubMenu->manageChild();
    algorithmsSubMenu->manageChild();
    pythonSubMenu->manageChild();
    mainMenu->manageChild();
    Vrui::setMainMenu(mainMenuPopup);
    
    // windows
    fileWindow = new GLMotif::FileSelectionDialog(mainMenu->getManager(), "Open file...",
            IO::openDirectory("./data"), ".xml;.dot;.chaco;.gml");
    fileWindow->getOKCallbacks().add(this, &Mycelia::fileOpenAction);
    fileWindow->getCancelCallbacks().add(this, &Mycelia::fileCancelAction);
    
    nodeWindow = new AttributeWindow(this, "Node Attributes", 5);
    nodeWindow->hide();
    
    layoutWindow = new ArfWindow(this);
    layoutWindow->hide();
    
    imageWindow = new ImageWindow(this);
    imageWindow->hide();
    
    statusWindow = new AttributeWindow(this, "Status", 1);
    statusWindow->hide();
    
    // fonts
    font = new FTGLTextureFont("fonts/Sansation_Light.ttf");
    font->FaceSize(FONT_SIZE);
    
    // generators
    barabasiGenerator = new BarabasiGenerator(this);
    erdosGenerator = new ErdosGenerator(this);
    wattsGenerator = new WattsGenerator(this);
    generator = barabasiGenerator;
    
    // logo
    lastFrameTime = Vrui::getApplicationTime();
    rotationAngle = 0;
    rotationSpeed = 40.0;
    
    // parsers
    chacoParser = new ChacoParser(this);
    dotParser = new DotParser(this);
    gmlParser = new GmlParser(this);
    xmlParser = new XmlParser(this);
    
    // misc
    selectedNode = SELECTION_NONE;
    previousNode = SELECTION_NONE;
    coneAngle = 0.005;
    xVector = Vrui::Vector(1, 0, 0);
    zVector = Vrui::Vector(0, 0, 1);
#ifdef __RPCSERVER__
    server = new RpcServer(this);
#endif
    
    // graph
    g = new Graph(this);
    gCopy = new Graph(this);
    
    // establishes initial node+edge sizes if graph builder is used first
    resetNavigationCallback(0);
}