Whoups.... my zip file was blocked...:-( thus I'm joining the files one by one....
regards,
Manu.
2007/10/25, Emmanuel Roche <[EMAIL PROTECTED]>:
>
> whoups... forgot the file of course;..
>
>
> 2007/10/25, Emmanuel Roche <[EMAIL PROTECTED]>:
> >
> > For those who would have some time to give a look at this, I'm joining
> > the code of a simple application designed to open a View in multiple tabs:
> >
> > the user select an osg or ive file to open an then a new tab is created
> > using this file as scene Data.
> >
> > There is a single CompositeViewer managed by the main frame, an 1 View
> > object per tab...
> >
> > This sample is NOT working properly: if you add one tab, every thing is
> > okay, but when you had other tabs, as before, only the last one is displayed
> > :-( the others become empty [only the default blue background :-( ] and this
> > last tab doesn't handle the mouse inputs correctly [instead, it seems that
> > the mouse input for the first tab are used for this last View !!!...
> >
> > Yet the code is very clear: each tab has its GraphicsWindowWX, (so its
> > wxGLCanvas too), its OSGPanel (so its own processing of mouse inputs, and
> > its View).. so what does this mean ? is the global CompositeViewer
> > appropriating itself the eventQueue of the first View added and then using
> > this one for the other Views ?....
> >
> > As always , any clue would be really welcomed, I feel a bit lost with
> > this...
> >
> > regards,
> > Manu.
> >
> >
> > 2007/10/25, Emmanuel Roche < [EMAIL PROTECTED]>:
> > >
> > > Hi again guys !
> > >
> > > I've just tested your solution Alberto, and indeed it's working and I
> > > can see both pages with two View on each page :-)...
> > >
> > > Yet I think there is still something I'm missing about the
> > > CompositeViewer behavior : indeed, I set a trackballmanipulator for the
> > > view1 [ view1->setCameraManipulator(new osgGA::TrackballManipulator); ]
> > > and
> > > created a Mouse handling function:
> > >
> > > void ventana::OnMouse(wxMouseEvent& event)
> > > {
> > > if (event.ButtonDown()) {
> > > int button = event.GetButton();
> > > v1->getEventQueue()->mouseButtonPress(event.GetX(), event.GetY(),
> > > button);
> > > }
> > > else if (event.ButtonUp()) {
> > > int button = event.GetButton();
> > > v1->getEventQueue()->mouseButtonRelease(event.GetX(),
> > > event.GetY(), button);
> > > }
> > > else if (event.Dragging ()) {
> > > v1->getEventQueue()->mouseMotion(event.GetX(), event.GetY());
> > > }
> > > }
> > >
> > > ... here "v1" is the first GraphicsWindow on the tab, and, when I
> > > activate this function by dragging the mouse on the tab nothing moves....
> > > :-(... I trying replacing "v1" by "cViewer" and calling
> > > cViewer->setEventQueue(v1->getEventQueue()) in the initilialization
> > > process
> > > [ because the eventQueue seems to be NULL otherwise...] but this doesn't
> > > work either... Any clue about this ???
> > >
> > >
> > > regards,
> > > Manu.
> > >
> > >
> > > 2007/10/25, Robert Osfield <[EMAIL PROTECTED] >:
> > > >
> > > > Hi Guys,
> > > >
> > > > I don't have any recommendations, or time right now to dive into
> > > > this
> > > > topic. I'd certainly like to see osgViewer be able to cope with
> > > > this
> > > > type of usage, and its not one that its been coded for up to this
> > > > point. Might I suggest getting a tabbed WxWidget example together
> > > > than could be included with the OSG distribution that illustrates
> > > > the
> > > > this issue and can be used as a test bed for a final recommend
> > > > solution.
> > > >
> > > > Robert.
> > > >
> > > > On 10/25/07, Emmanuel Roche <[EMAIL PROTECTED]> wrote:
> > > > > Thanks a lot Alberto I guess I could not get anything more usefull
> > > > :-) !
> > > > >
> > > > > I'm checking this right now....
> > > > >
> > > > > Regards,
> > > > > Manu.
> > > > >
> > > > > 2007/10/25, Alberto Luaces < [EMAIL PROTECTED]>:
> > > > > >
> > > > > > Hi Manu,
> > > > > >
> > > > > > I'm doing the very same thing, but with two views of a same
> > > > scene on every
> > > > > > tab. Currently it works well, but I suspect there are duplicated
> > > > > resources, so
> > > > > > I have to say that my code is not in its final version.
> > > > > >
> > > > > > I'm attaching it, it works for me on Linux and wx 2.6.3unmodified.
> > > > > >
> > > > > > Feel free to compare it with yours so we can learn together :)
> > > > > >
> > > > > > HTH,
> > > > > >
> > > > > > Alberto
> > > > > >
> > > > > > El Thursday 25 October 2007 12:37:45 Emmanuel Roche escribió:
> > > > > > > Hello everyone!
> > > > > > >
> > > > > > > I've got a simple question, but I can't find any practical
> > > > solution:
> > > > > > >
> > > > > > > In my application, I have to display a notebook with a 3D
> > > > window on each
> > > > > > > tab... and I want to be able to add/remove tabs dynamically...
> > > > so, what
> > > > > can
> > > > > > > I use to achieve this result ?
> > > > > > >
> > > > > > > I'm usig wxWidgets + OSG 2.2.0
> > > > > > > I'm on Win XP
> > > > > > >
> > > > > > > I tried with a CompositeViewer :
> > > > > > > - creating the conpositeViewer when requested (so everything
> > > > should be
> > > > > in
> > > > > > > the wx event handling thread...)
> > > > > > > - building my graphicswindowWX
> > > > > > > - creating a view
> > > > > > > - adding this view to the compositeview
> > > > > > > - relying on an Idle function to call viewer->frame()...
> > > > > > >
> > > > > > > ... this works as long as there is a single tab... but when I
> > > > had
> > > > > others,
> > > > > > > then only the last tab added display something : the others
> > > > only display
> > > > > > > the blue background with no model anymore... ? why that ??
> > > > > > >
> > > > > > > by the way I had to make a small change in the
> > > > > > > GraphicsWindowWx::makeCurrentImplementation() :
> > > > > > >
> > > > > > > bool GraphicsWindowWX::makeCurrentImplementation() {
> > > > > > > // Bouml preserved body begin 0001FE83
> > > > > > > if(!GetParent()->IsShown())
> > > > > > > return false;
> > > > > > >
> > > > > > > SetCurrent();
> > > > > > > return true;
> > > > > > > // Bouml preserved body end 0001FE83
> > > > > > > }
> > > > > > >
> > > > > > > --> So the hidden tabs should return false here... could this
> > > > be the
> > > > > source
> > > > > > > of the problem ?? (anyway wxWidgets doesn't accept
> > > > SetCurrent() when the
> > > > > > > corresponding tab is not visible... :-S )
> > > > > > >
> > > > > > > regards !
> > > > > > >
> > > > > > > Thanks for your help !
> > > > > > > Manu.
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > osg-users mailing list
> > > > > > [email protected]
> > > > > >
> > > > >
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > osg-users mailing list
> > > > > [email protected]
> > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > >
> > > > >
> > > > >
> > > > _______________________________________________
> > > > osg-users mailing list
> > > > [email protected]
> > > >
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > >
> > >
> > >
> >
>
>
#include "wx/dcclient.h"
#include "GraphicsWindowWX.h"
BEGIN_EVENT_TABLE(GraphicsWindowWX,wxGLCanvas)
EVT_PAINT(GraphicsWindowWX::OnPaint)
EVT_SIZE(GraphicsWindowWX::OnSize)
EVT_ERASE_BACKGROUND(GraphicsWindowWX::OnEraseBackground)
EVT_MOUSE_EVENTS(GraphicsWindowWX::OnMouse)
//EVT_IDLE(GraphicsWindowWX::OnIdle)
END_EVENT_TABLE()
GraphicsWindowWX::GraphicsWindowWX(wxWindow * parent)
: wxGLCanvas(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize) {
// Bouml preserved body begin 00020883
Show();
viewer = NULL;
view = NULL;
// Bouml preserved body end 00020883
}
void GraphicsWindowWX::OnPaint(wxPaintEvent & event) {
// Bouml preserved body begin 00020C83
/* must always be here */
wxPaintDC dc(this);
// Bouml preserved body end 00020C83
}
void GraphicsWindowWX::OnSize(wxSizeEvent & event) {
// Bouml preserved body begin 00020D03
// this is also necessary to update the context on some platforms
wxGLCanvas::OnSize(event);
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
int width, height;
GetClientSize(&width, &height);
osgGA::EventQueue* queue = (view ? view->getEventQueue() : getEventQueue());
// update the window dimensions, in case the window has been resized.
queue->windowResize(0, 0, width, height);
resized(0,0,width,height);
if(viewer)
viewer->getCamera()->setViewport(0,0,width,height);
if(view)
view->getCamera()->setViewport(0,0,width,height);
// Bouml preserved body end 00020D03
}
void GraphicsWindowWX::OnEraseBackground(wxEraseEvent & event) {
// Bouml preserved body begin 00020D83
// Bouml preserved body end 00020D83
}
void GraphicsWindowWX::OnMouse(wxMouseEvent & event) {
// Bouml preserved body begin 00020E03
osgGA::EventQueue* queue = (view ? view->getEventQueue() : getEventQueue());
if (event.ButtonDown()) {
int button = event.GetButton();
queue->mouseButtonPress(event.GetX(), event.GetY(), button);
}
else if (event.ButtonUp()) {
int button = event.GetButton();
queue->mouseButtonRelease(event.GetX(), event.GetY(), button);
}
else if (event.Dragging()) {
queue->mouseMotion(event.GetX(), event.GetY());
}
// Bouml preserved body end 00020E03
}
void GraphicsWindowWX::setViewer(osgViewer::Viewer* value) {
viewer = value;
}
void GraphicsWindowWX::OnIdle(wxIdleEvent & event) {
// Bouml preserved body begin 00021403
if(viewer)
viewer->frame();
// Bouml preserved body end 00021403
}
void GraphicsWindowWX::setView(osgViewer::View* value) {
view = value;
}
GraphicsWindowWX.h
Description: Binary data
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include "OSGPanel.h"
#include "GraphicsWindowWX.h"
OSGPanel::OSGPanel(wxWindow * parent) {
// Bouml preserved body begin 00020803
Create(parent,wxID_ANY);
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
GraphicsWindowWX* gw = new GraphicsWindowWX(this);
sizer->Add(gw,1,wxEXPAND|wxALL,2);
int width = 800;
int height = 600;
//viewer = new osgViewer::Viewer;
// viewer->getCamera()->setGraphicsContext(gw);
// viewer->getCamera()->setViewport(0,0,width,height);
// viewer->addEventHandler(new osgViewer::StatsHandler);
// viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
// viewer->setCameraManipulator(new osgGA::TrackballManipulator);
//gw->setViewer(viewer.get());
view = new osgViewer::View;
view->setCameraManipulator(new osgGA::TrackballManipulator);
view->getCamera()->setGraphicsContext(gw);
view->getCamera()->setViewport(0,0,width,height);
gw->setView(view.get());
SetSizer(sizer);
// Bouml preserved body end 00020803
}
osgViewer::Viewer* OSGPanel::getViewer() {
// Bouml preserved body begin 00021383
return viewer.get();
// Bouml preserved body end 00021383
}
osgViewer::View* OSGPanel::getView() {
// Bouml preserved body begin 00021483
return view.get();
// Bouml preserved body end 00021483
}
OSGPanel.h
Description: Binary data
Wimon.h
Description: Binary data
//#include "vld.h"
#include "WimonApp.h"
#include "WimonFrame.h"
#include "wx/frame.h"
IMPLEMENT_APP(WimonApp)
bool WimonApp::OnInit() {
// Bouml preserved body begin 0001F403
WimonFrame* frame = new WimonFrame();
wxTheApp->SetTopWindow(frame);
frame->Show(true);
return true;
// Bouml preserved body end 0001F403
}
int WimonApp::OnExit() {
// Bouml preserved body begin 0001F483
return wxApp::OnExit();
// Bouml preserved body end 0001F483
}
WimonApp.h
Description: Binary data
#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/msgdlg.h"
#include "wx/filedlg.h"
#include "wx/notebook.h"
#include <osgDB/ReadFile>
#include "WimonFrame.h"
#include "OSGPanel.h"
#include <osgGA/StateSetManipulator>
BEGIN_EVENT_TABLE(WimonFrame, wxFrame)
EVT_MENU(Menu_File_Quit,WimonFrame::OnQuit)
EVT_MENU(Menu_Help_About,WimonFrame::OnAbout)
EVT_MENU(Menu_File_Open,WimonFrame::OnOpen)
EVT_IDLE(WimonFrame::OnIdle)
END_EVENT_TABLE()
WimonFrame::WimonFrame() {
// Bouml preserved body begin 0001F983
Create(NULL,wxID_ANY,wxT("WiMon"));
// Ajout d'une barre de menu:
wxMenu* fileMenu = new wxMenu;
fileMenu->Append(Menu_File_Open, _T("&Open..."), _T("Open a model file"));
fileMenu->AppendSeparator();
fileMenu->Append(Menu_File_Quit, _T("E&xit\tAlt-X"), _T("Quit the application"));
wxMenu* helpMenu = new wxMenu;
helpMenu->Append(Menu_Help_About, _T("&About..."), _T("About WiMon"));
wxMenuBar* menuBar = new wxMenuBar(wxMB_DOCKABLE);
menuBar->Append(fileMenu, _T("&File"));
menuBar->Append(helpMenu, _T("&Help"));
SetMenuBar(menuBar);
// Ajout d'une barre de status:
wxStatusBar* statusBar = new wxStatusBar(this);
int statusWidths[] = {-1,-1};
statusBar->SetFieldsCount(2,statusWidths);
SetStatusBar(statusBar);
// Construction de la fenètre:
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->SetMinSize(640,480);
SetSizer(sizer);
sizer->SetSizeHints(this);
// Bouml preserved body end 0001F983
}
void WimonFrame::OnQuit(wxCommandEvent & event) {
// Bouml preserved body begin 00020283
Close(true);
// Bouml preserved body end 00020283
}
void WimonFrame::OnAbout(wxCommandEvent & event) {
// Bouml preserved body begin 00020303
wxMessageBox(wxString::Format(
_T("Welcome to WiMon v0.1\n")
_T("\n")
_T("This is the first prototype version.\n")
_T("Platform: %s"),
wxGetOsDescription()),_T("About WiMon"), wxOK | wxICON_INFORMATION, this);
// Bouml preserved body end 00020303
}
void WimonFrame::OnOpen(wxCommandEvent & event) {
// Bouml preserved body begin 00020383
wxFileDialog dialog
(
this,
_T("Select 3D model file to open"),
wxEmptyString,
wxEmptyString,
_T("OSG files (*.ive;*.osg)|*.ive;*.osg")
);
dialog.CentreOnParent();
//dialog.SetDirectory(wxGetHomeDir());
if (dialog.ShowModal() == wxID_OK)
{
// On commence par récupérer le notebook principal:
wxNotebook* book = (wxNotebook*)wxWindow::FindWindowById(Main_Notebook,this);
if(!book) {
// Le notebook n'existe pas encore, il faut l'ajouter:
book = new wxNotebook(this,Main_Notebook);
GetSizer()->Add(book,1,wxEXPAND|wxALL,2);
GetSizer()->Layout();
}
bool created = false;
if(!cViewer.valid()) {
cViewer = new osgViewer::CompositeViewer;
created = true;
}
// On crée la vue que l'on va utiliser pour charger ce modèle:
OSGPanel* panel = new OSGPanel(book);
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile((const char*)dialog.GetPath().mb_str(wxConvUTF8));
panel->getView()->setSceneData(node.get());
cViewer->addView(panel->getView());
if(created) {
// add the state manipulator
osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
statesetManipulator->setStateSet(panel->getView()->getCamera()->getOrCreateStateSet());
panel->getView()->addEventHandler( statesetManipulator.get() );
}
book->AddPage(panel,wxT("Model"));
}
// Bouml preserved body end 00020383
}
void WimonFrame::OnIdle(wxIdleEvent & event) {
// Bouml preserved body begin 00021503
if(cViewer.valid())
cViewer->frame();
event.RequestMore();
// Bouml preserved body end 00021503
}
WimonFrame.h
Description: Binary data
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

