void CUnitPane::SaveUnitListHdr() { CListLayoutItem * pLI; int i; CStr Key; CStr Val; if (m_pLayout) { // we are naming items dynamically, so remove them first! gpApp->RemoveSection(m_sConfigSectionHdr.GetData()); for (i=0; i<m_pLayout->Count(); i++) { pLI = (CListLayoutItem*)m_pLayout->At(i); Key.Format("%03d", i); Val.Format("%d, %lu, %s, %s", GetColumnWidth(i), pLI->m_Flags, pLI->m_Name, pLI->m_Caption); gpApp->SetConfig(m_sConfigSectionHdr.GetData(), Key.GetData(), Val.GetData()); } gpApp->SetConfig(m_sConfigSection.GetData(), SZ_KEY_SORT1, GetSortName(0 ) ); gpApp->SetConfig(m_sConfigSection.GetData(), SZ_KEY_SORT2, GetSortName(1 ) ); gpApp->SetConfig(m_sConfigSection.GetData(), SZ_KEY_SORT3, GetSortName(2 ) ); } }
bool COrgOp::Decode_GetNextToken( CStr &roDst, CStr &roSrc ) const { int j = roSrc.Find( 0, ORG_OP_DELIM ); if( j < 0 ) return false; roDst = roSrc.GetSub( 0, j ); roSrc.Del( 0, j+1 ); // ORG_OP_DELIM auch löschen ORG_OP_LOG( "token: %s\n", roDst.GetData() ); return true; }
void ShowMessageBoxSwitchable(const wxString &szTitle, const wxString &szMessage, const wxString &szConfigKey) { CStr S; S = gpApp->GetConfig(SZ_SECT_DO_NOT_SHOW_THESE, szConfigKey.ToUTF8()); if (atol(S.GetData()) > 0) return; CMessageBoxSwitchableDlg dlg(NULL, szTitle.ToUTF8(), szMessage.ToUTF8()); dlg.ShowModal(); if (dlg.m_chbSwitchOff->IsChecked()) gpApp->SetConfig(SZ_SECT_DO_NOT_SHOW_THESE, szConfigKey.ToUTF8(), "1"); }
CShowOneDescriptionDlg::CShowOneDescriptionDlg(wxWindow * parent, const char * title, const char * description) :CResizableDlg( parent, wxString::FromUTF8(title), SZ_SECT_WND_DESCR_ONE) { wxBoxSizer * topsizer = new wxBoxSizer( wxVERTICAL ); wxButton * pBtnDone = new wxButton (this, wxID_CANCEL, wxT("Done") ); wxButton * pBtnSave = new wxButton (this, wxID_OK , wxT("Save as") ); //wxTextCtrl * pText = new wxTextCtrl(this, -1, description, wxDefaultPosition, wxDefaultSize, // wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL ); wxTextCtrl * pText = new wxTextCtrl(this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL ); const char * p; int count = 0; CStr S; topsizer->Add( pText , 1, // make vertically stretchable wxEXPAND );//| wxALL, // make horizontally stretchable // and make border all around wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); button_sizer->Add( pBtnSave, 0, wxALL, 10 ); button_sizer->Add( pBtnDone, 0, wxALL, 10 ); topsizer->Add( button_sizer, 0, wxALIGN_CENTER ); SetAutoLayout( TRUE ); // tell dialog to use sizer SetSizer( topsizer ); // actually set the sizer topsizer->Fit( this ); // set size to minimum size as calculated by the sizer topsizer->SetSizeHints( this ); // set size hints to honour mininum size} pText->SetFocus(); pBtnDone ->SetDefault(); CResizableDlg::SetSize(); pText->SetValue(wxString::FromAscii(description)); pText->SetFont(*gpApp->m_Fonts[FONT_VIEW_DLG]); m_descr = description; p = description; while (p && *p && count++ < 3) { p = S.GetToken(p, '(', TRIM_ALL); p = S.GetToken(p, ')', TRIM_ALL); if (gpApp->SelectLand(S.GetData())) break; } }
void CCurveBezier3::Load( const CStr &roData ) { const char * pcD = roData.GetData(); unsigned int i = 0; unsigned int uiVertex = 0, uiToken = 0, uiSub = 0; while( true ) { const int j = roData.Find( i, DELIM ); if( j < 0 ) break; float fVal; sscanf( pcD + i, "%g", &fVal ); switch( uiToken ) { case 0: m_aoVertex[uiVertex].m_oPos[uiSub] = fVal; if( ++uiSub >= 4 ) { uiSub = 0; ++uiToken; } break; case 1: m_aoVertex[uiVertex].m_oColor[uiSub] = fVal; if( ++uiSub >= 4 ) { uiSub = 0; ++uiToken; } break; case 2: m_aoVertex[uiVertex].m_fWeight0 = fVal; if( ++uiSub >= 1 ) { m_aoVertex[uiVertex].m_uiVertex = uiVertex; uiSub = 0; uiToken = 0; ++uiVertex; if( uiVertex >= 4 ) break; } break; } i = j + 1; } }
bool COrgOp::Decode_GetNextLine( CStr &roDst, CStr &roSrc ) const { int j; j = roSrc.Find( 0, ORG_OP_DELIM ); if( j < 0 ) return false; roSrc.Del( 0, ++j ); j = roSrc.Find( 0, ORG_OP_NEWLINE ); if( j < 0 ) return false; roDst = roSrc.GetSub( 0, j ); roSrc.Del( 0, j+sizeof( ORG_OP_NEWLINE ) ); ORG_OP_LOG( "line: %s\n", roDst.GetData() ); return true; }
void CShowDescriptionListDlg::OnLBSelect(wxCommandEvent & event) { CBaseObject * pObj; CStr S; const char * p; pObj = (CBaseObject*)m_pItems->At((long)m_pList->GetClientData(m_pList->GetSelection())); if (pObj) { p = pObj->Name.GetData(); while (p && *p) { p = S.GetToken(p, '(', TRIM_ALL); p = S.GetToken(p, ')', TRIM_ALL); if (gpApp->SelectLand(S.GetData())) break; } } }
CComboboxDlg::CComboboxDlg(wxWindow *parent, const char * szTitle, const char * szMessage, const char * szChoices) :wxDialog(parent, -1, wxString::FromAscii(szTitle), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { wxBoxSizer * topsizer; wxBoxSizer * sizer ; CStr S; wxButton * btnOk; wxButton * btnCancel; btnOk = new wxButton (this, wxID_OK , wxT("Ok") ); btnCancel = new wxButton (this, wxID_CANCEL, wxT("Cancel") ); m_cbChoices = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN); topsizer = new wxBoxSizer( wxVERTICAL ); topsizer->Add(new wxStaticText(this, -1, wxString::FromAscii(szMessage)), 0, wxALIGN_LEFT | wxALL, 5); topsizer->Add(m_cbChoices , 0, wxALIGN_CENTER | wxALL | wxGROW, 5); sizer = new wxBoxSizer( wxHORIZONTAL ); sizer->Add(btnOk , 0, wxALIGN_CENTER | wxALL, 5); sizer->Add(btnCancel, 0, wxALIGN_CENTER | wxALL, 5); topsizer->Add(sizer, 0, wxALIGN_CENTER | wxALL, 10); while (szChoices && *szChoices) { szChoices = S.GetToken(szChoices, ','); m_cbChoices->Append(wxString::FromAscii(S.GetData())); } SetAutoLayout( TRUE ); // tell dialog to use sizer SetSizer( topsizer ); // actually set the sizer topsizer->Fit( this ); // set size to minimum size as calculated by the sizer topsizer->SetSizeHints( this ); // set size hints to honour mininum size} m_cbChoices->SetFocus(); btnOk->SetDefault(); Centre( wxBOTH | wxCENTER_FRAME); }
void CUnitPane::OnPopupMenuAddUnitToTracking (wxCommandEvent& WXUNUSED(event)) { long idx = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); CUnit * pUnit = GetUnit(idx); int sectidx; CStr S; const char * szName; const char * szValue; BOOL found = FALSE; BOOL ManyUnits = (GetSelectedItemCount() > 1); sectidx = gpApp->GetSectionFirst(SZ_SECT_UNIT_TRACKING, szName, szValue); while (sectidx >= 0) { if (!S.IsEmpty()) S << ","; S << szName; sectidx = gpApp->GetSectionNext(sectidx, SZ_SECT_UNIT_TRACKING, szName, szValue); } if (S.IsEmpty()) S = "Default"; if (pUnit || ManyUnits) { CComboboxDlg dlg(this, "Add unit to a tracking group", "Select a group to add unit to.\nTo create a new group, just type in it's name.", S.GetData()); if (wxID_OK == dlg.ShowModal()) { idx = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); while (idx>=0) { pUnit = GetUnit(idx); found = FALSE; szValue = gpApp->GetConfig(SZ_SECT_UNIT_TRACKING, dlg.m_Choice.GetData()); while (szValue && *szValue) { szValue = S.GetToken(szValue, ','); if (atol(S.GetData()) == pUnit->Id) { found = TRUE; break; } } if (found) wxMessageBox(wxT("The unit is already in the group.")); else { S = gpApp->GetConfig(SZ_SECT_UNIT_TRACKING, dlg.m_Choice.GetData()); S.TrimRight(TRIM_ALL); if (!S.IsEmpty()) S << ","; S << pUnit->Id; gpApp->SetConfig(SZ_SECT_UNIT_TRACKING, dlg.m_Choice.GetData(), S.GetData()); } idx = GetNextItem(idx, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } } } }
bool CPrsBDF::Parse( const char *pcFont ) { #define TOK(T) TPairTokenNameID( #T, PBDF_TOKEN_##T ) static const TPairTokenNameID m_aoToken_[] = { TOK( STARTFONT ), TOK( COMMENT ), TOK( CONTENTVERSION ), TOK( FONT ), TOK( SIZE ), TOK( FONTBOUNDINGBOX ), TOK( METRICSSET ), TOK( SWIDTH ), TOK( DWIDTH ), TOK( SWIDTH1 ), TOK( DWIDTH1 ), TOK( VVECTOR ), TOK( STARTPROPERTIES ), TOK( ENDPROPERTIES ), TOK( CHARS ), TOK( STARTCHAR ), TOK( ENCODING ), TOK( BBX ), TOK( BITMAP ), TOK( ENDCHAR ), TOK( ENDFONT ) }; static const unsigned int uiTokenNum = sizeof( m_aoToken_ ) / sizeof( TPairTokenNameID ); CStr oStrFontFile( pcFont ); const int iFontSize = oStrFontFile.GetSize(); int iPropertiesStartPos = -1; CGlyph oGylphNew; CGlyph *poGlyph = &m_oGlyphDefault; bool bIsReadingChar = false; Reset(); PBDF_LOG( "parse: start\n" ); int iPos = 0; while( iPos < iFontSize ) { int iEndOfLine = oStrFontFile.Find( iPos, PBDF_NEWLINE ); if( iEndOfLine < 0 ) iEndOfLine = iFontSize; CStr oStrLine = oStrFontFile.GetSub( iPos, iEndOfLine - iPos ); RemoveLeadingSpace( oStrLine ); //PBDF_LOG( "line: %s", oStrLine.GetData() ); //PBDF_LOG( "line_size: %s", oStrLine.GetSize() ); unsigned int uiTokenNext = PBDF_TOKEN_NONE; for( unsigned int t=0; t<uiTokenNum; ++t ) { CStr oStrToken = m_aoToken_[t].GetFirst() ; const unsigned int uiTokenSize = oStrToken.GetSize(); //PBDF_LOG( "token: %s", oStrToken.GetData() ); int iPosToken = oStrLine.Find( 0, oStrToken ); if( iPosToken != 0 ) continue; // Danach müssen Leerzeichen oder das Ende folgen! const unsigned int uiPosNext = iPosToken + uiTokenSize; if( uiPosNext < oStrLine.GetSize() ) { const char cNext = oStrLine[ uiPosNext ]; if( !( cNext == ' ' || cNext == '\t' ) ) continue; } if( iPosToken >= 0 ) { oStrLine.Del( 0, uiTokenSize ); RemoveLeadingSpace( oStrLine ); uiTokenNext = m_aoToken_[t].GetSecond(); PBDF_LOG( "token: %s\n", oStrToken.GetData() ); break; } } if( uiTokenNext != PBDF_TOKEN_NONE ) { switch( uiTokenNext ) { case PBDF_TOKEN_STARTFONT: ReadValue( oStrLine, &m_dVersion ); PBDF_LOG( "version: %g\n", m_dVersion ); break; case PBDF_TOKEN_COMMENT: break; case PBDF_TOKEN_CONTENTVERSION: // optional ReadValue( oStrLine, &m_iContentVersion ); PBDF_LOG( "content_version: %d\n", m_iContentVersion ); break; case PBDF_TOKEN_FONT: ReadValue( oStrLine, &m_oStrFont ); PBDF_LOG( "font: %s\n", m_oStrFont.GetData() ); break; case PBDF_TOKEN_SIZE: ReadValue( oStrLine, &m_iPointSize ); PBDF_LOG( "point_size: %d\n", m_iPointSize ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &m_iResX ); PBDF_LOG( "res_x: %d\n", m_iResX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &m_iResY ); PBDF_LOG( "res_y: %d\n", m_iResY ); break; case PBDF_TOKEN_FONTBOUNDINGBOX: ReadValue( oStrLine, &m_iBBX ); PBDF_LOG( "bounding_box_x: %d\n", m_iBBX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &m_iBBY ); PBDF_LOG( "bounding_box_y: %d\n", m_iBBY ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &m_iOffX ); PBDF_LOG( "offset_y: %d\n", m_iOffX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &m_iOffY ); PBDF_LOG( "offset_x: %d\n", m_iOffY ); RemoveNextWord( oStrLine ); break; case PBDF_TOKEN_METRICSSET: // optional ReadValue( oStrLine, &m_iMetricsSet ); PBDF_LOG( "metrics_set: %d\n", m_iMetricsSet ); break; case PBDF_TOKEN_SWIDTH: ReadValue( oStrLine, &poGlyph->m_dSX ); PBDF_LOG( "sx: %g\n", poGlyph->m_dSX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_dSY ); PBDF_LOG( "sy: %g\n", poGlyph->m_dSY ); break; case PBDF_TOKEN_DWIDTH: ReadValue( oStrLine, &poGlyph->m_iDX ); PBDF_LOG( "dx: %d\n", poGlyph->m_iDX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_iDY ); PBDF_LOG( "dy: %d\n", poGlyph->m_iDY ); break; case PBDF_TOKEN_SWIDTH1: ReadValue( oStrLine, &poGlyph->m_dSX1 ); PBDF_LOG( "sx1: %g\n", poGlyph->m_dSX1 ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_dSY1 ); PBDF_LOG( "sy1: %g\n", poGlyph->m_dSY1 ); break; case PBDF_TOKEN_DWIDTH1: ReadValue( oStrLine, &poGlyph->m_iDX1 ); PBDF_LOG( "dx1: %d\n", poGlyph->m_iDX1 ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_iDY1 ); PBDF_LOG( "dy1: %d\n", poGlyph->m_iDY1 ); break; case PBDF_TOKEN_VVECTOR: // optional ReadValue( oStrLine, &poGlyph->m_dVVX ); PBDF_LOG( "vvx: %g\n", poGlyph->m_dVVX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_dVVY ); PBDF_LOG( "vvy: %g\n", poGlyph->m_dVVY ); break; case PBDF_TOKEN_STARTPROPERTIES: // optional ReadValue( oStrLine, &m_iProperties ); PBDF_LOG( "properties: %d\n", m_iProperties ); iPropertiesStartPos = iEndOfLine + 1; break; case PBDF_TOKEN_ENDPROPERTIES: // optional if( iPropertiesStartPos < 0 ) break; m_oStrProperties = oStrFontFile.GetSub( iPropertiesStartPos, iPos - iPropertiesStartPos ); PBDF_LOG( "properties:\n%s\n", m_oStrProperties.GetData() ); break; case PBDF_TOKEN_CHARS: ReadValue( oStrLine, &m_iChars ); PBDF_LOG( "chars: %d\n", m_iChars ); poGlyph = &oGylphNew; break; case PBDF_TOKEN_STARTCHAR: if( bIsReadingChar ) { PBDF_ERROR( "glyph %s\n", oStrLine.GetData() ); return false; } bIsReadingChar = true; oGylphNew = m_oGlyphDefault; ReadValue( oStrLine, &poGlyph->m_oStrName ); PBDF_LOG( "char_name: %s\n", poGlyph->m_oStrName.GetData() ); PBDF_LOG( "char_num: %d\n", m_oArrGlyph.GetSize() ); break; case PBDF_TOKEN_ENCODING: ReadValue( oStrLine, &poGlyph->m_iEncoding0 ); PBDF_LOG( "encoding0: %d\n", poGlyph->m_iEncoding0 ); RemoveNextWord( oStrLine ); if( !oStrLine.GetSize() ) break; ReadValue( oStrLine, &poGlyph->m_iEncoding1 ); PBDF_LOG( "encoding1: %d\n", poGlyph->m_iEncoding1 ); break; case PBDF_TOKEN_BBX: ReadValue( oStrLine, &poGlyph->m_iBBX ); PBDF_LOG( "bbx: %d\n", poGlyph->m_iBBX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_iBBY ); PBDF_LOG( "bby: %d\n", poGlyph->m_iBBY ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_iBBOffX ); PBDF_LOG( "bb_off_x: %d\n", poGlyph->m_iBBOffX ); RemoveNextWord( oStrLine ); ReadValue( oStrLine, &poGlyph->m_iBBOffY ); PBDF_LOG( "bb_off_y: %d\n", poGlyph->m_iBBOffY ); break; case PBDF_TOKEN_BITMAP: { CArray<unsigned char> oArrBitmap; const int iHeight = poGlyph->m_iBBY; // Da hier sowieso kein Token folgt, kann ohne weiteres // auch über das Zeilenende hinaus gearbeitet werden. int iPosBegin = iEndOfLine + 1; int l = 0; poGlyph->m_oArrBitmap.Clear(); while( l < iHeight ) { const int iEOL = oStrFontFile.Find( iPosBegin, PBDF_NEWLINE ); if( iEOL < 0 ) break; CStr oCodeLine = oStrFontFile.GetSub( iPosBegin, iEOL - iPosBegin ); ReadValue( oCodeLine, &oArrBitmap ); poGlyph->m_oArrBitmap.Append( oArrBitmap ); iPosBegin = iEOL + 1; ++l; } } break; case PBDF_TOKEN_ENDCHAR: m_oArrGlyph.Append( oGylphNew ); bIsReadingChar = false; break; case PBDF_TOKEN_ENDFONT: PBDF_LOG( "glyph_count: %d\n", m_oArrGlyph.GetSize() ); if( m_oArrGlyph.GetSize() != (unsigned int)m_iChars ) { PBDF_ERROR( "glyph_cout: %d != %d", m_oArrGlyph.GetSize(), m_iChars ); return false; } break; }; } iPos = iEndOfLine + 1; // falls "\r\n"?? } PBDF_LOG( "parse: end\n" ); return true; }
void CPrsBDF::ReadValue( CStr &roStr, int *piInteger ) { if( roStr.GetSize() ) *piInteger = atoi( roStr.GetData() ); // TODO: ersetzen durch eigene Funktion. }
void CPrsBDF::ReadValue( CStr &roStr, double *pdNumber ) { if( roStr.GetSize() ) *pdNumber = atof( roStr.GetData() ); // TODO: ersetzen durch eigene Funktion. }
void CGmResMan::NewMeshObj( const char *pcSubDir, const char *pcFileName, CArray<CGMeshObj *> &roArr, bool bTexSmooth, bool bRawPoly ) { roArr.Clear(); CStr oPre( DATA_DIR + "model/" + pcSubDir ); if( oPre[oPre.GetSize()-1] != '/' ) oPre += '/'; CFileBlockTxt oFile; if( oFile.Load( ( oPre + pcFileName ).GetData() ) ) { LOG( "Loading %s.\n", ( oPre + pcFileName ).GetData() ); CStr oMaterialLibName; if( CGMeshObj::LoadModel_( oFile.GetString(), &roArr, bRawPoly, &oMaterialLibName ) ) { LOG( "%d OBJ-Meshes loaded.\n", roArr.GetSize() ); bool bMtllibOk = false; CFileBlockTxt oFileMaterialLib; if( oMaterialLibName.GetSize() ) { if( oFileMaterialLib.Load( ( oPre + oMaterialLibName ).GetData() ) ) { //LOG( "\nmtllib:\n%s\n", (const char *)oFileMaterialLib.m_pucData ); LOG( "%s loaded.\n", oMaterialLibName.GetData() ); bMtllibOk = true; } } for( unsigned int i=0; i<roArr.GetSize(); ++i ) { CGMeshObj *poMesh = roArr[i]; //poMesh->RotateX( M_PI ); //poMesh->ScaleX( 1.1f ); //poMesh->ScaleY( 1.1f ); //poMesh->ScaleZ( 1.1f ); LOG( "\t%s\n", poMesh->m_oName.GetData() ); LOG( "\t%d vertices\n", poMesh->m_oArrVertex.GetSize() ); LOG( "\t%d indices\n", poMesh->m_oArrIndex.GetSize() ); LOG( "\tmaterial: %s\n", poMesh->m_oMaterialName.GetData() ); if( bMtllibOk ) { CStr oTexNameDiffuse, oTexNameNormal; poMesh->LoadMaterial( oFileMaterialLib.GetString(), poMesh->m_oMaterialName, &oTexNameDiffuse, 0, &oTexNameNormal ); if( !bRawPoly ) { if( oTexNameDiffuse.GetSize() ) { poMesh->SetTex( NewTexture( oTexNameDiffuse, bTexSmooth, false ), 0 ); } if( oTexNameNormal.GetSize() ) { poMesh->SetTex( NewTexture( oTexNameNormal, false, false ), 1 ); } } } else if( !bRawPoly && poMesh->m_oMaterialName.GetSize() ) { poMesh->SetTex( NewTexture( poMesh->m_oMaterialName, bTexSmooth, false ), 0 ); } poMesh->m_bEnableColor = false; // Hat keine Funktion bei beim Wavefront Object Meshes. poMesh->Init(); m_oArrMesh.Append( poMesh ); // new } } } else { ERR( "OBJ Mesh %s.\n", pcFileName ); } }
int CStr::FindVecRev( unsigned int uiStart, const CStr & roStr ) const { return FindVecRev( uiStart, roStr.GetData() ); }
bool COrgOp::Load( CStr &roSrc, unsigned int uiIDOffset ) { CStr oStrLine; CStr oStrToken; CList<COp *> oLstPatch; unsigned int uiIDIn = 0; unsigned int uiIdxIn = 0; unsigned int uiCountIn = 0; unsigned int uiPortIn = 0; unsigned int uiIndexIn = 0; unsigned int uiCountOut = 0; unsigned int uiPortOut = 0; unsigned int uiInteralInt = 0; unsigned int uiInteralUInt = 0; unsigned int uiInteralFlt = 0; unsigned int i = 0; unsigned int uiMaxIPortIn = 0; unsigned int uiMaxIPortOut = 0; unsigned int uiMaxIInternalInt = 0; unsigned int uiMaxIInternalUInt = 0; unsigned int uiMaxIInternalFlt = 0; COp *poOp = 0; // <mod date="2010-12-07"> CList<CArray<unsigned int> *> oLstArrID; CArray<unsigned int> * poArrID = 0; // </mod> // Alle Operatoren einlesen, erstellen und pseudo-patchen. while( 1 ) { if( !Decode_GetNextLine( oStrLine, roSrc ) ) break; i = 0; while( 1 ) { if( !Decode_GetNextToken( oStrToken, oStrLine ) ) break; if( !oStrToken.GetSize() ) { if( i > 1 ) // Komprimierung :: -> :0: oStrToken = '0'; else if( i == 0 ) ORG_OP_LOG( "Fehler: Klassen-Name nicht vorhanden." ); } // class if( i == 0 ) { poOp = Create( oStrToken ); if( poOp == 0 ) { ORG_OP_LOG( "Fehler: Unbekannte Klasse: %s\n", oStrToken.GetData() ); return false; } oLstPatch.Append( poOp ); } // instance else if( i == 1 ) { #ifdef OP_USE_RUNTIME_INFO poOp->SetNameInstance( oStrToken ); #endif // OP_USE_RUNTIME_INFO } // id else if( i == 2 ) { unsigned int uiID; ORG_OP_SSCANF( oStrToken, "%x", &uiID ); poOp->SetID( uiID + uiIDOffset ); // Um keinen Konflikt zu erzeugen. } // flags else if( i == 3 ) { unsigned int uiFlags; ORG_OP_SSCANF( oStrToken, "%x", &uiFlags ); poOp->SetFlags( uiFlags ); } // count_input else if ( i == 4 ) { ORG_OP_SSCANF( oStrToken, "%x", &uiCountIn ); if( poOp->GetFlags() & OP_FLAG_DYNAMIC_INPUTS ) { poOp->SetCountIn( uiCountIn ); } else if( poOp->GetCountIn() != uiCountIn ) { #ifdef OP_USE_RUNTIME_INFO ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Inputs unterstuetzt! " "Keine dynamischen Inputs!\n", poOp->GetNameClass(), uiCountIn ); #endif // OP_USE_RUNTIME_INFO return false; } uiPortIn = 0; uiIndexIn = 0; uiMaxIPortIn = 3 * uiCountIn + 4 + 1; // <mod date="2010-12-07"> poArrID = new CArray<unsigned int>( uiCountIn ); oLstArrID.Append( poArrID ); // </mod> } // inputs else if( i < uiMaxIPortIn ) { unsigned int uiVal; ORG_OP_SSCANF( oStrToken.GetData(), "%x", &uiVal ); switch( uiIndexIn ) { case 0: // id uiIDIn = uiVal; break; case 1: // port uiIdxIn = uiVal; break; case 2: // flags if( uiIDIn ) uiIDIn += uiIDOffset; // Um keinen Konflikt zu erzeugen. // <mod date="2010-12-07"> poArrID->At( uiPortIn ) = uiIDIn; poOp->In( uiPortIn ) = COp::CLink( 0, uiIdxIn, uiVal ); //poOp->In( uiPortIn ) = COp::CLink( reinterpret_cast<COp *>( uiIDIn ), uiIdxIn, uiVal ); // </mod> ++uiPortIn; break; } ++uiIndexIn; if( uiIndexIn == 3 ) uiIndexIn = 0; } // count_output else if( i == uiMaxIPortIn ) { ORG_OP_SSCANF( oStrToken, "%x", &uiCountOut ); if( poOp->GetFlags() & OP_FLAG_DYNAMIC_OUTPUTS ) { poOp->SetCountOut( uiCountOut ); } else if( poOp->GetCountOut() != uiCountOut ) { #ifdef OP_USE_RUNTIME_INFO ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Outputs unterstuetzt! " "Keine dynamischen Outputs!\n", poOp->GetNameClass(), uiCountOut ); #endif // OP_USE_RUNTIME_INFO return false; } uiPortOut = 0; uiMaxIPortOut = uiCountOut + uiMaxIPortIn + 1; } // outputs else if( i < uiMaxIPortOut ) { double dVal; ORG_OP_SSCANF( oStrToken.GetData(), "%lf", &dVal ); poOp->Out( uiPortOut ) = dVal; ++uiPortOut; } // int internal count else if( i == uiMaxIPortOut ) { unsigned int uiCountInternalInt; ORG_OP_SSCANF( oStrToken, "%x", &uiCountInternalInt ); if( poOp->GetCountInternalInt() != uiCountInternalInt ) { #ifdef OP_USE_RUNTIME_INFO ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Int-Interals unterstuetzt!\n", poOp->GetNameClass(), uiCountIn ); #endif // OP_USE_RUNTIME_INFO return false; } uiInteralInt = 0; uiMaxIInternalInt = uiMaxIPortOut + uiCountInternalInt + 1; } // int internals else if( i < uiMaxIInternalInt ) { int iVal; ORG_OP_SSCANF( oStrToken.GetData(), "%d", &iVal ); poOp->SetValueInternalInt( uiInteralInt, iVal ); ++uiInteralInt; } // uint internal count else if( i == uiMaxIInternalInt ) { unsigned int uiCountInternalUInt; ORG_OP_SSCANF( oStrToken, "%x", &uiCountInternalUInt ); if( poOp->GetCountInternalUInt() != uiCountInternalUInt ) { #ifdef OP_USE_RUNTIME_INFO ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d UInt-Interals unterstuetzt!\n", poOp->GetNameClass(), uiCountIn ); #endif // OP_USE_RUNTIME_INFO return false; } uiInteralUInt = 0; uiMaxIInternalUInt = uiMaxIInternalInt + uiCountInternalUInt + 1; } // uint internals else if( i < uiMaxIInternalUInt ) { unsigned int uiVal; ORG_OP_SSCANF( oStrToken.GetData(), "%u", &uiVal ); poOp->SetValueInternalUInt( uiInteralUInt, uiVal ); ++uiInteralUInt; } // flt internal count else if( i == uiMaxIInternalUInt ) { unsigned int uiCountInternalFlt; ORG_OP_SSCANF( oStrToken, "%x", &uiCountInternalFlt ); if( poOp->GetCountInternalFlt() != uiCountInternalFlt ) { #ifdef OP_USE_RUNTIME_INFO ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Float-Interals unterstuetzt!\n", poOp->GetNameClass(), uiCountIn ); #endif // OP_USE_RUNTIME_INFO return false; } uiInteralFlt = 0; uiMaxIInternalFlt = uiMaxIInternalUInt + uiCountInternalFlt + 1; } // flt internals else if( i < uiMaxIInternalFlt ) { double dVal; ORG_OP_SSCANF( oStrToken.GetData(), "%lf", &dVal ); poOp->SetValueInternalFlt( uiInteralFlt, dVal ); ++uiInteralFlt; } else break; ++i; } } // Pseudo-Patch nun mit echten Verbindungen versehen. i = oLstPatch.GetSize(); /* if( i < 2 ) { ORG_OP_LOG( "Fehler: Weniger als 2 Operatoren eingelesen!\n" ); return false; } */ // Altes Patch löschen. //Clear(); //m_poOpRootL_ = 0; //m_poOpRootR_ = 0; // <mod date="2010-12-07"> oLstArrID.MoveToBack(); // </mod> while( i ) { --i; poOp = oLstPatch[i]; // <mod date="2010-12-07"> oLstArrID.GetPrev( &poArrID ); // </mod> if( poOp ) { unsigned int uiIn = poOp->GetCountIn(); while( uiIn ) { --uiIn; // <mod date="2010-12-07"> const unsigned int uiTmpIDNext = poArrID->At( uiIn ); //unsigned int uiTmpIDNext = // reinterpret_cast<unsigned int>( poOp->In( uiIn ).GetOp() ); // </mod> if( !uiTmpIDNext ) // ID 0 ist ungültig. continue; // Ganze Liste durchiterieren, und nach der ID aus dem aktuellen // Input-Array Ausschau halten! COp *poOpNext; oLstPatch.MoveToFront(); while( oLstPatch.GetNext( &poOpNext ) ) { if( poOpNext->GetID() == uiTmpIDNext ) { poOp->In( uiIn ).SetOp( poOpNext ); } } } } //if( i == 0 ) // m_poOpRootL_ = poOp; //else if ( i == 1 ) // m_poOpRootR_ = poOp; } // <mod date="2010-12-07"> LIST_DELETE( oLstArrID, CArray<unsigned int> ); // </mod> // Alle aufglösten Operatoren in die echte Liste einfügen... oLstPatch.MoveToFront(); while( oLstPatch.GetNext( &poOp ) ) { #ifdef OP_USE_USER_DATA poOp->m_pvData = 0; #endif // OP_USE_USER_DATA m_oLstOp.Append( poOp ); } //UpdateAll(); ValidateAll(); return true; }