00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031
00032
00033
00034 #ifndef ELEMENTARRAY_H
00035 #define ELEMENTARRAY_H
00036
00037
00038 #ifdef __GNUG__
00039 #pragma interface "ElementArray.h"
00040 #endif
00041
00042
00043 #include "mc/Element.h"
00044 #include "mc/MathCore.h"
00045 #include "mc/Operator.h"
00046
00047
00048
00049 class mcElementArrayHelpers;
00050 class mcMonomial;
00051 class mcFraction;
00052 class mcBracket;
00053 class mcNumber;
00054
00055
00058 #define mcELEMENTARRAY_DEFAULT_ROOM 4
00059
00062 #define mcELEMENTARRAY_EMPTYENTRY ((mcElement )0xFFFFFFFF)
00063
00067 #define mcEP_ELEMENTARRAY_FILTER mcEP_NONSTANDARD_BASE*2
00068
00071 #define mcFILTER_NO_INSTANCES_LIMIT -1
00072
00073
00074
00075
00077 class mcArrayEntry : public mcDataHelper
00078 {
00079 public:
00080
00082 int mdata_idx;
00083
00085 const mcElementArrayHelpers *mdata_arr;
00086
00087 public:
00088
00089 mcArrayEntry(const mcElementArrayHelpers *owner = NULL, int idx = -1)
00090 : mdata_arr(owner) { mdata_idx=idx; }
00091
00092 virtual ~mcArrayEntry() {}
00093
00094
00095
00098
00099 mcElement &data_GetRef() const;
00100
00101 int data_GetIdx() const;
00102 int math_GetIdx() const;
00103
00104 mcBracket &data_GetBracket() const { return (mcBracket &)data_GetRef(); }
00105 mcFraction &data_GetFraction() const { return (mcFraction &)data_GetRef(); }
00106
00107 bool data_isValid() const
00108 { return (mdata_arr != NULL) && (mdata_idx != -1); }
00109
00111
00112
00115
00116 void data_SetOwner(mcElementArrayHelpers *ref) { mdata_arr = ref; }
00117 void data_SetIdx(int idx) { mdata_idx = idx; }
00118
00120 };
00121
00122
00123
00124 extern mcArrayEntry mcEmptyArrayEntry;
00125
00126
00133 class mcFilter : public mcDataHelper
00134 {
00135 protected:
00136
00138 mcFilterType m_nType;
00139
00144 int m_nMaxInstances[mcNUM_ELEMENT_TYPES];
00145
00146 public:
00147
00153 mcFilter(mcFilterType type = mcFILTER_INCLUDE_ELEMENT_LIST,
00154 mcElementType t1 = mcET_INVALID, int count1 = -1);
00155 virtual ~mcFilter() {}
00156
00158 void DeepCopy(const mcFilter *f) {
00159 for (int i=0; i < mcNUM_ELEMENT_TYPES; i++)
00160 m_nMaxInstances[i] = f->m_nMaxInstances[i];
00161
00162 m_nType = f->m_nType;
00163 }
00164
00165
00166
00170
00177 void SetMaxInstancesFor(mcElementType t,
00178 int count = mcFILTER_NO_INSTANCES_LIMIT);
00179
00181 void math_AddAllowedMathData() {}
00182
00184 void SetFilterType(mcFilterType type) {
00185 m_nType = type;
00186 }
00187
00189
00190
00191
00196
00200 bool isElementTypeAllowed(mcElementType t, int num);
00201
00203 };
00204
00205
00206
00207
00208
00209
00210 mcDEFINE_HELPER_CLASSES(mcElementArray)
00211
00212
00213
00214
00215
00216 class mcElementArrayHelpers : public mcElementHelpers
00217 {
00218 friend class mcArrayEntry;
00219
00220 #ifdef mcENABLE_DATA
00221 private:
00222
00225 mcElement *mdata_pElemArray;
00226
00229 int mdata_nUpperBound;
00230
00231 protected:
00232
00234 int mdata_nElements;
00235
00238 mcFilter *mdata_pFilter;
00239
00240 #endif
00241
00242
00243
00244
00245 #ifdef mcENABLE_GUI
00246 protected:
00247
00251 int mgui_nCursorPos;
00252
00253
00254 public:
00255
00258 static wxPen *sgui_pSelectionPen;
00259
00265 static bool sgui_bDrawSelectionInverting;
00266
00274 virtual int gui_GetSpaceBetweenRatio() const
00275 { return 0; }
00276
00277 #ifdef mcELEMENTARRAY_DRAW_DECORATIONS
00278
00279 static wxBitmap *pBeginTriBmp, *pEndTriBmp;
00280 #endif
00281
00282 #endif
00283
00284
00285
00286
00287 public:
00288
00289 mcElementArrayHelpers() {
00290
00291
00292 mdata_nElements = mdata_nUpperBound = 0;
00293 mdata_pElemArray = NULL;
00294 mdata_pFilter = NULL;
00295 mgui_nCursorPos = 0;
00296 }
00297
00298 virtual ~mcElementArrayHelpers() {
00299 data_DeleteAll();
00300 mcSAFE_DELETE_ARRAY(mdata_pElemArray);
00301 mcSAFE_DELETE(mdata_pFilter);
00302 }
00303
00304
00305 protected:
00306
00308 void gui_Init() { mcElementHelpers::gui_Init(); mgui_nCursorPos = 0; }
00309
00310
00311
00312 #ifdef mcENABLE_DATA
00313 protected:
00314
00315 virtual int data_GetIdxFromEntry(const mcArrayEntry *p) const = 0;
00316 virtual mcElement &data_GetRefFromEntry(const mcArrayEntry *p) = 0;
00317
00318 public:
00319
00323
00324 #ifdef __MCDEBUG__
00325
00326 void data_Check() const;
00327
00330 wxString data_Debug(long flags) const;
00331
00333 wxString data_GetDebugName() const
00334 { return wxT("mcElementArray"); }
00335
00336 #endif
00337
00338 void data_DeepCopy(const mcElementHelpers *p);
00339
00343 void data_AddProperty(int p, void *val1 = NULL, void *val2 = NULL) {
00344 if (p == mcEP_ELEMENTARRAY_FILTER)
00345 data_ChangeFilter((const mcFilter *)val1);
00346 }
00347
00348 int data_GetChildrenCount() const {
00349 return mcElementHelpers::data_GetChildrenCount()+data_GetCount();
00350 }
00351
00352 const mcElement &data_GetConstChild(int n) const {
00353 mcRETURN_ELEMENT_CHILD(n, mcElementHelpers);
00354 return data_Get(n);
00355 }
00356
00357 void data_SetChild(int n, const mcElement &newchild) {
00358 mcSET_ELEMENT_CHILD(n, mcElementHelpers, newchild);
00359 data_Delete(n);
00360 data_Set(n, newchild);
00361 }
00362
00363
00366 void data_CheckArrayLimit();
00367
00369 void data_ChangeFilter(const mcFilter *p);
00370
00372 void data_UpdateFilterFor(mcElement &p, const mcFilter *f);
00373
00376 bool data_isElementAllowed(mcElementType type) const;
00377
00379 bool data_isSameAs(const mcElementHelpers *p) const;
00380
00382
00383
00384
00388
00394 virtual bool data_ScanArray(bool (*func)(const mcElement &), bool odd) const;
00395
00409 virtual int data_AddElements(const mcElement *p, int num, int pos = -1,
00410 bool bOverwrite = FALSE, bool bForceCopy = FALSE);
00411
00417 virtual mcElement &data_AddNewElement(mcElementType t, bool bOverwrite = FALSE, int pos = -1);
00418
00423 virtual mcElement &data_AddNewWrappedElement(mcElementType t,
00424 bool bOverwrite = FALSE, int pos = -1)
00425 { return data_AddNewElement(t, bOverwrite, pos); }
00426
00434 void data_Merge(const mcElementArray &p, int n = 0, bool bAddToEnd = TRUE);
00435
00443 virtual void data_AddNewOp(mcElementType type, int pos = -1);
00444
00446 virtual void data_AddNewEmptyBox(int pos = -1);
00447
00451 virtual void data_UpdateNeighbor(int n);
00452
00456 virtual void data_Delete(int entry);
00457
00465 virtual bool data_Delete(const mcElement &elem);
00466
00470 virtual void data_DeleteLast(int num);
00471
00475 virtual void data_DeleteFirst(int num);
00476
00479 virtual void data_DeleteAllElemType(mcElementType);
00480
00485 mcElement data_Detach(int n);
00486
00488 mcElement data_DetachLastElem(int num);
00489
00493 mcElement data_DetachAll();
00494
00497 void data_DeleteAll();
00498
00502 void data_MoveElemRight(int start);
00503
00512 void data_MoveElemLeft(int start);
00513
00518 void data_Move(int n, int k);
00519
00525 int data_MoveAllElemType(mcElementType t, mcElementArray &m);
00526
00530 void data_Swap(int index1, int index2);
00531
00542 int data_QueueElemType(mcElementType t, int firstpos);
00543
00547 virtual void data_Repair() {}
00548
00550 virtual bool data_isWrappingOnly(mcElementType t) const;
00551
00555 virtual const mcElement &data_GetWrapped(mcElementType t) const;
00556
00558
00559
00560
00561
00565
00569 inline void data_CheckIndex(int entry) const {
00570
00571 mcASSERT(mdata_pElemArray != NULL, wxT("Array not allocated yet"));
00572 mcASSERT(entry >= 0 && entry <= mdata_nUpperBound, wxT("Invalid index"));
00573 }
00574
00582 inline const mcElement &data_GetConst(int entry) const {
00583 data_CheckIndex(entry);
00584 return mdata_pElemArray[entry];
00585 }
00586
00587 inline const mcElement &data_Get(int entry) const
00588 { return data_GetConst(entry); }
00589
00590 inline mcElement &data_Get(int entry) {
00591 data_CheckIndex(entry);
00592 return mdata_pElemArray[entry];
00593 }
00594
00597 int data_GetIndexOf(const mcElement &p) const;
00598
00600 inline const mcElement &data_GetLast() const
00601 { return data_Get(data_GetCount()-1); }
00602
00603 inline mcElement &data_GetLast()
00604 { return data_Get(data_GetCount()-1); }
00605
00608 inline mcElement *data_GetArray(int n = 0) const {
00609 data_CheckIndex(n);
00610 return &mdata_pElemArray[n];
00611 }
00612
00619 inline int data_GetIndex(int id) const {
00620 for (int i=0; i < data_GetCount(); i++)
00621 if (data_Get(i).data_GetID() == id)
00622 return i;
00623 return -1;
00624 }
00625
00628 inline int data_GetCount() const {
00629 return mdata_nElements;
00630 }
00631
00634 inline int data_GetAvailableEntryCount() const {
00635 return mdata_nUpperBound;
00636 }
00637
00640 int data_GetNumOfElemType(mcElementType t) const;
00641
00643 int data_GetOpCount() const;
00644
00649 mcElement &data_GetElemOfType(int n, mcElementType t) const;
00650
00654 int data_GetElemIndexOfType(int n, mcElementType t) const;
00655
00658 mcElement &data_GetNonOpElem(int n) const;
00659
00662 int data_GetNonOpElemIndex(int n) const;
00663
00667 mcOperator &data_GetOp(int n) const;
00668
00676 int data_GetOpIndex(int n) const;
00677
00679 mcElementType data_GetOpTypeBetween(int n1, int n2) const;
00680
00682 mcElementType data_GetOpTypePreceding(int n) const;
00683
00684 mcOperator &data_GetOpPreceding(int n) const
00685 { return (mcOperator &)*data_GetInstanceOf(data_GetOpTypePreceding(n)); }
00686
00691 const mcElement &data_GetElemAtLeftOf(const mcElement &p) const {
00692 int n = data_GetIndexOf(p);
00693 return (n < 1) ? mcEmptyElement : data_Get(n-1);
00694 }
00695
00700 const mcElement &data_GetElemAtRightOf(const mcElement &p) const {
00701 int n = data_GetIndexOf(p);
00702 return (n == -1 || n >= mdata_nElements-1) ? mcEmptyElement : data_Get(n+1);
00703 }
00704
00706
00707
00708
00709
00710
00714
00716 bool data_isOp(int entry) const;
00717
00720 inline bool data_isEmptyBox(int entry) const {
00721 data_CheckIndex(entry);
00722 return (mdata_pElemArray[entry].data_GetType() == mcET_EMPTYBOX);
00723 }
00724
00727 inline bool data_isEmptyEntry(int entry) const {
00728 data_CheckIndex(entry);
00729 return (data_Get(entry) == mcEmptyElement);
00730 }
00731
00733 inline bool data_isAddSubOp(int entry) const {
00734 data_CheckIndex(entry);
00735 return (data_Get(entry).data_GetType() == mcET_ADDOP ||
00736 data_Get(entry).data_GetType() == mcET_SUBOP);
00737 }
00738
00740 inline bool data_isMultDivOp(int entry) const {
00741 data_CheckIndex(entry);
00742 return (data_Get(entry).data_GetType() == mcET_MULTOP ||
00743 data_Get(entry).data_GetType() == mcET_DIVOP);
00744 }
00745
00747 inline bool data_isArrayEmpty() const {
00748 return (mdata_nElements == 0);
00749 }
00750
00755 static inline bool data_isValidElem(const mcElement &p) {
00756 return p != mcEmptyElement;
00757 }
00758
00760 inline bool data_isValidElem(int entry) const {
00761 data_CheckIndex(entry);
00762 return data_isValidElem(mdata_pElemArray[entry]);
00763 }
00765
00766
00767
00768
00772
00776 void data_Set(int i, const mcElement &value);
00777
00784 inline void data_SetAsEmptyEntry(int entry) {
00785 data_CheckIndex(entry);
00786 mdata_pElemArray[entry] = mcEmptyElement;
00787 }
00788
00790
00791
00795
00798 void data_SetFilter(const mcFilter *p);
00799
00802 mcFilter *data_GetFilter() { return mdata_pFilter; }
00803
00805 const mcFilter *data_GetFilter() const { return mdata_pFilter; }
00806
00808 bool data_isUsingFilter() const { return (mdata_pFilter != NULL); }
00809
00811
00812 #endif // mcENABLE_DATA
00813
00814
00815
00816
00817
00818 #ifdef mcENABLE_GUI
00819 public:
00820
00824
00836 virtual int gui_AddNewElement(mcElementType type, const mcKey &key, int pos = -1);
00837
00841 void gui_AddNewEmptyBox(int pos = -1);
00842
00846 void gui_AddNewOp(mcElementType nOpType, int pos = -1);
00847
00849 void gui_SetCursorOnElemBegin(int n) {
00850 mgui_nCursorPos = n;
00851 data_Get(n).gui_SetCursorPos(mcCP_BEGIN);
00852 gui_CheckCursorPos();
00853 }
00854
00856 void gui_SetCursorOnElemEnd(int n) {
00857 mgui_nCursorPos = n;
00858 data_Get(n).gui_SetCursorPos(mcCP_END);
00859 gui_CheckCursorPos();
00860 }
00861
00865 bool gui_isCursorOn(const mcElement &p) const {
00866 int idx = data_GetIndexOf(p);
00867 if (idx != -1)
00868 return (idx == mgui_nCursorPos);
00869 return FALSE;
00870 }
00871
00873 int gui_GetSelElemCount() const {
00874 return gui_GetSelEnd()-gui_GetSelStart();
00875 }
00876
00879 int gui_GetSelElemCountOfType(mcElementType t) const {
00880 int count = 0;
00881
00882 for (int i=gui_GetSelStart(), max=gui_GetSelEnd(); i < max; i++)
00883 if (data_Get(i).data_GetType() == t)
00884 count++;
00885
00886 return count;
00887 }
00888
00895 int gui_GetSelElemIndex(int n) const {
00896 int m = -1;
00897
00898
00899
00900 for (int i=0; i < data_GetCount(); i++) {
00901 if (data_Get(i).gui_isSelected()) {
00902 m++;
00903
00904 if (m == n) return i;
00905 }
00906 }
00907
00908
00909 return -1;
00910 }
00911
00919 int gui_GetSelElemIndexOfType(int n, mcElementType t) const {
00920 int m = -1;
00921
00922 for (int i=0, max=gui_GetSelElemCount(); i < max; i++) {
00923 if (gui_GetSelElem(i).data_GetType() == t) {
00924 m++;
00925
00926 if (n == m) return gui_GetSelElemIndex(i);
00927 }
00928 }
00929
00930
00931 return -1;
00932 }
00933
00939 const mcElement &gui_GetSelElem(int n) const {
00940 int m = gui_GetSelElemIndex(n);
00941
00942 if (m > -1)
00943 return data_Get(m);
00944
00945
00946 return mcEmptyElement;
00947 }
00948
00949 const mcElement &gui_GetSelElemOfType(int n, mcElementType t) const {
00950 int m = gui_GetSelElemIndexOfType(n, t);
00951
00952 if (m > -1)
00953 return data_Get(m);
00954
00955
00956 return mcEmptyElement;
00957 }
00958
00961 int gui_GetSelStart() const {
00962 for (int i=0; i < data_GetCount(); i++)
00963 if (data_Get(i).gui_isSelected())
00964 return i;
00965 return -1;
00966 }
00967
00970 int gui_GetSelEnd() const {
00971 for (int i=data_GetCount()-1; i >= 0; i--)
00972 if (data_Get(i).gui_isSelected())
00973 return i+1;
00974 return -1;
00975 }
00976
00978 void gui_DeleteSelection();
00979
00982 mcElement &gui_ExGetActiveElem(int x, int y, const wxPoint &pt, int cl) {
00983 int n = gui_GetActiveElemIndex(x, y, pt, cl);
00984 if (n != mcDRW_NOACTIVEELEM && n != mcDRW_ONSELECTION)
00985 return data_Get(n).gui_GetActiveElem(x, y, pt);
00986 return mcEmptyElement;
00987 }
00988
00990 void gui_DeleteNextOp();
00991
00993 void gui_DeletePreviousOp();
00994
00997 void gui_MoveCursorRight();
00998 void gui_MoveCursorLeft();
00999
01002 void gui_UpdateExpDepth();
01003
01004 bool gui_Insert(const mcElement &toinsert);
01005
01007
01008
01009
01010
01011
01016
01017 virtual bool gui_isEndKey(const mcKey &ev) const;
01018
01019 virtual void gui_SetCursorPos(const mcCursorPos &code);
01020 virtual mcInputRes gui_Input(const mcKey &ev, mcElement *newelem);
01021 virtual mcMoveCursorRes gui_MoveCursor(mcMoveCursorFlag flag, long modifiers);
01022 virtual mcElement gui_GetSelection() const;
01023 virtual void gui_DoRecalcSize();
01024 virtual void gui_GetCursorPos(mcCursorPos &) const;
01025 virtual mcCursorPos gui_GetCursorPos() const
01026 { return mcElementHelpers::gui_GetCursorPos(); }
01027
01028 virtual int gui_GetYAnchor() const {
01029 return gui_GetCenterLine();
01030 }
01031
01032 void gui_OnSelect(wxDC &dc, wxRect &rc) {
01033
01034 gui_ExOnSelect(dc, rc, -1);
01035 }
01036
01037 int gui_Draw(wxDC &dc, int x, int y, long flags, const wxPoint &pt) const {
01038
01039 return gui_ExDraw(dc, x, y, flags, pt, -1);
01040 }
01041
01042 int gui_GetRelCursorPos(wxDC &dc, wxPoint *pt) const {
01043
01044 return gui_ExGetRelCursorPos(dc, pt, -1);
01045 }
01046
01047 int gui_MoveCursorUsingPoint(wxDC &dc, const wxPoint &pt) {
01048
01049 return gui_ExMoveCursorUsingPoint(dc, pt, -1);
01050 }
01051
01052 mcElement &gui_GetActiveElem(int x, int y, const wxPoint &pt) {
01053
01054 return gui_ExGetActiveElem(x, y, pt, -1);
01055 }
01056
01058
01059
01060
01061
01066
01069 virtual mcInputRes gui_BackInput(const mcKey &key, mcElement *pnewelem, int n) = 0;
01070
01074 virtual bool gui_isArrEndKey(const mcKey &ev) const = 0;
01075
01081 virtual void gui_CheckCursorPos() const = 0;
01082
01085 virtual void gui_DoSplit(mcElementType type, const mcKey &ev) = 0;
01086
01087
01092
01094
01095
01096
01097
01102
01106 virtual int gui_GetSpaceBetween() const;
01107
01111 virtual int gui_GetCenterLine() const;
01112
01125 virtual int gui_ExDraw(wxDC &dc, int x, int y, long flags, const wxPoint &pt, int cl = -1,
01126 int begin = 0, int end = -1, bool bgui_DrawSelected = FALSE) const;
01127
01141 virtual int gui_DrawSelectedElements(wxDC &dc, int x, int y, long flags,
01142 const wxPoint &pt, int cl = -1) const;
01143
01160 virtual int gui_DrawSelection(wxDC &hDC, int x, int y, long flags, const wxPoint &pt, int cl = -1) const;
01161
01171 virtual void gui_ExOnSelect(wxDC &dc, wxRect &rc, int cl = -1);
01172
01178 virtual wxSize gui_CalcSizeOfFirst(int n, int cl = -1) const;
01179
01187 virtual wxSize gui_CalcSizeOfRange(int begin, int end, int cl = -1) const;
01188
01195 virtual wxRect gui_GetSelectionRect(wxDC &dc, int x, int y, int cl = -1) const;
01196
01200 virtual wxPoint gui_GetOriginOfElem(int n, int cl = -1) const;
01201
01215 virtual int gui_GetBB(int n, wxRect *rc, int yCenter = 0, int w = 0) const;
01216
01222 virtual int gui_ExGetRelCursorPos(wxDC &hDC, wxPoint *pt, int cl = -1) const;
01223
01231 virtual int gui_ExMoveCursorUsingPoint(wxDC &hDC, const wxPoint &pt, int cl = -1);
01232
01241 virtual int gui_GetActiveElemIndex(int x, int y, const wxPoint &pt, int cl = -1);
01242
01244 #endif // mcENABLE_GUI
01245
01246
01247
01248
01249 #ifdef mcENABLE_MATH
01250
01273
01274
01275 protected:
01276
01285 virtual mcExpSimRes math_HandleExpSimFlag(mcExpSimRes r, mcElement *newelem, int i);
01286
01292 virtual void math_HandleBasicOpRes(mcBasicOpRes res, mcElement r, int ridx);
01293
01300 virtual int math_ReorderElements(mcElement *arr, int sz, int start = 0, int toskip = 1);
01301
01302
01304 virtual mcExpSimRes math_ExpandAll(long flags, mcElement *pp);
01305
01306
01308 virtual mcExpSimRes math_SimplifyAll(long flags, mcElement *pp);
01309
01311 virtual mcExpSimRes math_SimplifyExp(long flags, mcElement *pp);
01312
01315 virtual mcExpSimRes math_SimplifyRemoveNeutrals(long flags);
01316
01318 virtual mcExpSimRes math_SimplifySolveOp(long flags);
01319
01323 virtual mcExpSimRes math_Reorder() = 0;
01324
01327 virtual bool math_SimplifyNeedExp(long flags, int n) const;
01328
01329 virtual mcExpSimRes math_BeginSimSteps() { return mcESR_DONE; }
01330 virtual mcExpSimRes math_FinalSimSteps() { return mcESR_DONE; }
01331
01334 virtual void math_EndSimSteps() {}
01335
01337 virtual void math_EndExpSteps() {}
01338
01339 public:
01340
01344
01345 mcExpSimRes math_Simplify(long flags, mcElement *newelem);
01346 mcExpSimRes math_Expand(long flags, mcElement *newelem);
01347
01352 mcExpSimRes math_Simplify(long flags) { return math_Simplify(flags, NULL); }
01353 mcExpSimRes math_Expand(long flags) { return math_Expand(flags, NULL); }
01354
01355 mcMathType math_GetMathType() const;
01356
01357 bool math_CanBeAddedWith(const mcElement &p) const;
01358 bool math_CanBeDivBy(const mcElement &p) const;
01359 bool math_CanBeMultWith(const mcElement &p) const;
01360
01361
01362 mcBasicOpRes math_MakeReciprocal(mcElement *);
01363
01364 virtual mcRealValue math_Evaluate() const;
01365
01369 virtual mcRealValue math_GetLenght() const { return 0.5; }
01370
01372
01373
01374
01375
01379
01382 const mcElement &math_Get(int n) const
01383 { return data_Get(math_MathToDataIdx(n)); }
01384 mcElement &math_Get(int n)
01385 { return data_Get(math_MathToDataIdx(n)); }
01386
01387 virtual int math_GetCount() const
01388 { return data_GetCount() - data_GetOpCount(); }
01389
01396 int math_GetIndexOf(int occ, const mcElement &tofind) const;
01397
01398 mcElementType math_GetOpTypeBetween(int n1, int n2) const
01399 { return data_GetOpTypeBetween(math_MathToDataIdx(n1), math_MathToDataIdx(n2)); }
01400
01401 mcElementType math_GetOpTypePreceding(int n) const
01402 { return data_GetOpTypePreceding(math_MathToDataIdx(n)); }
01403
01404 mcOperator &math_GetOpBetween(int n1, int n2) const;
01405 mcOperator &math_GetOpPreceding(int n) const;
01406
01408
01409
01410
01414
01426 bool math_Remove(int n, bool bAddZero = TRUE);
01427
01428 bool math_RemoveFactor(const mcArrayEntry &toremove);
01429
01441 virtual bool math_Delete(int n, const mcElement &elem, bool bAddZero = TRUE);
01442
01447
01448
01451 void math_ApplyOp(mcElementType optype, mcElement res, const mcElement &factor, mcElement *);
01452
01455 void math_ApplyOpSimple(mcElementType optype, mcElement res, const mcElement &factor);
01456
01457 virtual bool math_CompareThisOnly(const mcElement &p, long flags) const;
01458 virtual bool math_Compare(const mcElement &p, long flags) const;
01459
01461 virtual bool math_isWrappingOnly(mcElementType t) const;
01462
01466 virtual const mcElement &math_GetWrapped(mcElementType t) const;
01467
01468 virtual mcArrayEntry math_WrapMonomial(const mcMonomial &) = 0;
01469 virtual mcArrayEntry math_WrapSimple(const mcElement &) = 0;
01470
01471 virtual mcArrayEntry math_WrapSymbol(const mcSymbolProperties *sym);
01472 virtual mcArrayEntry math_WrapNumber(const mcRealValue &val);
01473
01475 bool math_isWrappingNumOnly() const { return math_isWrappingOnly(mcET_NUMBER); }
01476
01478 bool math_isWrappingSymOnly() const { return math_isWrappingOnly(mcET_SYMBOL); }
01479
01482 mcRealValue math_GetWrappedNumber() const;
01483
01486 const mcSymbolProperties *math_GetWrappedSymbol() const;
01487
01488 bool math_isWrappingOnly(const mcSymbolProperties *sym) const
01489 { return math_GetWrappedSymbol() == sym; }
01490 bool math_isWrappingOnly(const mcRealValue &val) const
01491 { return math_GetWrappedNumber() == val; }
01492
01493 virtual void math_ResetToOne();
01494 virtual void math_ResetToZero();
01495
01496 virtual void math_SimpleAdd(const mcElement &p, bool add = TRUE);
01497 virtual void math_SimpleMultiplyBy(const mcElement &p);
01498 virtual void math_SimpleDivideBy(const mcElement &p);
01499
01500 mcArrayEntry math_EmbedInFraction(bool bAsDenominator = FALSE);
01501 mcArrayEntry math_EmbedInBracket();
01502 mcArrayEntry math_EmbedInRadical();
01503
01505
01506
01507
01511
01514 virtual int math_DataToMathIdx(int dataindex) const = 0;
01515
01518 virtual int math_MathToDataIdx(int mathindex) const = 0;
01519
01520 virtual void math_PrepareForComparison(mcElementArray &p) const;
01521 virtual void math_PrepareForMathOperations(mcElementArray &p) const;
01522
01523 virtual mcElementType math_GetNeutralOpType() const = 0;
01524 virtual double math_GetNeutralValue() const = 0;
01525
01529 virtual mcPolynomial math_GetPolynomialWrapper() const = 0;
01530
01532 virtual mcElementArray math_CreateWrapperFor(const mcElement &p) const;
01533
01534 virtual mcMonomial math_GetFactors() const;
01535
01541
01542
01543
01544
01545
01546 void math_EmbedInBracketAndRaiseTo(const mcRealValue &n);
01547 void math_EmbedInBracketAndRaiseTo(const mcPolynomial &p);
01548 void math_EmbedInRadicalAndRaiseTo(const mcPolynomial &p);
01549
01551
01552 #endif // mcENABLE_MATH
01553
01554
01555
01556 #ifdef mcENABLE_IO
01557 public:
01558
01561 bool io_isBeginTag(const wxXml2Node &tag) const {
01562 if (tag.GetName() == wxT("mrow"))
01563 return TRUE;
01564 return FALSE;
01565 }
01566
01571 bool io_isBeginChar(const wxString &str) const {
01572 return FALSE;
01573 }
01574
01575 wxString io_GetInlinedExpr() const;
01576
01577 #endif // mcENABLE_IO
01578 };
01579
01580
01581
01582
01583
01587 class mcElementArray : public mcElement
01588 {
01589 mcDEFINE_ABSTRACT_CLASS(ElementArray, mcElement);
01590
01591 public:
01592
01593 bool data_isValidContainerFor(mcElementType t) const
01594 { return t == mcET_MONOMIAL || t == mcET_POLYNOMIAL; }
01595
01596
01597 #ifdef mcENABLE_DATA
01598 public:
01599
01600 mcWRAPPER void data_CheckIndex(int entry) const
01601 { hlp()->data_CheckIndex(entry); }
01602 mcWRAPPER void data_CheckArrayLimit()
01603 { hlp()->data_CheckArrayLimit(); }
01604 mcWRAPPER void data_ChangeFilter(const mcFilter *p)
01605 { hlp()->data_ChangeFilter(p); }
01606
01607 mcWRAPPER void data_UpdateFilterFor(mcElement &p, const mcFilter *f)
01608 { hlp()->data_UpdateFilterFor(p, f); }
01609
01610 mcWRAPPER bool data_isElementAllowed(mcElementType type) const
01611 { return hlp()->data_isElementAllowed(type); }
01612
01613 mcWRAPPER int data_AddElements(const mcElement *p, int num, int pos = -1,
01614 bool bOverwrite = FALSE, bool bForceCopy = FALSE)
01615 { return hlp()->data_AddElements(p, num, pos, bOverwrite, bForceCopy); }
01616
01617 mcWRAPPER mcElement &data_AddNewElement(mcElementType t, bool bOverwrite = FALSE, int pos = -1)
01618 { return hlp()->data_AddNewElement(t, bOverwrite, pos); }
01619
01620 mcWRAPPER mcElement &data_AddNewWrappedElement(mcElementType t,
01621 bool bOverwrite = FALSE, int pos = -1)
01622 { return hlp()->data_AddNewWrappedElement(t, bOverwrite, pos); }
01623
01624 mcWRAPPER void data_Merge(const mcElementArray &p, int n, bool bmath_AddToEnd = TRUE)
01625 { hlp()->data_Merge(p, n, bmath_AddToEnd); }
01626
01627 mcWRAPPER void data_AddNewOp(mcElementType type, int pos = -1)
01628 { hlp()->data_AddNewOp(type, pos); }
01629
01630 mcWRAPPER void data_AddNewEmptyBox(int pos = -1)
01631 { hlp()->data_AddNewEmptyBox(pos); }
01632
01633
01634 mcWRAPPER bool data_Delete(const mcElement &elem)
01635 { return hlp()->data_Delete(elem); }
01636 mcWRAPPER void data_Delete(int entry)
01637 { hlp()->data_Delete(entry); }
01638 mcWRAPPER void data_DeleteLast(int num)
01639 { hlp()->data_DeleteLast(num); }
01640 mcWRAPPER void data_DeleteFirst(int num)
01641 { hlp()->data_DeleteFirst(num); }
01642 mcWRAPPER void data_DeleteAllElemType(mcElementType t)
01643 { hlp()->data_DeleteAllElemType(t); }
01644 mcWRAPPER void data_DeleteAll()
01645 { hlp()->data_DeleteAll(); }
01646
01647 mcWRAPPER mcElement data_Detach(int n)
01648 { return hlp()->data_Detach(n); }
01649 mcWRAPPER mcElement data_DetachLastElem(int num)
01650 { return hlp()->data_DetachLastElem(num); }
01651 mcWRAPPER mcElement data_DetachAll()
01652 { return hlp()->data_DetachAll(); }
01653
01654 mcWRAPPER void data_MoveElemRight(int start)
01655 { hlp()->data_MoveElemRight(start); }
01656 mcWRAPPER void data_MoveElemLeft(int start)
01657 { hlp()->data_MoveElemLeft(start); }
01658 mcWRAPPER void data_Move(int n, int k)
01659 { hlp()->data_Move(n, k); }
01660 mcWRAPPER int data_MoveAllElemType(mcElementType t, mcElementArray &m)
01661 { return hlp()->data_MoveAllElemType(t, m); }
01662
01663 mcWRAPPER void data_Swap(int index1, int index2)
01664 { hlp()->data_Swap(index1, index2); }
01665
01666 mcWRAPPER int data_QueueElemType(mcElementType t, int firstpos)
01667 { return hlp()->data_QueueElemType(t, firstpos); }
01668
01669 mcWRAPPER void data_Repair()
01670 { hlp()->data_Repair(); }
01671
01672
01673
01674 mcWRAPPER bool data_isWrappingOnly(mcElementType t) const
01675 { return hlp()->data_isWrappingOnly(t); }
01676
01677 mcWRAPPER const mcElement &data_GetWrapped(mcElementType t) const
01678 { return hlp()->data_GetWrapped(t); }
01679
01680
01681 mcWRAPPER const mcElement &data_Get(int entry) const
01682 { return hlp()->data_Get(entry); }
01683 mcWRAPPER mcElement &data_Get(int entry)
01684 { return hlp()->data_Get(entry); }
01685
01686
01687 mcWRAPPER int data_GetIndexOf(const mcElement &p) const
01688 { return hlp()->data_GetIndexOf(p); }
01689
01690 mcWRAPPER const mcElement &data_GetLast() const
01691 { return hlp()->data_GetLast(); }
01692 mcWRAPPER mcElement &data_GetLast()
01693 { return hlp()->data_GetLast(); }
01694
01695
01696 mcWRAPPER mcElement *data_GetArray(int n = 0) const
01697 { return hlp()->data_GetArray(n); }
01698
01699 mcWRAPPER int data_GetIndex(int id) const
01700 { return hlp()->data_GetIndex(id); }
01701
01702 mcWRAPPER int data_GetCount() const
01703 { return hlp()->data_GetCount(); }
01704
01705 mcWRAPPER int data_GetAvailableEntryCount() const
01706 { return hlp()->data_GetAvailableEntryCount(); }
01707
01708 mcWRAPPER int data_GetNumOfElemType(mcElementType t) const
01709 { return hlp()->data_GetNumOfElemType(t); }
01710
01711 mcWRAPPER int data_GetOpCount() const
01712 { return hlp()->data_GetOpCount(); }
01713
01714 mcWRAPPER mcElement &data_GetElemOfType(int n, mcElementType t) const
01715 { return hlp()->data_GetElemOfType(n, t); }
01716
01717 mcWRAPPER int data_GetElemIndexOfType(int n, mcElementType t) const
01718 { return hlp()->data_GetElemIndexOfType(n, t); }
01719
01720 mcWRAPPER mcElement &data_GetNonOpElem(int n) const
01721 { return hlp()->data_GetNonOpElem(n); }
01722
01723 mcWRAPPER int data_GetNonOpElemIndex(int n) const
01724 { return hlp()->data_GetNonOpElemIndex(n); }
01725
01726 mcWRAPPER mcOperator &data_GetOp(int n) const
01727 { return hlp()->data_GetOp(n); }
01728
01729 mcWRAPPER int data_GetOpIndex(int n) const
01730 { return hlp()->data_GetOpIndex(n); }
01731
01732 mcWRAPPER mcElementType data_GetOpTypeBetween(int n1, int n2) const
01733 { return hlp()->data_GetOpTypeBetween(n1, n2); }
01734
01735 mcWRAPPER mcElementType data_GetOpTypePreceding(int n) const
01736 { return hlp()->data_GetOpTypePreceding(n); }
01737
01738 mcWRAPPER const mcElement &data_GetElemAtLeftOf(const mcElement &p) const
01739 { return hlp()->data_GetElemAtLeftOf(p); }
01740
01741 mcWRAPPER const mcElement &data_GetElemAtRightOf(const mcElement &p) const
01742 { return hlp()->data_GetElemAtRightOf(p); }
01743
01744 mcWRAPPER bool data_isOp(int entry) const
01745 { return hlp()->data_isOp(entry); }
01746 mcWRAPPER bool data_isEmptyBox(int entry) const
01747 { return hlp()->data_isEmptyBox(entry); }
01748 mcWRAPPER bool data_isEmptyEntry(int entry) const
01749 { return hlp()->data_isEmptyEntry(entry); }
01750 mcWRAPPER bool data_isAddSubOp(int entry) const
01751 { return hlp()->data_isAddSubOp(entry); }
01752 mcWRAPPER bool data_isMultDivOp(int entry) const
01753 { return hlp()->data_isMultDivOp(entry); }
01754
01755 mcWRAPPER bool data_isArrayEmpty() const
01756 { return hlp()->data_isArrayEmpty(); }
01757 mcWRAPPER bool data_isValidElem(int entry) const
01758 { return hlp()->data_isValidElem(entry); }
01759
01760 mcWRAPPER void data_Set(int i, const mcElement &value)
01761 { hlp()->data_Set(i, value); }
01762
01763 mcWRAPPER void data_SetAsEmptyEntry(int entry)
01764 { hlp()->data_SetAsEmptyEntry(entry); }
01765
01766 mcWRAPPER void data_SetFilter(const mcFilter *p)
01767 { hlp()->data_SetFilter(p); }
01768
01769 mcWRAPPER mcFilter *data_GetFilter()
01770 { return hlp()->data_GetFilter(); }
01771
01772 mcWRAPPER const mcFilter *data_GetFilter() const
01773 { return hlp()->data_GetFilter(); }
01774
01775 mcWRAPPER bool data_isUsingFilter() const
01776 { return hlp()->data_isUsingFilter(); }
01777
01778 #endif // mcENABLE_DATA
01779
01780
01781
01782
01783 #ifdef mcENABLE_GUI
01784 public:
01785
01786 mcWRAPPER int gui_AddNewElement(mcElementType type, const mcKey &key, int pos = -1)
01787 { return hlp()->gui_AddNewElement(type, key, pos); }
01788 mcWRAPPER void gui_AddNewEmptyBox(int pos = -1)
01789 { hlp()->gui_AddNewEmptyBox(pos); }
01790 mcWRAPPER void gui_AddNewOp(mcElementType nOpType, int pos = -1)
01791 { hlp()->gui_AddNewOp(nOpType, pos); }
01792
01793 mcWRAPPER void gui_SetCursorOnElemBegin(int n)
01794 { hlp()->gui_SetCursorOnElemBegin(n); }
01795 mcWRAPPER void gui_SetCursorOnElemEnd(int n)
01796 { hlp()->gui_SetCursorOnElemEnd(n); }
01797
01798 mcWRAPPER bool gui_isCursorOn(const mcElement &p) const
01799 { return hlp()->gui_isCursorOn(p); }
01800
01801 mcWRAPPER int gui_GetSelElemCount() const
01802 { return hlp()->gui_GetSelElemCount(); }
01803 mcWRAPPER int gui_GetSelElemCountOfType(mcElementType t) const
01804 { return hlp()->gui_GetSelElemCountOfType(t); }
01805 mcWRAPPER int gui_GetSelElemIndex(int n) const
01806 { return hlp()->gui_GetSelElemIndex(n); }
01807 mcWRAPPER int gui_GetSelElemIndexOfType(int n, mcElementType t) const
01808 { return hlp()->gui_GetSelElemIndexOfType(n, t); }
01809
01810 mcWRAPPER const mcElement &gui_GetSelElem(int n) const
01811 { return hlp()->gui_GetSelElem(n); }
01812 mcWRAPPER const mcElement &gui_GetSelElemOfType(int n, mcElementType t) const
01813 { return hlp()->gui_GetSelElemOfType(n, t); }
01814
01815 mcWRAPPER int gui_GetSelStart() const
01816 { return hlp()->gui_GetSelStart(); }
01817 mcWRAPPER int gui_GetSelEnd() const
01818 { return hlp()->gui_GetSelEnd(); }
01819
01820 mcWRAPPER void gui_DeleteSelection()
01821 { hlp()->gui_DeleteSelection(); }
01822
01823 mcWRAPPER mcElement &gui_ExGetActiveElem(int x, int y, const wxPoint &pt, int cl)
01824 { return hlp()->gui_ExGetActiveElem(x, y, pt, cl); }
01825
01826 mcWRAPPER void gui_DeleteNextOp()
01827 { hlp()->gui_DeleteNextOp(); }
01828 mcWRAPPER void gui_DeletePreviousOp()
01829 { hlp()->gui_DeletePreviousOp(); }
01830
01831 mcWRAPPER void gui_MoveCursorRight()
01832 { hlp()->gui_MoveCursorRight(); }
01833 mcWRAPPER void gui_MoveCursorLeft()
01834 { hlp()->gui_MoveCursorLeft(); }
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847 mcWRAPPER int gui_GetCenterLine() const
01848 { return hlp()->gui_GetCenterLine(); }
01849
01850 mcWRAPPER int gui_ExDraw(wxDC &dc, int x, int y, long flags, const wxPoint &pt, int cl = -1,
01851 int begin = 0, int end = -1, bool bDrawSelected = FALSE) const
01852 { return hlp()->gui_ExDraw(dc, x, y, flags, pt, cl, begin, end, bDrawSelected); }
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871 mcWRAPPER int gui_ExGetRelCursorPos(wxDC &dc, wxPoint *pt, int cl = -1) const
01872 { return hlp()->gui_ExGetRelCursorPos(dc, pt, cl); }
01873
01874
01875
01876
01877
01878 #endif // mcENABLE_GUI
01879
01880
01881 #ifdef mcENABLE_MATH
01882 public:
01883
01884 mcWRAPPER mcExpSimRes math_Simplify(long flags)
01885 { return hlp()->math_Simplify(flags); }
01886 mcWRAPPER mcExpSimRes math_Expand(long flags)
01887 { return hlp()->math_Expand(flags); }
01888 mcWRAPPER mcExpSimRes math_Simplify(long flags, mcElement *p)
01889 { return hlp()->math_Simplify(flags, p); }
01890 mcWRAPPER mcExpSimRes math_Expand(long flags, mcElement *p)
01891 { return hlp()->math_Expand(flags, p); }
01892
01893 mcWRAPPER const mcElement &math_Get(int n) const
01894 { return hlp()->math_Get(n); }
01895 mcWRAPPER mcElement &math_Get(int n)
01896 { return hlp()->math_Get(n); }
01897 mcWRAPPER int math_GetCount() const
01898 { return hlp()->math_GetCount(); }
01899
01900 mcWRAPPER int math_GetIndexOf(int occ, const mcElement &tofind) const
01901 { return hlp()->math_GetIndexOf(occ, tofind); }
01902
01903 mcWRAPPER mcElementType math_GetOpTypeBetween(int n1, int n2) const
01904 { return hlp()->math_GetOpTypeBetween(n1, n2); }
01905 mcWRAPPER mcElementType math_GetOpTypePreceding(int n) const
01906 { return hlp()->math_GetOpTypePreceding(n); }
01907 mcWRAPPER mcOperator &math_GetOpBetween(int n1, int n2) const
01908 { return hlp()->math_GetOpBetween(n1, n2); }
01909 mcWRAPPER mcOperator &math_GetOpPreceding(int n) const
01910 { return hlp()->math_GetOpPreceding(n); }
01911
01912 mcWRAPPER bool math_Remove(int n, bool bAddZero = TRUE)
01913 { return hlp()->math_Remove(n, bAddZero); }
01914 mcWRAPPER bool math_Delete(int n, const mcElement &elem, bool bAddZero = TRUE)
01915 { return hlp()->math_Delete(n, elem, bAddZero); }
01916 mcWRAPPER void math_ApplyOp(mcElementType optype, mcElement res, const mcElement &factor, mcElement *pp)
01917 { hlp()->math_ApplyOp(optype, res, factor, pp); }
01918 mcWRAPPER void math_ApplyOpSimple(mcElementType optype, mcElement res, const mcElement &factor)
01919 { hlp()->math_ApplyOpSimple(optype, res, factor); }
01920
01921 mcWRAPPER bool math_isWrappingOnly(mcElementType t) const
01922 { return hlp()->math_isWrappingOnly(t); }
01923
01924 mcWRAPPER const mcElement &math_GetWrapped(mcElementType t) const
01925 { return hlp()->math_GetWrapped(t); }
01926 mcWRAPPER mcArrayEntry math_WrapMonomial(const mcMonomial &m)
01927 { return hlp()->math_WrapMonomial(m); }
01928 mcWRAPPER mcArrayEntry math_WrapSimple(const mcElement &e)
01929 { return hlp()->math_WrapSimple(e); }
01930 mcWRAPPER mcArrayEntry math_WrapSymbol(const mcSymbolProperties *sym)
01931 { return hlp()->math_WrapSymbol(sym); }
01932 mcWRAPPER mcArrayEntry math_WrapNumber(const mcRealValue &val)
01933 { return hlp()->math_WrapNumber(val); }
01934
01935 mcWRAPPER bool math_isWrappingNumOnly() const
01936 { return hlp()->math_isWrappingNumOnly(); }
01937 mcWRAPPER bool math_isWrappingSymOnly() const
01938 { return hlp()->math_isWrappingSymOnly(); }
01939
01940 mcWRAPPER mcRealValue math_GetWrappedNumber() const
01941 { return hlp()->math_GetWrappedNumber(); }
01942
01943 mcWRAPPER const mcSymbolProperties *math_GetWrappedSymbol() const
01944 { return hlp()->math_GetWrappedSymbol(); }
01945 mcWRAPPER bool math_isWrappingOnly(const mcSymbolProperties *sym) const
01946 { return hlp()->math_isWrappingOnly(sym); }
01947 mcWRAPPER bool math_isWrappingOnly(const mcRealValue &val) const
01948 { return hlp()->math_isWrappingOnly(val); }
01949
01950 mcWRAPPER void math_ResetToOne()
01951 { hlp()->math_ResetToOne(); }
01952 mcWRAPPER void math_ResetToZero()
01953 { hlp()->math_ResetToZero(); }
01954
01955 mcWRAPPER mcArrayEntry math_EmbedInFraction(bool bAsDenominator = FALSE)
01956 { return hlp()->math_EmbedInFraction(bAsDenominator); }
01957 mcWRAPPER mcArrayEntry math_EmbedInBracket()
01958 { return hlp()->math_EmbedInBracket(); }
01959 mcWRAPPER mcArrayEntry math_EmbedInRadical()
01960 { return hlp()->math_EmbedInRadical(); }
01961
01962 mcWRAPPER int math_DataToMathIdx(int dataindex) const
01963 { return hlp()->math_DataToMathIdx(dataindex); }
01964 mcWRAPPER int math_MathToDataIdx(int mathindex) const
01965 { return hlp()->math_MathToDataIdx(mathindex); }
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981 mcWRAPPER void math_EmbedInBracketAndRaiseTo(const mcRealValue &n)
01982 { hlp()->math_EmbedInBracketAndRaiseTo(n); }
01983 mcWRAPPER void math_EmbedInBracketAndRaiseTo(const mcPolynomial &p)
01984 { hlp()->math_EmbedInBracketAndRaiseTo(p); }
01985
01986 #endif // mcENABLE_MATH
01987 };
01988
01989
01990 #endif // ELEMENTARRAY_H
01991