void CPitchBendEditor::ZoomChanged( int32 diff) { BRect r(Frame()); float scroll = (ScrollValue(B_VERTICAL) + (r.bottom - r.top) / 2) / pixelsPerValue; verticalZoom += diff; if (verticalZoom > 12) verticalZoom = 12; else if (verticalZoom < 4) verticalZoom = 4; Hide(); CalcZoom(); SetScrollRange(scrollRange.x, scrollValue.x, stripLogicalHeight, (scroll * pixelsPerValue) - (r.bottom - r.top) / 2); Show(); }
CPitchBendEditor::CPitchBendEditor( CStripFrameView &frame, BRect rect) : CContinuousValueEditor(frame, rect, "Pitch Bend") { SetRendererFor(EvtType_PitchBend, new CPitchBendEventRenderer(this)); minValue = 0 - 0x2000; maxValue = 0x3fff - 0x2000; eventAscent = 3; eventDescent = 3; verticalZoom = 6; CalcZoom(); // Make the label view on the left-hand side SetLabelView(new CStripLabelView(BRect(-1.0, -1.0, 20.0, rect.Height() + 1), "Pitch Bend", B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)); }
void DesenhaRota(DIST *distrito, CTD *contorno) { char nomelocal[SSIZE]; LOCAL *local = NULL, *rota = NULL, *auxloc = NULL; FILE *frota; int ret,cod; COORD *aux, *coordenadas; double oldlatitude, oldlongitude; double latitude, longitude; float zoom, latref, lonref; /*Guarda o conteudo do ficheiro numa lista do tipo LOCAL chamada rota*/ frota = fopen(FROTA,"r"); if(frota == NULL){ allegro_init(); allegro_message("Ficheiro com a rota não encontrado."); allegro_exit(); return; } fgets(nomelocal,SSIZE,frota); do { nomelocal[strlen(nomelocal)-1] = '\0'; local = RetLocal(distrito,nomelocal); rota = InsereLocalidade(rota,local->localidade,local->latitude,local->longitude); }while(fgets(nomelocal,SSIZE,frota) != NULL); fclose(frota); zoom = CalcZoom(rota); /*Define o zoom*/ /*Define Centro do ecra */ auxloc = rota; while(auxloc->prox != NULL) auxloc = auxloc->prox; latref = (rota->latitude + auxloc->latitude)/2; /*calcula o ponto médio entre a localidade de partida e a de chegada*/ lonref = (rota->longitude + auxloc->longitude)/2; /*que sera o centro do ecra*/ /*Desenha os contornos dos distritos*/ allegro_init(); ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, LARGURA_JANELA, ALTURA_JANELA, 0, 0); if (ret != 0) { allegro_message("Graphic error- Exiting"); return; } floodfill(screen,1,1,BGCOL); textprintf_ex(screen, font,3,3,TCOL, -1,"Zoom = %.2f",zoom); for(cod = 0 ; cod < NFRON; cod++) { coordenadas = contorno[cod].coord; aux = coordenadas; while(aux->prox != NULL) { oldlatitude = transf_lat(aux->latitude,zoom,latref,SCREEN_H); oldlongitude = transf_lon(aux->latitude,aux->longitude,zoom,lonref,SCREEN_W); aux = aux->prox; latitude = transf_lat(aux->latitude,zoom,latref,SCREEN_H); longitude = transf_lon(aux->latitude,aux->longitude,zoom,lonref, SCREEN_W); line(screen,oldlongitude,oldlatitude,longitude,latitude,contorno[cod].cor); } } /*Desenha o nome das localidades*/ auxloc = rota; while(auxloc != NULL) { DesenhaLocal(auxloc->localidade,auxloc->latitude,auxloc->longitude,latref,lonref,zoom); auxloc = auxloc->prox; } /*Desenha caminho*/ auxloc = rota; while(auxloc->prox != NULL) { oldlatitude = transf_lat(auxloc->latitude,zoom,latref,SCREEN_H); oldlongitude = transf_lon(auxloc->latitude,auxloc->longitude,zoom,lonref,SCREEN_W); auxloc = auxloc->prox; latitude = transf_lat(auxloc->latitude,zoom,latref,SCREEN_H); longitude = transf_lon(auxloc->latitude,auxloc->longitude,zoom,lonref, SCREEN_W); line(screen,oldlongitude,oldlatitude,longitude,latitude,1); } install_keyboard(); readkey(); allegro_exit(); }