0

I want to use selection in my 3d viewer ,and I tried this example ,but I faced the following problem :

error: ‘SceneElement’ was not declared in this scope QList sceneElements ;

scene.h file:

#ifndef SCENE_H
#define SCENE_H
 #include <sceneelement.h>
#include <QGLViewer/qglviewer.h>

class Scene
{

private:
    /// The list of elements that make up the scene

 QList <SceneElement*> sceneElements ;

public:
     Scene();
    /// Creates a scene with RenderElements positionned on a regular grid.
    /// Consider increasing selectBufferSize() if you use more RenderElements.

    void draw();
    void setSelected(int i);
    void drawWithNames();
void clearSelection();
};

sceneelement.h file:

#include <QGLViewer/qglviewer.h>
#include <viewer.h>

class SceneElement
{

    friend class Scene;
private:

    qglviewer::Frame frame;
    bool isSelected;


public:
    /// Constructor
    SceneElement(float x, float y){
        isSelected=false;
        qglviewer::Vec pos(x,y,0.0);
        frame.setPosition(pos);
    }
    /// Draws this element
    void draw() const;

};

I don't know why it couldn't use SceneElement,although I included sceneelement.h

I appreciate any help , thank you.

user3019180
  • 80
  • 1
  • 7
  • I would try checking that there is only one sceneelement.h file and that you are in fact including the right one. Secondly, could you paste sceneelement.h? Can it be that sceneelement.h uses the same include guards that scene.h uses? – CuriouslyRecurringThoughts Jul 21 '19 at 08:20
  • @CuriouslyRecurringThoughts I updated the question post with sceneelement.h file . – user3019180 Jul 21 '19 at 08:58
  • 1
    It looks like you have a [circular dependency](https://en.wikipedia.org/wiki/Circular_dependency). Try to add a forward declaration `class SceneElement` just before the line `class Scene` in scene.h – Dimitry Ernot Jul 21 '19 at 09:18

1 Answers1

0

that suggestion solves my problem It looks like you have a circular dependency. Try to add a forward declaration class SceneElement just before the line class Scene in scene.h – Romha Korev

user3019180
  • 80
  • 1
  • 7