00001
00002
00003
00004 #ifndef __COMPONENT_H
00005 #define __COMPONENT_H
00006
00007 #include "graphics.h"
00008 #include "frame.h"
00009 #include <vector>
00010 #include <string>
00011
00012
00013
00014 using namespace std;
00015
00016 static const int COMPONENT_TYPE_FILTER = 0;
00017 static const int COMPONENT_TYPE_INPUTFILTER = 1;
00018
00019 static const int COMPONENTPIN_TYPE_INPUT = 0;
00020 static const int COMPONENTPIN_TYPE_OUTPUT = 1;
00021
00022 static const int PIN_DIRECTION_LEFT = 0;
00023 static const int PIN_DIRECTION_UP = 1;
00024 static const int PIN_DIRECTION_RIGHT = 2;
00025 static const int PIN_DIRECTION_DOWN = 3;
00026
00027 static const int COMPONENT_ROTATION_0_DEG = 0;
00028 static const int COMPONENT_ROTATION_90_DEG = 1;
00029 static const int COMPONENT_ROTATION_180_DEG = 2;
00030 static const int COMPONENT_ROTATION_270_DEG = 3;
00031
00032 static const int NB_COMPONENT_ROTATION_DEGS = 4;
00033
00034 class WireEnd;
00035 class Component;
00036 class Wire;
00037
00038 static int component_index_counter = 0;
00039
00040 class ComponentPin{
00041 public:
00042 ComponentPin(Component *parent, int pintype);
00043 ~ComponentPin();
00044
00045
00046
00047 void print();
00048
00049 Component *parent;
00050 int pintype;
00051
00052
00053
00054 vector<WireEnd *> connected_wireends;
00055 friend class WireEnd;
00056
00057
00058 };
00059
00060
00061
00062 class Component{
00063
00064 public:
00065 Component(void *object, int component_type);
00066 ~Component();
00067
00068 int index;
00069 int component_type;
00070
00071
00072
00073 void draw(Graphics *g, int scale, bool selected, bool valid);
00074 int width();
00075 int height();
00076 void rotate();
00077 char *get_name();
00078
00079 int x;
00080 int y;
00081
00082 char *component_label;
00083
00084 bool executing;
00085
00086 bool is_input_pin(int tx, int ty);
00087 bool is_output_pin(int tx, int ty);
00088
00089
00090 ComponentPin *inputpin;
00091 ComponentPin *outputpin;
00092
00093 vector<Component *> *get_output_receivers();
00094 Component *get_output_receiver();
00095
00096
00097 void *object;
00098
00099 private:
00100
00101
00102
00103 int _width;
00104 int _height;
00105 int _rotation;
00106
00107
00108 void draw_pin(Graphics *g, int scale, int x, int y, int pin_direction);
00109
00110 };
00111
00112
00113 #endif