Click here to Skip to main content
15,881,809 members
Articles / Desktop Programming / MFC

2D Graph ActiveX Control

Rate me:
Please Sign up or sign in to vote.
4.89/5 (159 votes)
5 Aug 2003MIT8 min read 1.5M   70.2K   339  
An ActiveX control for 2D data visualisation
// NVector.h: interface for the CNVector class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_NVECTOR_H__20F39921_490B_4640_A830_CD50343AF2AF__INCLUDED_)
#define AFX_NVECTOR_H__20F39921_490B_4640_A830_CD50343AF2AF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <iostream>
#include <vector>
using namespace std;

class CNVector : public vector<double>  
{
public:
	CNVector(); //  Constructs an empty vector. 
    CNVector( unsigned int size ); //  Constructs a vector with the specified number of elements.
    CNVector( unsigned int size, double value );  //  Constructs a vector with the specified number of elements initialized to a constant value. 
    CNVector( unsigned int size, const double* data ); //  Constructs a vector with the specified number of elements initialized from an array of data values. 
	CNVector( const CNVector& source ); // Copy Constructor
	virtual ~CNVector();
	double & Append( const double& element ); // Appends an element  
    double & Append( const CNVector& other ); // Appends the specified  
	void Copy( const CNVector& source ); // Copies the internal vector data from another vector  
    inline void CopyDataToVector( const double* data, unsigned int size ); // Copies a data array of the templatized type to this vector. 
	void Init( int size = 0 ); // Initializes the vector. 
	CNVector & operator =( const CNVector& source ); // Assignment operator. 
public:
    double operator []( int index ) const; // Returns the value of the vector element at the specified index. 
    double operator []( long index ) const; // Returns the value of the vector element at the specified index. 
    double operator []( unsigned int index ) const; // Returns the value of the vector element at the specified index. 
    double operator []( unsigned long index ) const; // Returns the value of the vector element at the specified index. 
    double & operator []( int index ); // Returns a reference to the value of the vector element at the specified index. 
    double & operator []( long index ); // Returns a reference to the value of the vector element at the specified index. 
    double & operator []( unsigned int index ); // Returns a reference to the value of the vector element at the specified index. 
    double & operator []( unsigned long index ); // Returns a reference to the value of the vector element at the specified index. 
    void Set( const double& value ); // Sets every element in the vector to the same value. 
private:
	double *buf;
	vector<double>vec;
	int length;


};  

#endif // !defined(AFX_NVECTOR_H__20F39921_490B_4640_A830_CD50343AF2AF__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions