I have attached the screenshot of my application running.  I have also
attached the view class.  Again the class was generated by KDevelop and
I have modified it.

I have been looking at the example Rafa mentioned, but I still cannot
find the solution to the issue I am having.  I select the cube.osg file
from the following location: OSG_OP_OT-1.2/Producer/Test/Trackball

My application reads the file and it displays.  However, what you see in
my screenshot disappears and I get a full screen of the cube.  I am
hoping some one can tell me what I am missing.  I would like the cube to
be displayed in the window of the application.

I am a beginner with OSG, so forgive me if this is trivial.  If someone
has any advice, please send it my way.  Now back to the reference
documentation.

Thanks,
Michael

On Wed, 2008-01-02 at 08:53 +0100, Rafa Gaitan wrote:
> Hi Michael, 
> 
> 
> mmh I don't know, I successfully created a Viewer in Java, so,
> probably you are missing
> something...Have you called to setUpViewerAsEmbedded method?.. .You
> should have
> all you need in the viewer examples of the OSG source tree.
> 
> 
> Rafa.
> 
> On Jan 1, 2008 11:45 PM, Michael W. Hall <[EMAIL PROTECTED]> wrote:
>         Thanks for the info Rafa.  I appear to have something
>         working.  I my
>         KMapView class is derived from QGLWidget and
>         osgViewer::Viewer.  The 
>         application compiled successfully.
>         
>         To test it I tried to open cube.osg that came with my osg
>         source.  It
>         appeared to open the file.  It was a yellow cube with a symbol
>         that
>         looked like a lamda.  However, when the file was opened it was
>         showing 
>         full screen.  My question is how do you keep this from
>         happening?  Was
>         it the file or is there something wrong in my code?
>         
>         Thanks,
>         Michael
>         
>         
>         On Thu, 2007-12-27 at 08:18 +0100, Rafa Gaitan wrote:
>         > Hi Michael,
>         >
>         > I'm not an expert in QT, but probably you can take a look
>         > to osgviewerQT example inside OSG source tree.
>         >
>         > Rafa.
>         >
>         > On Dec 27, 2007 4:35 AM, Michael W. Hall <[EMAIL PROTECTED]>
>         wrote:
>         >         I have created a KDevelop project using the
>         Application
>         >         framework 
>         >         template.  I have made my kmapview.cpp class derive
>         from
>         >         QGLWidget.  I
>         >         created a member variable, m_Viewer in the KMapView
>         class.  I
>         >         have in my
>         >         constructor for KMapView the following: 
>         >
>         >
>          m_Viewer.getCamera()->setProjectionMatrixAsPerspective(
>         >                40., 1., 1., 100. );
>         >
>          m_Viewer.getCamera()->setClearColor( osg::Vec4( 0., 0., 0.,
>         >         1. ) ); 
>         >
>         >         However, it doesn't appear that anything is
>         changing.  I ran
>         >         the
>         >         application after creating the project to see how it
>         looked.
>         >          With the
>         >         above changes, it appears that nothing is being
>         effected.  The 
>         >         window
>         >         still looks the same as when I first ran it.  I have
>         still
>         >         have a window
>         >         with a white background.  I have attached a picture
>         of the
>         >         application 
>         >         running.
>         >
>         >         I was hoping the big white field would have changed
>         to an
>         >         osgViewer as
>         >         the window where the white field is.  Any ideas as
>         how to
>         >         replace the 
>         >         white field with an osgViewer?  I am a beginner with
>         OSG.  I
>         >         am playing
>         >         to learn.  I have read the OpenSceneGraph Quick
>         Start Quide.
>         >
>         >         Thanks for any help. 
>         >
>         >         _______________________________________________
>         >         osg-users mailing list
>         >         osg-users@lists.openscenegraph.org
>         >
>         
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>         >
>         >
>         >
>         > -- 
>         > Rafael Gaitán Linares
>         > Instituto de Automática e Informática Industrial
>         >  http://www.ai2.upv.es
>         > Ciudad Politécnica de la Innovación
>         > Universidad Politécnica de Valencia 
>         
>         > _______________________________________________
>         > osg-users mailing list
>         > osg-users@lists.openscenegraph.org
>         >
>         
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>         
>         
>         _______________________________________________ 
>         
>         osg-users mailing list
>         osg-users@lists.openscenegraph.org
>         
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>         
> 
> 
> 
> -- 
> Rafael Gaitán Linares 
> Instituto de Automática e Informática Industrial
>  http://www.ai2.upv.es
> Ciudad Politécnica de la Innovación
> Universidad Politécnica de Valencia
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

<<attachment: Screenshot-KMap.png>>

/***************************************************************************
 *   Copyright (C) 2007 by Michael W. Hall   *
 *   [EMAIL PROTECTED]   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#include "kmapview.h"

#include <qpainter.h>
#include <qlayout.h>

#include <kurl.h>

#include <ktrader.h>
#include <klibloader.h>
#include <kmessagebox.h>
#include <krun.h>
#include <klocale.h>

#include <osgDB/ReadFile>

KMapView::KMapView(QWidget *parent)
    : QGLWidget(parent),
      DCOPObject("KMapIface")
{

    // Get a graphics context.
    m_gw = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height());

    // Set the viewport.
    getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));

    // Set the Projection Matrix.
    getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);

    // Set the graphics context.
    getCamera()->setGraphicsContext(getGraphicsWindow());

    setThreadingModel(osgViewer::Viewer::SingleThreaded);

}

KMapView::~KMapView()
{
}

osgViewer::GraphicsWindow* KMapView::getGraphicsWindow()
{
   return m_gw.get();
}

void KMapView::print(QPainter *p, int height, int width)
{
    // do the actual printing, here
    // p->drawText(etc..)
}

QString KMapView::currentURL()
{
    return m_html->url().url();
}

void KMapView::open(QString filename)
{
    m_Viewer.setSceneData(osgDB::readNodeFile(filename));
    m_Viewer.run();
}

//void KMapView::openURL(const KURL& url)
//{
//    m_html->openURL(url);
//}

void KMapView::slotOnURL(const QString& url)
{
    emit signalChangeStatusbar(url);
}

void KMapView::slotSetTitle(const QString& title)
{
    emit signalChangeCaption(title);
}
#include "kmapview.moc"
/***************************************************************************
 *   Copyright (C) 2007 by Michael W. Hall   *
 *   [EMAIL PROTECTED]   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#ifndef _KMAPVIEW_H_
#define _KMAPVIEW_H_

#include <qwidget.h>
#include <kparts/part.h>
#include <kmapiface.h>
#include <qgl.h>
#include <osgViewer/Viewer>

class QPainter;
class KURL;

/**
 * This is the main view class for KMap.  Most of the non-menu,
 * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
 * here.
 *
 * This kmap uses an HTML component as an example.
 *
 * @short Main view
 * @author Michael W. Hall <[EMAIL PROTECTED]>
 * @version 0.1
 */
class KMapView : public QGLWidget, public osgViewer::Viewer, public KMapIface
{
    Q_OBJECT
public:
	/**
	 * Default constructor
	 */
    KMapView(QWidget *parent);

	/**
	 * Destructor
	 */
    virtual ~KMapView();

    osgViewer::GraphicsWindow* getGraphicsWindow();

    /**
     * Random 'get' function
     */
    QString currentURL();

    /**
     * Random 'set' function accessed by DCOP
     */
    virtual void open(QString filename);

    /**
     * Random 'set' function
     */
    //virtual void openURL(const KURL& url);

    /**
     * Print this view to any medium -- paper or not
     */
    void print(QPainter *, int height, int width);

signals:
    /**
     * Use this signal to change the content of the statusbar
     */
    void signalChangeStatusbar(const QString& text);

    /**
     * Use this signal to change the content of the caption
     */
    void signalChangeCaption(const QString& text);

private slots:
    void slotOnURL(const QString& filename);
    void slotSetTitle(const QString& title);

protected:
    //void initializeGL();
    //void paintEvent(QPaintEvent* paintEvent);
    //void paintGL();
    //void resizeGL(int width, int height);

    osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> m_gw;


private:
    KParts::ReadOnlyPart *m_html;

    osgViewer::Viewer m_Viewer;
};

#endif // _KMAPVIEW_H_
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to