bonjour, je n'arrive pas à résoudre un problème concernant la récupération de données à partir d'un fichier.

Le fichier cercles.cir contient un exemple de fichier texte contenant des cercles.
Il est écrit dans le format que j'ai choisi pour sauvegarder des fichiers.

Ce format est constitué d’une première ligne contenant un entier n représentant le nombre de
cercles contenus dans le fichier.
Puis, après une ligne vide, viennent n blocs de données contenant chacun 3 lignes :

– la première contient 3 entiers correspondant aux coordonnées 2D du centre du cercle et de
son rayon : xyr
– la seconde contient 4 entiers compris entre 0 et 255 qui correspondent à la couleur de l’intérieur
du cercle au format RGBA.
– la troisième contient un entier représentant l’épaisseur de trait du bord du cercle.

Voici le fichier en question:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
4
 
-208 158 86
0 255 0 255
5
 
-153 111 117
0 0 255 128
2
 
253 -59 147
255 0 0 128
2
 
-96 -56 230
255 0 0 128
2
j'essaye de récuperer ces donnée dans un vecteur que j'ai nommé_tab_circle.

Voici la classe Mainframe:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
class MainFrame: public wxFrame {
public:
  //Constructeur & Destrucuteur
  MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
  ~MainFrame();
 
  void onInit();
 
private:
 
  bool is_drawing;
  int _num_circle;
  std::vector<Circle> _tab_circle;
DECLARE_EVENT_TABLE();
}; //MainFrame
Voici la class circle:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
#ifndef CIRCLE_H
#define CIRCLE_H
 
#include <wx/wx.h>
 
class Circle {
 
public:
	Circle();
	Circle(wxPoint center, int radius, wxColor colour, int thickness);
	Circle(Circle& t);
 
	~Circle();
 
	void setCenter(const wxPoint& val)		{ _center = val; }
	wxPoint center() const					{ return _center; }
 
	void setRadius(int val)				{ _radius = val; }
	int radius() const					{ return _radius; }
 
	void setColour(const wxColor& val)	{ _colour = val; }
	wxColor colour() const				{ return _colour; }
 
	void setThickness(int val)			{ _thickness = val; }
	int thickness() const				{ return _thickness; }
 
	Circle& operator=(const Circle &t);
 
protected:
	wxPoint _center;
	int _radius;
 
	wxColor _colour;
 
	int _thickness;
};
 
#endif
Voici le fichier circle.cpp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
#include "circle.h"
 
#include <wx/listimpl.cpp>
WX_DEFINE_LIST(CircleList);
 
Circle::Circle()
{
}
 
Circle::Circle(wxPoint center, int radius, wxColor colour, int thickness)
{
	_center = center;
	_radius = radius;
 
	_colour = colour;
	_thickness = thickness;
}
 
Circle::Circle(Circle& t)
{
	_center = t.center();
	_radius = t.radius();
 
	_colour = t.colour();
 
	_thickness = t.thickness();
}
 
Circle::~Circle()
{
}
 
Circle& Circle::operator=(const Circle &t)
{
	if(&t != this) {
		_center = t.center();
		_radius = t.radius();
 
		_colour = t.colour();
 
		_thickness = t.thickness();
	}
 
	return *this;
}
Voici la fonction dans laquelle on vas commencer a extraire les données:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
void MainFrame::OnOpen( wxCommandEvent& event )
{
  int red, green, blue,cyan; 
  int i = 0;
  wxFileDialog filedialog ( this, wxT("Open"), wxT("./save/"), wxEmptyString, wxT("*"),wxOPEN, wxDefaultPosition );
  filedialog.ShowModal();
  Circle mycircle;
 
  // Ouvre le fichier
  wxFileInputStream file ( filedialog.GetPath ( ) ) ;
  // Test si l’ouverture a reussi
  if (file .IsOk( )) 
  {
    // Transforme le fichier en un flux de texte
    wxTextInputStream in (file) ;
    // Ici les commandes pour lire
 
    // on veut lire une donnéé du flux in, et qu’on veut la ranger dans _num_circle
    in >> _num_circle ;
    if( _num_circle > 0)
    {
		GetMenuBar()->Enable( OPTION_CERCLE, TRUE);
 
		for( i = 0 ; i < _num_circle; i++)
		{    
		    in >> mycircle._center.x >> mycircle._center.y >> mycircle._radius;
		    in >> red >> green >> blue >> cyan;
		    mycircle._colour = wxColour( red, green, blue, cyan );
		    in >> mycircle._thickness;
		    _tab_circle.push_back(mycircle);
		}
		Refresh();
    }
 
 
  } 
  else 
  {
    // if open file failed , show an error message box
    wxString errormsg, caption;
    errormsg.Printf(wxT("Unable to open file "));
    errormsg.Append(filedialog.GetPath());
    caption.Printf(wxT("Erreur"));
    wxMessageDialog msg( this, errormsg, caption, wxOK | wxCENTRE | wxICON_ERROR );
    msg.ShowModal();
    return ;
  }
 
 
}
quand j'essaye de compiler le programme ,j'ai des erreurs :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
circle.h: In member function ‘void MainFrame::OnOpen(wxCommandEvent&)’:
circle.h:31: error: ‘wxPoint Circle::_center’ is protected
mainframe.cpp:144: error: within this context
circle.h:31: error: ‘wxPoint Circle::_center’ is protected
mainframe.cpp:144: error: within this context
circle.h:32: error: ‘int Circle::_radius’ is protected
mainframe.cpp:144: error: within this context
circle.h:34: error: ‘wxColour Circle::_colour’ is protected
mainframe.cpp:146: error: within this context
circle.h:36: error: ‘int Circle::_thickness’ is protected
mainframe.cpp:147: error: within this context
In file included from /usr/include/c++/4.4/i486-linux-gnu/bits/c++allocator.h:34,
                 from /usr/include/c++/4.4/bits/allocator.h:48,
                 from /usr/include/c++/4.4/string:43,
                 from /usr/include/wx-2.8/wx/string.h:176,
                 from /usr/include/wx-2.8/wx/memory.h:16,
                 from /usr/include/wx-2.8/wx/object.h:20,
                 from /usr/include/wx-2.8/wx/wx.h:16,
                 from mainframe.cpp:3:
/usr/include/c++/4.4/ext/new_allocator.h: In member function ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Tp*, const _Tp&) [with _Tp = Circle]’:
/usr/include/c++/4.4/bits/stl_vector.h:737:   instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = Circle, _Alloc = std::allocator<Circle>]’
mainframe.cpp:148:   instantiated from here
/usr/include/c++/4.4/ext/new_allocator.h:105: error: no matching function for call to ‘Circle::Circle(const Circle&)’
circle.h:12: note: candidates are: Circle::Circle(Circle&)
circle.h:11: note:                 Circle::Circle(wxPoint, int, wxColour, int)
circle.h:10: note:                 Circle::Circle()
In file included from /usr/include/c++/4.4/vector:69,
                 from mainframe.cpp:6:
/usr/include/c++/4.4/bits/vector.tcc: In member function ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = Circle, _Alloc = std::allocator<Circle>]’:
/usr/include/c++/4.4/bits/stl_vector.h:741:   instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = Circle, _Alloc = std::allocator<Circle>]’
mainframe.cpp:148:   instantiated from here
/usr/include/c++/4.4/bits/vector.tcc:306: error: no matching function for call to ‘Circle::Circle(const Circle&)’
circle.h:12: note: candidates are: Circle::Circle(Circle&)
circle.h:11: note:                 Circle::Circle(wxPoint, int, wxColour, int)
circle.h:10: note:                 Circle::Circle()
make: *** [mainframe.o] Erreur 1
Pouvez vous me dire où se trouve mon erreur?

Merci de votre compréhension.