IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

trace courbe en visual basic


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut trace courbe en visual basic
    Bonjour à tous ,
    Je reviens cette fois ci vous demandez de l'aide
    J'ai essayé d'avancer tout seul mais la je bloque
    Je dois créer une application qui permet de tracer une courbe en fonction du temps.

    J'ai un code en c sharp
    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
     
     
     
    private: System::Void  traceCourbe (array <float> ^temperatures) 
    {			
    		 float a, pasX ;
    		 //
    		 //
    		 a = ((float) pGraphe->Height / (float)(min-max))  ;
    		 pasX = (float)(pGraphe->Width) / (float)(nbPts-1) ;
    		 drawBrush->Color = colCourbe ;
     
    		 //
    		 //
    		 array <Point> ^tempsPt = gcnew array <Point> (temperatures->Length) ;
    		 array <Point> ^tempsPtLb = gcnew array <Point> (temperatures->Length) ;
     
    		 //
    		 //
    		 for (int i = 0 ; i < temperatures->Length ; i++)
    		 {
    			 //
    			 //
    			 tempsPt[i].Y = (int) (a * (temperatures[i] - max)) ;
    			 tempsPt[i].X = (int) (i*pasX) ;
    			 //
    			 //
    			 tempsPtLb[i].Y = tempsPt[i].Y - 10;
    			 tempsPtLb[i].X = tempsPt[i].X + 10;
    			 //
    			 //
    			 g->DrawString (temps[i].ToString(), drawFont, drawBrush, tempsPtLb[i] ) ;
    			 //
    			 //
    			 g->DrawArc (penPt,tempsPt[i].X, tempsPt[i].Y, 5, 5, 0, 359) ; 
    		 }
    		 //
    		 //
    		 g->DrawCurve(penCourbe, tempsPt, 0.2) ;
     
    }


    et j'aimerais le mettre en visual basic:


    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
    52
    53
    54
    55
    56
    57
     
     
      Private Sub p_box_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles p_box.Click
            Dim a As Double
            Dim pasX As Double
            Dim nbPts As Integer
            Dim gradY As Integer
            Dim max As Integer
            Dim min As Integer
            Dim colCourbe As New System.Drawing.Color
            Dim colGrille As New System.Drawing.Color
            Dim g As System.Drawing.Graphics ' méthode
     
     
            Dim tempsPt(temperature->Lenght) as Point
           Dim tempsPtLb(temperature->Lenght) as Point
            Dim drawBrush As New SolidBrush(colCourbe)
     
     
     
    	      a = ((Double )) p_box->Height /( (Double)(min-max))  
    		 pasX =( (Double))(p_box->Width) / (Double)(nbPts-1)
     
     
            Dim  tempsPt(temperatures->Length) As point
     
     
            Dim i As Integer = 0
     
    		 For
     
     
     
    			 tempsPt[i].Y = (int) (a * (temperatures[i]) - max)) 
                tempsPt([i].X = (Int())(i * pasX))
     
    			 tempsPtLb[i].Y = tempsPt[i].Y - 10
    			 tempsPtLb[i].X = tempsPt[i].X + 10
     
     
     
    			 g->DrawString (temps[i].ToString(), drawFont, drawBrush, tempsPtLb[i] ) 
     
     
    			 g->DrawArc (penPt,tempsPt[i].X, tempsPt[i].Y, 5, 5, 0, 359) 
     
            Next i
     
     
     
    		 g->DrawCurve(penCourbe, tempsPt, 0.2) 
     
     
     
     
     
        End Sub
    Le problème c'est que j'ai pleins de faute :


    Je continue à chercher dans mon coin
    Merci à vous

  2. #2
    Membre Expert Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Par défaut
    XD

    tu m'étonne que tu ais de fautes ...
    oublie de C sharp

    tu voudrais une fonction qui prenne par exemple la température et qui te la dessine dans un pictureBox ?

    le problème comme je t'ais dit,
    j'ais des taka qui sont très limites en ce moment ... (mm impossible)
    donc je vais pas avoir 1-2h a me pencher sur ton problème ....

    mai je me souvenais avoir vue un sujet interessant
    http://www.developpez.net/forums/d92...box-graphique/

    essaye avec sa déja
    (dsl de pas pouvoir faire + ...)

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    Ok meci d'avoir essayer , on verra ensemble un de ces quatre, fait ce que tuas de prioritaire avant

  4. #4
    Membre émérite Avatar de methylene
    Profil pro
    Inscrit en
    Février 2010
    Messages
    659
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Février 2010
    Messages : 659
    Par défaut
    Le lien qu'il t'a donné explique en effet comment "dessiner" une courbe. Le mieux c'est de coller le code histoire de voir comment cela fonctionne et de l'adapter à ta situation.

    Si tu as des questions je suis là.

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    le truc c'est que j'ai dejà le principe pour tracer une courbe

    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
     
     
    private: System::Void traceCourbe (array <float> ^temperatures)
    {
    float a, pasX ;
    //
    //
    a = ((float) pGraphe->Height / (float)(min-max)) ;
    pasX = (float)(pGraphe->Width) / (float)(nbPts-1) ;
    drawBrush->Color = colCourbe ;
     
    //
    //
    array <Point> ^tempsPt = gcnew array <Point> (temperatures->Length) ;
    array <Point> ^tempsPtLb = gcnew array <Point> (temperatures->Length) ;
     
    //
    //
    for (int i = 0 ; i < temperatures->Length ; i++)
    {
    //
    //
    tempsPt[i].Y = (int) (a * (temperatures[i] - max)) ;
    tempsPt[i].X = (int) (i*pasX) ;
    //
    //
    tempsPtLb[i].Y = tempsPt[i].Y - 10;
    tempsPtLb[i].X = tempsPt[i].X + 10;
    //
    //
    g->DrawString (temps[i].ToString(), drawFont, drawBrush, tempsPtLb[i] ) ;
    //
    //
    g->DrawArc (penPt,tempsPt[i].X, tempsPt[i].Y, 5, 5, 0, 359) ;
    }
    //
    //
    g->DrawCurve(penCourbe, tempsPt, 0.2) ;
     
    }


    Et un ami m' passé ce qu'il avait fait

    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
    52
    53
    54
    55
    56
    57
     
    Public Class clsCourbeTemperature
        Inherits PictureBox
        Private m_Temperature, m_EcartEntrePoints, m_NombrePointsMax As Integer
        Private m_NombreHautEchelle, m_NombreBasEchelle As String
        Private m_CouleurFond, m_CouleurTrait As Color
        Private m_col As Collection = New Collection
        Private b As Bitmap
        Private g As Graphics
     
        Public Sub New(ByVal ParentForm As Form, _
                       ByVal CouleurTrait As Color, _
                       ByVal CouleurFond As Color, _
                       ByVal TempsRafraichissement As Double, _
                       ByVal EcartEntrePoints As Integer, _
                       ByVal NombrePointsMax As Integer, _
                       ByVal NombreBasEchelle As String, _
                       ByVal NombreHautEchelle As String)
            Me.Width = ParentForm.ClientRectangle.Width
            Me.Height = ParentForm.ClientRectangle.Height
            Me.Parent = ParentForm
            m_EcartEntrePoints = EcartEntrePoints
            m_NombrePointsMax = NombrePointsMax
            m_CouleurFond = CouleurFond
            m_CouleurTrait = CouleurTrait
            m_NombreHautEchelle = NombreHautEchelle
            m_NombreBasEchelle = NombreBasEchelle
            b = New Bitmap(Me.Width, Me.Height)
            g = Graphics.FromImage(b)
        End Sub
     
        Public WriteOnly Property Temperature() As Double
            Set(ByVal value As Double)
                m_Temperature = value
                If m_col.Count >= m_NombrePointsMax Then
                    m_col.Remove(1)
                End If
                m_col.Add(((100 - m_Temperature) / 100) * Me.Height)
                Dim ft As New Font("Arial", 13, FontStyle.Regular, GraphicsUnit.Pixel)
                g.FillRectangle(New SolidBrush(m_CouleurFond), New Rectangle(0, 0, b.Width, b.Height))
                g.DrawString(m_NombreBasEchelle, ft, New SolidBrush(Color.White), 5, Me.Height - 20)
                g.DrawString(m_NombreHautEchelle, ft, New SolidBrush(Color.White), 5, 5)
                For x = 2 To m_col.Count
                    g.DrawLine(New Pen(m_CouleurTrait, 2), _
                               New Point(x * m_EcartEntrePoints, m_col.Item(x - 1)), _
                               New Point((x * m_EcartEntrePoints) + m_EcartEntrePoints, m_col.Item(x)))
                    If x = m_col.Count Then
                        g.DrawString(m_Temperature.ToString, _
                                     ft, _
                                     New SolidBrush(Color.Orange), _
                                     (x * m_EcartEntrePoints) + m_EcartEntrePoints, _
                                     m_col.Item(x))
                    End If
                Next
                Me.Image = b.Clone
            End Set
        End Property

    Et voici le code du formulaire apres avoir placé un timer dessus
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
     
    Public Class Form1
        Private p As clsCourbeTemperature
        Private rd As Random = New Random
     
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            p = New clsCourbeTemperature(Me, Color.Red, Color.Black, 1000, 20, 12, "0°C", "100°C")
        End Sub
     
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            p.Temperature = rd.next(0, 100)
        End Sub
    End Class
    Et voilà les erreurs que j'ai:





    Merci de ton aide

  6. #6
    Membre Expert Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Par défaut
    Pourtant je programme en vb.net,
    mais la avec ton code j'ais l'impression que tu écrits un autre langage...

    on va commencer pas a pas tu veux bien ?

    1/ ta PictureBox:
    Tu veux la créer en dynamique ou tu l'a déjà créer sur ton form grâce a la boite a outils ?

    2/ les valeurs :
    Ou récupére tu les valeurs ? (base de données? textBox? etc...)
    3/ La fonction :
    quels paramètres tu veut lui donner ..?
    PictureBox ou tu veut dessiner?
    Valeurs X,Y,Z *juste un temprérature je crois pour toi*?
    un temps en plus? ou c'est le timer qui s'en charge?

    * après on va regarder pour comment faire tout sa, mais défini moi bien ton projet en répondant aux question *

    ce que tu a à faire n'est pas très long en soit mais si tu prend du code a droite a gauche
    sans savoir comment il marche tu va jamais t'en sortir, fait le toi mm ce programme, mets y ta petite touche perso

Discussions similaires

  1. Dessiner une courbe en visual basic a partir d'une table excel
    Par jasmin_76 dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 04/04/2009, 08h27
  2. Différences entre Delphi et Visual Basic ?
    Par Anonymous dans le forum Débats sur le développement - Le Best Of
    Réponses: 75
    Dernier message: 30/03/2009, 20h09
  3. [MSChart] creation de courbe sous visual C++
    Par gabriel knight dans le forum MFC
    Réponses: 5
    Dernier message: 18/09/2006, 14h32
  4. [Excel] Courbes sous Excel avec Visual Basic
    Par françoisc dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 02/05/2005, 09h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo