00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "DynamicLineArt.h"
00023 #include "Visible.h"
00024 #include "Presentable.h"
00025 #include "Ingredients.h"
00026 #include "Root.h"
00027 #include "BaseClasses.h"
00028 #include "ParseNode.h"
00029 #include "ASN1Codes.h"
00030 #include "Engine.h"
00031 #include "freemheg.h"
00032
00033 MHDynamicLineArt::MHDynamicLineArt()
00034 {
00035 m_picture = NULL;
00036 }
00037
00038 MHDynamicLineArt::~MHDynamicLineArt()
00039 {
00040 delete(m_picture);
00041 }
00042
00043
00044 void MHDynamicLineArt::Initialise(MHParseNode *p, MHEngine *engine)
00045 {
00046 MHLineArt::Initialise(p, engine);
00047 m_picture =
00048 engine->GetContext()->CreateDynamicLineArt(m_fBorderedBBox, GetColour(m_OrigLineColour), GetColour(m_OrigFillColour));
00049 }
00050
00051 void MHDynamicLineArt::PrintMe(FILE *fd, int nTabs) const
00052 {
00053 PrintTabs(fd, nTabs); fprintf(fd, "{:DynamicLineArt ");
00054 MHLineArt::PrintMe(fd, nTabs+1);
00055 PrintTabs(fd, nTabs); fprintf(fd, "}\n");
00056 }
00057
00058 void MHDynamicLineArt::Preparation(MHEngine *engine)
00059 {
00060 MHLineArt::Preparation(engine);
00061 m_picture->SetSize(m_nBoxWidth, m_nBoxHeight);
00062 m_picture->SetLineSize(m_nLineWidth);
00063 m_picture->SetLineColour(GetColour(m_LineColour));
00064 m_picture->SetFillColour(GetColour(m_FillColour));
00065 }
00066
00067 void MHDynamicLineArt::Display(MHEngine *)
00068 {
00069 m_picture->Draw(m_nPosX, m_nPosY);
00070 }
00071
00072
00073 QRegion MHDynamicLineArt::GetOpaqueArea()
00074 {
00075 if ((GetColour(m_OrigFillColour)).alpha() == 255) return GetVisibleArea();
00076 else return QRegion();
00077 }
00078
00079
00080 void MHDynamicLineArt::Clear()
00081 {
00082 m_picture->Clear();
00083 }
00084
00085
00086 void MHDynamicLineArt::SetBoxSize(int nWidth, int nHeight, MHEngine *engine)
00087 {
00088 MHLineArt::SetBoxSize(nWidth, nHeight, engine);
00089 m_picture->SetSize(nWidth, nHeight);
00090 Clear();
00091 }
00092
00093
00094
00095
00096 void MHDynamicLineArt::SetFillColour(const MHColour &colour, MHEngine *)
00097 {
00098 m_FillColour.Copy(colour);
00099 m_picture->SetFillColour(GetColour(m_FillColour));
00100 }
00101
00102 void MHDynamicLineArt::SetLineColour(const MHColour &colour, MHEngine *)
00103 {
00104 m_LineColour.Copy(colour);
00105 m_picture->SetLineColour(GetColour(m_LineColour));
00106 }
00107
00108 void MHDynamicLineArt::SetLineWidth(int nWidth)
00109 {
00110 m_nLineWidth = nWidth;
00111 m_picture->SetLineSize(m_nLineWidth);
00112 }
00113
00114
00115 void MHDynamicLineArt::SetLineStyle(int nStyle) { m_LineStyle = nStyle; }
00116
00117
00118 void MHDynamicLineArt::GetLineColour(MHRoot *pResult)
00119 {
00120
00121 if (m_LineColour.m_nColIndex >= 0)
00122 pResult->SetVariableValue(m_LineColour.m_nColIndex);
00123 else pResult->SetVariableValue(m_LineColour.m_ColStr);
00124 }
00125
00126 void MHDynamicLineArt::GetFillColour(MHRoot *pResult)
00127 {
00128 if (m_FillColour.m_nColIndex >= 0)
00129 pResult->SetVariableValue(m_FillColour.m_nColIndex);
00130 else pResult->SetVariableValue(m_FillColour.m_ColStr);
00131 }
00132
00133 void MHDynamicLineArt::DrawLine(int x1, int y1, int x2, int y2, MHEngine *engine)
00134 {
00135 m_picture->DrawLine(x1, y1, x2, y2);
00136 engine->Redraw(GetVisibleArea());
00137 }
00138
00139 void MHDynamicLineArt::DrawRectangle(int x1, int y1, int x2, int y2, MHEngine *engine)
00140 {
00141 m_picture->DrawBorderedRectangle(x1, y1, x2-x1, y2-y1);
00142 engine->Redraw(GetVisibleArea());
00143 }
00144
00145 void MHDynamicLineArt::DrawOval(int x, int y, int width, int height, MHEngine *engine)
00146 {
00147 m_picture->DrawOval(x, y, width, height);
00148 engine->Redraw(GetVisibleArea());
00149 }
00150
00151 void MHDynamicLineArt::DrawArcSector(bool fIsSector, int x, int y, int width, int height,
00152 int start, int arc, MHEngine *engine)
00153 {
00154 m_picture->DrawArcSector(x, y, width, height, start, arc, fIsSector);
00155 engine->Redraw(GetVisibleArea());
00156 }
00157
00158 void MHDynamicLineArt::DrawPoly(bool fIsPolygon, const QPointArray &points, MHEngine *engine)
00159 {
00160 m_picture->DrawPoly(fIsPolygon, points);
00161 engine->Redraw(GetVisibleArea());
00162 }
00163
00164
00165
00166
00167 void MHDrawPoly::Initialise(MHParseNode *p, MHEngine *engine)
00168 {
00169 MHElemAction::Initialise(p, engine);
00170 MHParseNode *args = p->GetArgN(1);
00171 for (int i = 0; i < args->GetSeqCount(); i++) {
00172 MHPointArg *pPoint = new MHPointArg;
00173 m_Points.Append(pPoint);
00174 pPoint->Initialise(args->GetSeqN(i), engine);
00175 }
00176 }
00177
00178 void MHDrawPoly::Perform(MHEngine *engine)
00179 {
00180 QPointArray points(m_Points.Size());
00181 for (int i = 0; i < m_Points.Size(); i++) {
00182 MHPointArg *pPoint = m_Points[i];
00183 points.setPoint(i, pPoint->x.GetValue(engine), pPoint->y.GetValue(engine));
00184 }
00185 Target(engine)->DrawPoly(m_fIsPolygon, points, engine);
00186 }
00187
00188 void MHDrawPoly::PrintArgs(FILE *fd, int ) const
00189 {
00190 fprintf(fd, " ( ");
00191 for (int i = 0; i < m_Points.Size(); i++) m_Points[i]->PrintMe(fd, 0);
00192 fprintf(fd, " )\n");
00193 }