// File: TestTopOpe_BOOPCommands.cxx // Created: Mon Oct 21 10:32:36 1996 // Author: Jean Yves LEBEY // #include #include #include #include #include #include #include #include #include #include #ifdef WNT Standard_IMPORT Draw_Viewer dout; #endif //static Standard_Boolean Bool; static Standard_Integer NbMES = 0; static TColStd_Array1OfAsciiString *PDel = NULL; static TColStd_Array1OfAsciiString *PNAME = NULL; static TestTopOpeTools_Array1OfMesure *PAMES = NULL; //----------------------------------------------- static Standard_Integer SetName(const Standard_Character *C, Draw_Interpretor& di) //----------------------------------------------- // here the number of measurement is managed { if(PNAME == NULL) { PNAME = new TColStd_Array1OfAsciiString(1, 100); } if(PDel == NULL) { PDel = new TColStd_Array1OfAsciiString(1, 100); } if(NbMES >= 100) {di << "ATTENTION : last measurement accepted";} for(Standard_Integer i = 1; i <= NbMES; i++) { Standard_Character *Ch = (Standard_Character *)(*PNAME).Value(i).ToCString(); if( *Ch == *C) return i; } (*PNAME).SetValue(++NbMES, *C); (*PDel).SetValue(NbMES, "0"); return NbMES; } // Unused : #ifdef DEB //----------------------------------------------- static void SeemMesure(const Handle(TestTopOpeDraw_DrawableMesure) DM,const Standard_Integer CMES) //----------------------------------------------- { char *pname = (char *)(*PNAME).Value(CMES).ToCString(); Draw::Set(pname,DM); } #endif static void Mes_help(Draw_Interpretor& di) { di<<"\n"; di<<"mesure M : create/reset measurement M "<<"\n"; di<<"mesure reset : reinitialize all measurements"<<"\n"; di<<"mesure M n t : add data [n t] to M"<<"\n"; di<<"mesure range M : sort indexes 'min max' of M"<<"\n"; di<<"mesure minmax M : take 'xmin ymin xmax ymax' from M"<<"\n"; di<<"mesure xy M : take 'x y' = M(i)"<<"\n"; di<<"seem M : visualize M"<<"\n"; di<<"seemx M fx : visualize M with factor in x"<<"\n"; di<<"seemx M fy : visualize M with factor in y"<<"\n"; di<<"seemxy M fx fy : visualize M with factor in x,y"<<"\n"; di<<""<<"\n"; } // ---------------------------------------------------------------------- Standard_Integer Mes(Draw_Interpretor& di,Standard_Integer na, const char** a) // ---------------------------------------------------------------------- { if (!strcmp(a[0],"mesure")) { if (na == 1) { Mes_help(di); return 0; } else if (na == 2) { if (!strcmp(a[1],"reset")) { PAMES = NULL; return 0;} else { Standard_Integer CurrentMES2 = SetName(a[1],di); TestTopOpeTools_Mesure *MES2; MES2 = new TestTopOpeTools_Mesure(a[1]); if(PAMES == NULL) { PAMES = new TestTopOpeTools_Array1OfMesure(1, 100); } (*PAMES).SetValue(CurrentMES2, *MES2); } } else if (na == 3) { if (!strcmp(a[1],"range")) { const TestTopOpeTools_Mesure& M = (*PAMES).Value(SetName(a[2],di)); di<<"1 "<Pnts())); MES->SetName(a[i]); (*PAMES).SetValue(CurrentMESS2, *MES); } else { MESS2 = (*PAMES).Value(CurrentMESS2); if(!D.IsNull()) { DMES2 = Handle(TestTopOpeDraw_DrawableMesure)::DownCast(D); } else { // --> M is already in PAMES, and DMES has no name DMES2 = new TestTopOpeDraw_DrawableMesure(MESS2, Draw_blanc,Draw_rose); } } Draw::Set(a[i],DMES2); (*PDel).SetValue(CurrentMESS2, "1"); } dout.RepaintAll(); } else if (!strcmp(a[0],"seemx") || !strcmp(a[0],"seemy")) { if (na < 3) return 0; Standard_Real dx=1.,dy=1.; Standard_Boolean isX = Standard_False, isY = Standard_False; if (!strcmp(a[0],"seemx")) { dx = atof(a[na-1]); isX = Standard_True; } else if (!strcmp(a[0],"seemy")) { dy = atof(a[na-1]); isY = Standard_True; } TestTopOpeTools_Mesure MES5; Handle(Draw_Drawable3D) D; Handle(TestTopOpeDraw_DrawableMesure) DMES5; Standard_Integer test, i; if(PAMES == NULL) { PAMES = new TestTopOpeTools_Array1OfMesure(1, 100); } for(i = 1; i < na-1; i++) { test = NbMES; Standard_Integer CurrentMES5 = SetName(a[i],di); D = Draw::Get(a[i],Standard_False); if(test < CurrentMES5) {// if new measurement, it is after restore if(D.IsNull()) { return 0; } DMES5 = Handle(TestTopOpeDraw_DrawableMesure)::DownCast(D); TestTopOpeTools_Mesure *MES; MES = (new TestTopOpeTools_Mesure(DMES5->Pnts())); MES->SetName(a[i]); (*PAMES).SetValue(CurrentMES5, *MES); } else { MES5 = (*PAMES).Value(CurrentMES5); if(!D.IsNull()) { DMES5 = Handle(TestTopOpeDraw_DrawableMesure)::DownCast(D); } else { DMES5 = new TestTopOpeDraw_DrawableMesure(MES5, Draw_blanc,Draw_rose); } } Draw::Set(a[i],DMES5); (*PDel).SetValue(CurrentMES5, "1"); if(isX) DMES5->SetScaleX(dx); if(isY) DMES5->SetScaleY(dy); } } else if (!strcmp(a[0],"seemxy")) { if (na < 4) return 0; TestTopOpeTools_Mesure& M = (*PAMES).ChangeValue(SetName(a[1],di)); Standard_Real dx=atof(a[2]),dy=atof(a[3]); Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False); Handle(TestTopOpeDraw_DrawableMesure) DM; DM = Handle(TestTopOpeDraw_DrawableMesure)::DownCast(D); if (DM.IsNull()) { DM = new TestTopOpeDraw_DrawableMesure(M,Draw_blanc,Draw_rose); Draw::Set(a[1],DM); } DM->SetScaleX(dx); DM->SetScaleY(dy); dout<