Reply to topic

Write a Custom AbstractFloatItem

Beacon11
Registered Member
Posts
35
Karma
0

Write a Custom AbstractFloatItem

Fri Mar 08, 2013 6:43 pm
Hello all. I'm wanting to write a simplified version of the NavigationFloatItem with only zoom controls (no pan controls). Please bear with me: I have no plugin experience as far as Qt is concerned. So I wrote something with this interface:

Code: Select all
#include <QObject>
#include <marble/MarbleGlobal.h>
#include <marble/AbstractFloatItem.h>

namespace Marble
{

   class MarbleWidget;
   class WidgetGraphicsItem;

   class ZoomFloatItem: public AbstractFloatItem
   {
      Q_OBJECT

      Q_INTERFACES( Marble::RenderPluginInterface )

      MARBLE_PLUGIN( ZoomFloatItem )

      public:
         ZoomFloatItem();
         explicit ZoomFloatItem( const MarbleModel *marbleModel );
         ~ZoomFloatItem();

         QStringList backendTypes() const;

         QString name() const;

         QString guiString() const;

         QString nameId() const;

         QString version() const;

         QString description() const;

         QString copyrightYears() const;

         QList<PluginAuthor> pluginAuthors() const;

         QIcon icon () const;

         void initialize ();

         bool isInitialized () const;

         void changeViewport( ViewportParams *viewport );

      protected:
         bool eventFilter( QObject *object, QEvent *e );

      private Q_SLOTS:
         /** Adjust slider value to zoom level provided */
         void setZoomSliderValue( int level );

         void setMarbleZoomValue( int level );

         /** Map theme was changed, adjust controls */
         void selectTheme( QString theme );

         /** Decrease quality during zooming */
         void adjustForAnimation();

         /** Normal quality when not zooming */
         void adjustForStill();

         /** Enable/disable zoom in/out buttons */
         void updateButtons( int zoomValue );

      private:
         /** MarbleWidget this float item is installed as event filter for */
         MarbleWidget *m_marbleWidget;

         /** The GraphicsItem presenting the widgets. NavigationFloatItem doesn't take direct ownership
        of this */
         WidgetGraphicsItem *m_widgetItem;

         /** Used Profile */
         MarbleGlobal::Profiles m_profiles;

         /** Radius of the viewport last time */
         int m_oldViewportRadius;
   };
}


The .cpp is really just stubbed out functions for now. Compiling this results in an "Undefined interface" error from Q_INTERFACES line. What am I missing? Is this possible? There's a tutorial for the LayerInterface stuff... why is there no tutorial for this?
User avatar Earthwings
KDE Developer
Posts
89
Karma
1
OS

Re: Write a Custom AbstractFloatItem

Sat Mar 09, 2013 12:53 pm
You need to have an
Code: Select all
#include <marble/RenderPluginInterface.h>
since Marble::RenderPluginInterface is defined in it.
Beacon11
Registered Member
Posts
35
Karma
0

Re: Write a Custom AbstractFloatItem

Mon Mar 11, 2013 11:02 am
Thanks Earthwings, but that changed nothing. This is what I have now:

Code: Select all
#include <QObject>
#include <marble/MarbleGlobal.h>
#include <marble/AbstractFloatItem.h>
#include <marble/RenderPluginInterface.h>

namespace Marble
{
   class MarbleWidget;
   class WidgetGraphicsItem;

   class ZoomFloatItem: public AbstractFloatItem
   {
      Q_OBJECT

      Q_INTERFACES( Marble::RenderPluginInterface )

      MARBLE_PLUGIN( ZoomFloatItem )

      public:
         ZoomFloatItem();
         explicit ZoomFloatItem( const MarbleModel *marbleModel );
         ~ZoomFloatItem();

         QStringList backendTypes() const;

         QString name() const;

         QString guiString() const;

         QString nameId() const;

         QString version() const;

         QString description() const;

         QString copyrightYears() const;

         QList<PluginAuthor> pluginAuthors() const;

         QIcon icon () const;

         void initialize ();

         bool isInitialized () const;

         void changeViewport( ViewportParams *viewport );

      protected:
         bool eventFilter( QObject *object, QEvent *e );

      private Q_SLOTS:
         /** Adjust slider value to zoom level provided */
         void setZoomSliderValue( int level );

         void setMarbleZoomValue( int level );

         /** Map theme was changed, adjust controls */
         void selectTheme( QString theme );

         /** Decrease quality during zooming */
         void adjustForAnimation();

         /** Normal quality when not zooming */
         void adjustForStill();

         /** Enable/disable zoom in/out buttons */
         void updateButtons( int zoomValue );

      private:
         /** MarbleWidget this float item is installed as event filter for */
         MarbleWidget *m_marbleWidget;

         /** The GraphicsItem presenting the widgets. NavigationFloatItem doesn't take direct ownership
        of this */
         WidgetGraphicsItem *m_widgetItem;

         /** Used Profile */
         MarbleGlobal::Profiles m_profiles;

         /** Radius of the viewport last time */
         int m_oldViewportRadius;
   };
}
Beacon11
Registered Member
Posts
35
Karma
0

Re: Write a Custom AbstractFloatItem

Mon Mar 11, 2013 11:04 am
Addtionally, in my .cpp, if I copy what NavigationFloatItem has and do something like this:

Code: Select all
<snip>

Q_EXPORT_PLUGIN2(ZoomFloatItem, ZoomFloatItem)

#include "zoom_float_item.moc"


I get a "zoom_float_item.moc: No such file or directory." Any change these issues are related?
User avatar Earthwings
KDE Developer
Posts
89
Karma
1
OS

Re: Write a Custom AbstractFloatItem

Wed Mar 13, 2013 10:00 pm
How are you building your code? moc is not run, or called but produces a different file than the one you're including.

 
Reply to topic

Bookmarks



Who is online

Registered users: alake, Alexa [Bot], Baidu [Spider], Bing [Bot], blue_bullet, chicken2jail, claydoh, colomar, Exabot [Bot], garthecho, ghevan, Google [Bot], google01103, Hans, inhiway, kainz.a, koriun, La Ninje, lazyit, Majestic-12 [Bot], mmistretta, nezumi, pedrorodriguez, private_lock, robinh, scummos, Tuukka, urgo, Uri_Herrera, wolfi323, Yahoo [Bot]