本文整理汇总了C++中InternalWindowRefPtr::setAlignmentInDrawingSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ InternalWindowRefPtr::setAlignmentInDrawingSurface方法的具体用法?C++ InternalWindowRefPtr::setAlignmentInDrawingSurface怎么用?C++ InternalWindowRefPtr::setAlignmentInDrawingSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InternalWindowRefPtr
的用法示例。
在下文中一共展示了InternalWindowRefPtr::setAlignmentInDrawingSurface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
//Editor Field
LabelRecPtr TheTextEditorLabel = Label::create();
TheTextEditorLabel->setText("Text");
TheTextEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
FieldEditorComponentRefPtr TheTextEditor = FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
Label::TextFieldId,
TheCommandManager);
TheTextEditor->setPreferredSize(Vec2f(100.0f, 20.0f));
LabelRecPtr ThePreferredSizeEditorLabel = Label::create();
ThePreferredSizeEditorLabel->setText("PreferredSize");
ThePreferredSizeEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
FieldEditorComponentRefPtr ThePreferredSizeEditor =
FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
Label::PreferredSizeFieldId,
TheCommandManager);
ThePreferredSizeEditor->setPreferredSize(Vec2f(150.0f, 20.0f));
//Editing Panel
LayoutRefPtr EditorPanelLayout = OSG::FlowLayout::create();
PanelRecPtr EditorPanel = Panel::create();
EditorPanel->setPreferredSize(Vec2f(200.0f,200.0f));
EditorPanel->pushToChildren(TheTextEditorLabel);
EditorPanel->pushToChildren(TheTextEditor);
EditorPanel->pushToChildren(ThePreferredSizeEditorLabel);
EditorPanel->pushToChildren(ThePreferredSizeEditor);
EditorPanel->setLayout(EditorPanelLayout);
//Undo Panel
LabelRecPtr UndoPanelLabel = Label::create();
UndoPanelLabel->setText("Undo Panel");
UndoPanelLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
LayoutRefPtr UndoPanelLayout = OSG::FlowLayout::create();
PanelRecPtr UndoPanel = Panel::create();
UndoPanel->setPreferredSize(Vec2f(300.0f,300.0f));
UndoPanel->pushToChildren(UndoPanelLabel);
UndoPanel->pushToChildren(UndoRedoScrollPanel);
UndoPanel->pushToChildren(UndoButton);
UndoPanel->pushToChildren(RedoButton);
UndoPanel->setLayout(UndoPanelLayout);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(EditedLabel);
MainInternalWindow->pushToChildren(EditorPanel);
MainInternalWindow->pushToChildren(UndoPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
sceneManager.setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
TutorialViewport->setBackground(TutorialBackground);
// Show the whole Scene
sceneManager.showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"02GenericFieldEditor");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例2: main
//.........这里部分代码省略.........
ExamplePatternLayerButton->setTextColor(Color4f(0.0,1.0,0.0,1.0));
ExamplePatternLayerButton->setRolloverTextColor(Color4f(0.0,1.0,0.0,1.0));
ExamplePatternLayerButton->setActiveTextColor(Color4f(0.0,1.0,0.0,1.0));
ExampleGlassLayerButton->setText("Glass Layer");
ExampleGlassLayerButton->setBackground(ExampleGlassLayer);
ExampleGlassLayerButton->setActiveBackground(ExampleGlassLayer);
ExampleGlassLayerButton->setRolloverBackground(ExampleGlassLayer);
ExampleGlassLayerButton->setPreferredSize(Vec2f(150,50));
ExampleGlassLayerButton->setTextColor(Color4f(0.0,0.0,0.0,1.0));
ExampleGlassLayerButton->setRolloverTextColor(Color4f(0.0,0.0,0.0,1.0));
ExampleGlassLayerButton->setActiveTextColor(Color4f(0.0,0.0,0.0,1.0));
ExampleGlassCompoundLayerButton->setText("GlassCompound Layer");
ExampleGlassCompoundLayerButton->setBackground(ExampleGlassCompoundLayer);
ExampleGlassCompoundLayerButton->setActiveBackground(ExampleGlassCompoundLayer);
ExampleGlassCompoundLayerButton->setRolloverBackground(ExampleGlassCompoundLayer);
ExampleGlassCompoundLayerButton->setPreferredSize(Vec2f(150,50));
ExampleGlassCompoundLayerButton->setTextColor(Color4f(0.0,0.0,0.0,1.0));
ExampleGlassCompoundLayerButton->setRolloverTextColor(Color4f(0.0,0.0,0.0,1.0));
ExampleGlassCompoundLayerButton->setActiveTextColor(Color4f(0.0,0.0,0.0,1.0));
/******************************************************
Create a MainFrameBackground. For almost
all Tutorials, this is simply a
ColorLayer with a semi-transparent
white Background.
******************************************************/
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
//InternalWindow Layout
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleColorLayerButton);
MainInternalWindow->pushToChildren(ExampleCompoundLayerButton);
MainInternalWindow->pushToChildren(ExampleEmptyLayerButton);
MainInternalWindow->pushToChildren(ExampleGradientLayerButton);
MainInternalWindow->pushToChildren(ExampleMaterialLayerButton);
MainInternalWindow->pushToChildren(ExampleTextureLayerButton);
MainInternalWindow->pushToChildren(ExamplePatternLayerButton);
MainInternalWindow->pushToChildren(ExampleGlassLayerButton);
MainInternalWindow->pushToChildren(ExampleGlassCompoundLayerButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
sceneManager->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
//Create the Documentation Foreground and add it to the viewport
SimpleScreenDoc TheSimpleScreenDoc(sceneManager, TutorialWindow);
// Show the whole Scene
sceneManager->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"04Background");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例3: main
//.........这里部分代码省略.........
ExampleList->setModel(ExampleListModel);
ExampleList->setSelectionModel(ExampleListSelectionModel);
/******************************************************
Determine the SelectionModel
-SINGLE_SELECTION lets you select ONE item
via a single mouse click
-SINGLE_INTERVAL_SELECTION lets you select
one interval via mouse and SHIFT key
-MULTIPLE_INTERVAL_SELECTION lets you select
via mouse, and SHIFT and CONTRL keys
Note: this tutorial is currently set up
to allow for this to be changed via
TogggleButtons with ActionListeners attached
to them so this code is commented out.
******************************************************/
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr ExampleScrollPanel = ScrollPanel::create();
ExampleScrollPanel->setPreferredSize(Vec2f(200,300));
ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
//ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
ExampleScrollPanel->setViewComponent(ExampleList);
// Create MainFramelayout
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(0.5f);
LabelRefPtr ListLabel = Label::create();
ListLabel->setText("Background Colors List");
ListLabel->setPreferredSize(Vec2f(200.0f, ListLabel->getPreferredSize().y()));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ListLabel);
MainInternalWindow->pushToChildren(ExampleScrollPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.7f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
TutorialViewport->setBackground(TheBackground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"44MFieldList");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例4: main
//.........这里部分代码省略.........
distorted. For Layouts which will often
be dynamically changed, FlowLayout is not
the best choice.
-setHorizontalGap(int): Determine the Horizontal
gap in pixels between Components in
FlowLayout.
-setVerticalGap(int): Determine the Vertical
gap in pixels between Components in
FlowLayout.
-setOrientation(ENUM): Determine whether the
Layout is arranged Vertically or
Horizontally. Takes HORIZONTAL_ORIENTATION
or VERTICAL_ORIENTATION arguments.
-setMajorAxisAlignment(ENUM): Determines
the alignment of the entire Layout
within its ComponentContainer. See below.
-setMinorAxistAlignment(ENUM): Determines
the alignment of Components within
the Layout. See below.
Both of the last two functions take the
following arguments: AXIS_MAX_ALIGNMENT,
AXIS_CENTER_ALIGNMENT, and AXIS_MIN_ALIGNMENT.
MAX puts it to the bottom/right, CENTER
centers it, and MIN puts it to the
top/left (for Vertical/Horizontal as
set above, respectively).
******************************************************/
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setHorizontalGap(3.0f);
MainInternalWindowLayout->setVerticalGap(3.0f);
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(1.0f);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Add a 10 pixel "padding" inside the MainFrame
MainInternalWindow->setAllInsets(10);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"05FlowLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例5: main
//.........这里部分代码省略.........
// Create an Action and assign it to ExampleButton
// This Class is defined above, and will cause the output
// window to display "Button 1 Action" when pressed
ExampleButton->connectActionPerformed(boost::bind(actionPerformed, _1));
/******************************************************
Create a ToggleButton and determine its
characteristics. ToggleButton inherits
off of Button, so all characteristsics
used above can be used with ToggleButtons
as well.
The only difference is that when pressed,
ToggleButton remains pressed until pressed
again.
-setSelected(bool): Determine whether the
ToggleButton is Selected (true) or
deselected (false).
******************************************************/
ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();
ExampleToggleButton->setSelected(false);
ExampleToggleButton->setText("ToggleMe");
ExampleToggleButton->setToolTipText("Toggle Button ToolTip");
//Button with Image
ButtonRefPtr ExampleDrawObjectButton = OSG::Button::create();
ExampleDrawObjectButton->setDrawObjectToTextAlignment(Button::ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT);
ExampleDrawObjectButton->setText("Icon");
ExampleDrawObjectButton->setImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setActiveImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setFocusedImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setRolloverImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setDisabledImage(std::string("./Data/Icon.png"));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(ExampleButton);
MainInternalWindow->pushToChildren(ExampleToggleButton);
MainInternalWindow->pushToChildren(ExampleDrawObjectButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
sceneManager.setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
//Create the Documentation Foreground and add it to the viewport
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
// Show the whole Scene
sceneManager.showAll();
//Attach key controls
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01Button");
commitChanges();
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例6: main
//.........这里部分代码省略.........
ExampleTabPanel->addTab(MultiFieldLabel, createMultiFieldPanel());
ExampleTabPanel->addTab(SinglePtrFieldLabel, createSinglePtrFieldPanel());
ExampleTabPanel->addTab(MultiPtrFieldLabel, createMultiPtrFieldPanel());
ExampleTabPanel->setTabAlignment(0.5f);
ExampleTabPanel->setTabPlacement(TabPanel::PLACEMENT_NORTH);
ExampleTabPanel->setSelectedIndex(0);
//UndoList
UndoRedoListModel = DefaultListModel::create();
UndoRedoListModel->pushBack(boost::any(std::string("Top")));
ListSelectionModelPtr UndoRedoListSelectionModel(new DefaultListSelectionModel());
UndoRedoList = List::create();
UndoRedoList->setPreferredSize(Vec2f(200, 300));
UndoRedoList->setOrientation(List::VERTICAL_ORIENTATION);
UndoRedoList->setModel(UndoRedoListModel);
UndoRedoList->setSelectionModel(UndoRedoListSelectionModel);
UndoRedoListListener TheUndoRedoListListener;
UndoRedoList->getSelectionModel()->addListSelectionListener(&TheUndoRedoListListener);
UndoButton = OSG::Button::create();
UndoButton->setText("Undo");
UndoButton->setEnabled(TheUndoManager->numberOfUndos() != 0);
UndoButtonActionListener TheUndoButtonActionListener;
UndoButton->addActionListener(&TheUndoButtonActionListener);
RedoButton = OSG::Button::create();
RedoButton->setText("Redo");
RedoButton->setEnabled(TheUndoManager->numberOfRedos() != 0);
RedoButtonActionListener TheRedoButtonActionListener;
RedoButton->addActionListener(&TheRedoButtonActionListener);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr UndoRedoScrollPanel = ScrollPanel::create();
UndoRedoScrollPanel->setPreferredSize(Vec2f(200,200));
UndoRedoScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
UndoRedoScrollPanel->setViewComponent(UndoRedoList);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(ExampleTabPanel);
MainInternalWindow->pushToChildren(UndoRedoScrollPanel);
MainInternalWindow->pushToChildren(UndoButton);
MainInternalWindow->pushToChildren(RedoButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
TutorialViewport->setBackground(TutorialBackground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01ChangeFieldCommands");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例7: main
//.........这里部分代码省略.........
of pixels between each row.
******************************************************/
GridLayoutRefPtr MainInternalWindowLayout = OSG::GridLayout::create();
MainInternalWindowLayout->setRows(3);
MainInternalWindowLayout->setColumns(2);
MainInternalWindowLayout->setHorizontalGap(4);
MainInternalWindowLayout->setVerticalGap(4);
/******************************************************
Create and edit some Button Components.
Note that as with BoxLayout, Components
are resized to fit their respective
grid boxes. Unless a MaxSize is set,
this will be the case. This will
override even PreferredSizes (see
ExampleButton3).
******************************************************/
ButtonRefPtr ExampleButton1 = OSG::Button::create();
ButtonRefPtr ExampleButton2 = OSG::Button::create();
ButtonRefPtr ExampleButton3 = OSG::Button::create();
ButtonRefPtr ExampleButton4 = OSG::Button::create();
ButtonRefPtr ExampleButton5 = OSG::Button::create();
ButtonRefPtr ExampleButton6 = OSG::Button::create();
ExampleButton1->setPreferredSize(Vec2f(50,50));
ExampleButton1->setMaxSize(Vec2f(50,50)); //if MaxSize is commented out, this button then will revert to being the same size as the others in the grid.
ExampleButton2->setPreferredSize(Vec2f(200,100)); //<----
// |
ExampleButton3->setPreferredSize(Vec2f(50,100)); //Notice that even though these two differ in size they appear the same on the grid
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"07GridLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例8: main
//.........这里部分代码省略.........
ExamplePanel1->setPreferredSize(Vec2f(400, 400));
ExamplePanel1->pushToChildren(ExampleButton2);
ExamplePanel1->pushToChildren(ExamplePanel3);
ExamplePanel1->pushToChildren(ExamplePanel4);
ExamplePanel1->setLayout(ExamplePanel1Layout);
ExamplePanel1->setBackgrounds(ExamplePanelBackground);
ExamplePanel1->setBorders(ExamplePanelBorder);
ExamplePanel2->setPreferredSize(Vec2f(400, 400));
ExamplePanel2->pushToChildren(ExampleButton3);
ExamplePanel2->pushToChildren(ExamplePanel5);
ExamplePanel2->pushToChildren(ExamplePanel6);
ExamplePanel2->setLayout(ExamplePanel2Layout);
ExamplePanel2->setBackgrounds(ExamplePanelBackground);
ExamplePanel2->setBorders(ExamplePanelBorder);
ExamplePanel3->pushToChildren(ExampleButton4);
ExamplePanel3->pushToChildren(ExampleButton5);
ExamplePanel3->setLayout(ExamplePanel3Layout);
ExamplePanel3->setPreferredSize(Vec2f(125, 130));
ExamplePanel3->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel4->pushToChildren(ExampleButton6);
ExamplePanel4->pushToChildren(ExampleButton7);
ExamplePanel4->setLayout(ExamplePanel4Layout);
ExamplePanel4->setPreferredSize(Vec2f(125, 130));
ExamplePanel4->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel5->pushToChildren(ExampleButton8);
ExamplePanel5->pushToChildren(ExampleButton9);
ExamplePanel5->setLayout(ExamplePanel5Layout);
ExamplePanel5->setPreferredSize(Vec2f(125, 130));
ExamplePanel5->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel6->pushToChildren(ExampleButton10);
ExamplePanel6->pushToChildren(ExampleButton11);
ExamplePanel6->setLayout(ExamplePanel6Layout);
ExamplePanel6->setPreferredSize(Vec2f(125, 130));
ExamplePanel6->setBackgrounds(ExampleSmallPanelBackground);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->setBorder(ExamplePanelBorder);
MainInternalWindow->pushToChildren(ExampleLabel1);
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExamplePanel1);
MainInternalWindow->pushToChildren(ExamplePanel2);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.8f,0.8f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"12ComplexLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例9: main
//.........这里部分代码省略.........
SplitButton->setText("Split");
SplitButton->connectButtonSelected(boost::bind(handleSplitSelected,
_1,
theTextEditor.get()));
SplitButton->connectButtonDeselected(boost::bind(handleSplitDeselected,
_1,
theTextEditor.get()));
ButtonRefPtr LoadButton = Button::create();
LoadButton->setMinSize(Vec2f(50, 25));
LoadButton->setMaxSize(Vec2f(200, 100));
LoadButton->setPreferredSize(Vec2f(80, 40));
LoadButton->setToolTipText("Click to open a file browser window");
LoadButton->setText("Load File");
LoadButton->connectActionPerformed(boost::bind(handleLoadButtonAction, _1, TutorialWindow.get(), theTextEditor.get()));
ButtonRefPtr SaveButton = Button::create();
SaveButton->setMinSize(Vec2f(50, 25));
SaveButton->setMaxSize(Vec2f(200, 100));
SaveButton->setPreferredSize(Vec2f(80, 40));
SaveButton->setToolTipText("Click to save the currently opened file");
SaveButton->setText("Save File");
SaveButton->connectActionPerformed(boost::bind(handleSaveButtonAction, _1, TutorialWindow.get(),theTextEditor.get()));
//Button Panel
LayoutRefPtr ButtonPanelLayout = FlowLayout::create();
PanelRecPtr ButtonPanel = Panel::createEmpty();
ButtonPanel->setPreferredSize(Vec2f(300, 300));
ButtonPanel->setLayout(ButtonPanelLayout);
ButtonPanel->pushToChildren(LoadButton);
ButtonPanel->pushToChildren(SaveButton);
ButtonPanel->pushToChildren(SplitButton);
ButtonPanel->pushToChildren(ClipboardButton);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = InternalWindow::create();
//MainInternalWindow->pushToChildren(TextAreaScrollPanel);
MainInternalWindow->pushToChildren(theTextEditor);
MainInternalWindow->pushToChildren(ButtonPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
//MainInternalWindow->setDrawTitlebar(true);
//MainInternalWindow->setResizable(true);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
sceneManager.setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
sceneManager.showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.95f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"06Editor");
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, theTextEditor.get()));
commitChanges();
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例10: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create and edit a CheckboxButton.
Note: the only function call shown
specific to CheckboxButton is setSelected.
In DefaultLookAndFeel, the options
for changing the style of the CheckBox
are shown. CheckboxButton also
inherits off Button so all features
of Button may be used.
-setSelected(bool): Determines if the
CheckboxButton is checked(true) or
not checked(false).
******************************************************/
CheckboxButtonRefPtr ExampleCheckboxButton = OSG::CheckboxButton::create();
ExampleCheckboxButton->setMinSize(Vec2f(50, 25));
ExampleCheckboxButton->setMaxSize(Vec2f(300, 100));
ExampleCheckboxButton->setPreferredSize(Vec2f(200, 50));
ExampleCheckboxButton->setEnabled(true);
ExampleCheckboxButton->setText("Checkbox Button");
ExampleCheckboxButton->setAlignment(Vec2f(0.5,0.5));
ExampleCheckboxButton->setSelected(true);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleCheckboxButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//.........这里部分代码省略.........
示例11: main
//.........这里部分代码省略.........
ExampleTextDomArea->setPreferredSize(Vec2f(600, 400));
ExampleTextDomArea->setWrapStyleWord(false);
ExampleTextDomArea->setMinSize(Vec2f(600,400));
ExampleTextDomArea->setFont(_Font);
ExampleAdvancedTextDomArea = OSG::AdvancedTextDomArea::create();
ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));
ExampleAdvancedTextDomArea->setGutterVisible(true);
ExampleAdvancedTextDomArea->pushToChildren(ExampleTextDomArea);
ExampleAdvancedTextDomArea->setLayout(LayoutRefPtr(OSG::FlowLayout::create()));
ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));
ScrollPanelRefPtr TextAreaScrollPanel = ScrollPanel::create();
TextAreaScrollPanel->setPreferredSize(Vec2f(600,400));
TextAreaScrollPanel->setMinSize(Vec2f(600,400));
TextAreaScrollPanel->setViewComponent(ExampleAdvancedTextDomArea);
*/
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(theTextEditor);
MainInternalWindow->pushToChildren(LoadButton);
MainInternalWindow->pushToChildren(SaveButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.85f,0.85f));
MainInternalWindow->setDrawTitlebar(true);
MainInternalWindow->setResizable(false);
/******************************************************
The Drawing Surface is created the
same as with previous Tutorials
(however the MainInternalWindow is created
in a function below).
******************************************************/
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
/******************************************************
Create the 3D UIRectangle. This allows
the DrawingSurface to be rotated relative
to the screen, allowing a 3D aspect to
the DrawingSurface. The Surface
can still be interacted with, so Buttons,
Menus, etc. all will still function
normally.
-setPoint(Pnt3f): Determine the location
of the UIRectangle in 3D space. Keep
示例12: main
//.........这里部分代码省略.........
LeftPanelLabel1->setBorders(emptyBorder);
LeftPanelLabel1->setBackgrounds(GreyBackground);
LeftPanelLabel1->setFont(LeftPanelLabel1Font);
LeftPanelLabel1->setText("OSG Gui");
LeftPanelLabel1->setPreferredSize(Vec2f(300, 100));
LeftPanelLabel1->setAlignment(Vec2f(0.0f, 0.5f));
/******************************************************
Create some Layouts
******************************************************/
BoxLayoutRefPtr MainInternalWindowLayout = OSG::BoxLayout::create();
FlowLayoutRefPtr LeftPanelLayout = OSG::FlowLayout::create();
BoxLayoutRefPtr RightPanelLayout = OSG::BoxLayout::create();
MainInternalWindowLayout->setOrientation(BoxLayout::HORIZONTAL_ORIENTATION);
LeftPanelLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION);
LeftPanelLayout->setMinorAxisAlignment(1.0f);
RightPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);
/******************************************************
Create MainFrame and Panels
******************************************************/
PanelRefPtr LeftPanel = OSG::Panel::create();
PanelRefPtr RightPanel = OSG::Panel::create();
// LeftPanel stuff
LeftPanel->setPreferredSize(Vec2f(400, 500));
LeftPanel->pushToChildren(LeftPanelLabel1);
LeftPanel->pushToChildren(createLeftPanelButtonPanel());
LeftPanel->pushToChildren(createLeftPanelRadioTextPanel());
LeftPanel->setLayout(LeftPanelLayout);
LeftPanel->setBackgrounds(GreyBackground);
LeftPanel->setBorders(Panel1Border);
//RightPanel stuff
RightPanel->setPreferredSize(Vec2f(200, 620));
RightPanel->pushToChildren(createRightPanelButtonPanel());
RightPanel->pushToChildren(createRightPanelCheckPanel());
RightPanel->setLayout(RightPanelLayout);
RightPanel->setBackgrounds(GreyBackground);
RightPanel->setBorders(Panel2Border);
// Create The Main InternalWindow
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(LeftPanel);
MainInternalWindow->pushToChildren(RightPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(GreyBackground);
MainInternalWindow->setBorders(PanelBorder);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Make A 3D Rectangle to draw the UI on
UIRectangleRefPtr UIRectCore = UIRectangle::create();
UIRectCore->setPoint(Pnt3f(-310.0,-310.0,370.0));
UIRectCore->setWidth(620);
UIRectCore->setHeight(620);
UIRectCore->setDrawingSurface(TutorialDrawingSurface);
NodeRefPtr UIRectNode = OSG::Node::create();
UIRectNode->setCore(UIRectCore);
// add the UIRect as a child
scene->addChild(UIRectNode);
mgr->setRoot(scene);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"21ExampleInterface");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例13: main
//.........这里部分代码省略.........
******************************************************/
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
/******************************************************
Create a non-editable ComboBox.
-setEditable(bool): Determine whether
the user can type in the ComboBox
or if it is uneditable. In this
case, it is set to false.
When creating a non-editable ComboBox,
a Renderer must also be assigned. For
editable ComboBoxes, the ComboBox
automatically shows its text due to the
nature of the ComboBox. However, when
uneditable, this aspect of the ComboBox
is disabled, and so to display the
selection, a renderer must be created and
assigned to the ComboBox.
Note: as with Sliders and ScrollBars,
having the same Model assigned causes
the ComboBoxes to be tied together.
******************************************************/
// Create another ComboBox
ComboBoxRefPtr ExampleUneditableComboBox = ComboBox::create();
// Set it to be uneditable
ExampleUneditableComboBox->setEditable(false);
ExampleUneditableComboBox->setModel(ExampleComboBoxModel);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
MainInternalWindow->pushToChildren(ExampleUneditableComboBox);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr viewport = mgr->getWindow()->getPort(0);
viewport->addForeground(foreground);
// Show the whole scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"33ComboBox");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例14: main
//.........这里部分代码省略.........
// creating a submenu. Note this does not
// involve begin/endEditCPs to do
ExampleSubMenu->addItem(SubMenuItem1);
ExampleSubMenu->addItem(SubMenuItem2);
ExampleSubMenu->addItem(SubMenuItem3);
/******************************************************
Create the PopupMenu itself.
Items are added in the order in which
they will be displayed (top to bottom)
via addItem(ItemToBeAdded)
The PopupMenu is attached to a
Button below using
setPopupMenu(PopupMenuName).
Note: PopupMenus can be added to any
Component.
******************************************************/
PopupMenuRefPtr ExamplePopupMenu = PopupMenu::create();
ExamplePopupMenu->addItem(MenuItem1);
ExamplePopupMenu->addItem(MenuItem2);
ExamplePopupMenu->addItem(MenuItem3);
ExamplePopupMenu->addSeparator();
ExamplePopupMenu->addItem(ExampleSubMenu);
ExamplePopupMenu->addItem(MenuItem4);
// Create a Button and Font
UIFontRefPtr PopupMenuButtonFont = OSG::UIFont::create();
PopupMenuButtonFont->setSize(16);
ButtonRefPtr PopupMenuButton = OSG::Button::create();
PopupMenuButton->setText("RightClickMe!");
// Add the PopupMenu to PopupMenuButton so that when right clicked,
// the PopupMenu will appear
PopupMenuButton->setPopupMenu(ExamplePopupMenu);
PopupMenuButton->setPreferredSize(Vec2f(200,100));
PopupMenuButton->setFont(PopupMenuButtonFont);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(PopupMenuButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01RubberBandCamera");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例15: main
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//TutorialKeyListener TheKeyListener;
//TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr graphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create the DefaultMutableComboBoxModel and
add Elements to it (several Colors
in this case). These will be the data
values shown in the ComboBox.
******************************************************/
DefaultMutableComboBoxModelRefPtr ExampleComboBoxModel = DefaultMutableComboBoxModel::create();
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(std::string("More Colors")));
/******************************************************
Create an editable ComboBox. A ComboBox
has a Model just like various other
Components.
******************************************************/
ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
ExampleComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
ExampleComboBox->setEditable(false);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->setDrawingSurface(TutorialDrawingSurface);
//.........这里部分代码省略.........