virtual void DrawWidget(const Rect &r, int widget) const { switch (widget) { case MW_GAUGE: GfxFillRect(r.left, r.top, r.right, r.bottom, 0); for (uint i = 0; i != 8; i++) { int colour = 0xD0; if (i > 4) { colour = 0xBF; if (i > 6) { colour = 0xB8; } } GfxFillRect(r.left, r.bottom - i * 2, r.right, r.bottom - i * 2, colour); } break; case MW_TRACK_NR: { GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, 0); StringID str = STR_MUSIC_TRACK_NONE; if (_song_is_active != 0 && _music_wnd_cursong != 0) { SetDParam(0, GetTrackNumber(_music_wnd_cursong - 1)); SetDParam(1, 2); str = STR_MUSIC_TRACK_DIGIT; } DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str); break; } case MW_TRACK_NAME: { GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, 0); StringID str = STR_MUSIC_TITLE_NONE; if (_song_is_active != 0 && _music_wnd_cursong != 0) { str = STR_MUSIC_TITLE_NAME; SetDParamStr(0, GetSongName(_music_wnd_cursong - 1)); } DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_FROMSTRING, SA_HOR_CENTER); break; } case MW_MUSIC_VOL: case MW_EFFECT_VOL: { DrawFrameRect(r.left, r.top + 2, r.right, r.bottom - 2, COLOUR_GREY, FR_LOWERED); byte volume = (widget == MW_MUSIC_VOL) ? _msf.music_vol : _msf.effect_vol; int x = (volume * (r.right - r.left) / 127); if (_current_text_dir == TD_RTL) { x = r.right - x; } else { x += r.left; } DrawFrameRect(x, r.top, x + slider_width, r.bottom, COLOUR_GREY, FR_NONE); break; } } }
void DrawButtonFrame(int x, int y, int w, int h, int str) { DrawFrameRect(x, y, x + w, y + h, COLOUR_GREY, FR_BORDERONLY); Dimension d = GetStringBoundingBox(str); DrawFrameRect(x + w / 2 - d.width / 2 - 1, Center(y, h) - 2, x + w / 2 + d.width / 2 + 1, Center(y, h) + d.height, COLOUR_GREY, FR_NONE); DrawString(x, x + w, Center(y, h), str, TC_FROMSTRING, SA_HOR_CENTER); }
/* virtual */ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const { if (widget != WID_NCDS_BACKGROUND) return; /* Draw nice progress bar :) */ DrawFrameRect(r.left + 20, r.top + 4, r.left + 20 + (int)((this->width - 40LL) * this->downloaded_bytes / this->total_bytes), r.top + 14, COLOUR_MAUVE, FR_NONE); int y = r.top + 20; SetDParam(0, this->downloaded_bytes); SetDParam(1, this->total_bytes); SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes); DrawString(r.left + 2, r.right - 2, y, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER); StringID str; if (this->downloaded_bytes == this->total_bytes) { str = STR_CONTENT_DOWNLOAD_COMPLETE; } else if (!StrEmpty(this->name)) { SetDParamStr(0, this->name); SetDParam(1, this->downloaded_files); SetDParam(2, this->total_files); str = STR_CONTENT_DOWNLOAD_FILE; } else { str = STR_CONTENT_DOWNLOAD_INITIALISE; } y += FONT_HEIGHT_NORMAL + 5; DrawStringMultiLine(r.left + 2, r.right - 2, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER); }
virtual void DrawWidget(const Rect &r, int widget) const { switch (widget) { case WID_TT_SIGNS: case WID_TT_TREES: case WID_TT_HOUSES: case WID_TT_INDUSTRIES: case WID_TT_BUILDINGS: case WID_TT_BRIDGES: case WID_TT_STRUCTURES: case WID_TT_CATENARY: case WID_TT_LOADING: { uint i = widget - WID_TT_BEGIN; if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + 1, r.top + 1); break; } case WID_TT_BUTTONS: for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) { if (i == WID_TT_LOADING) continue; // Do not draw button for invisible loading indicators. const NWidgetBase *wi = this->GetWidget<NWidgetBase>(i); DrawFrameRect(wi->pos_x + 1, r.top + 2, wi->pos_x + wi->current_x - 2, r.bottom - 2, COLOUR_PALE_GREEN, HasBit(_invisibility_opt, i - WID_TT_BEGIN) ? FR_LOWERED : FR_NONE); } break; } }
/** * Draws an image of a road vehicle chain * @param v Front vehicle * @param left The minimum horizontal position * @param right The maximum horizontal position * @param y Vertical position to draw at * @param selection Selected vehicle to draw a frame around */ void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection) { bool rtl = _dynlang.text_dir == TD_RTL; Direction dir = rtl ? DIR_E : DIR_W; const RoadVehicle *u = RoadVehicle::From(v); int max_width = right - left + 1; int spent_width = 0; int pos = rtl ? right : left; for (; u != NULL && spent_width < max_width; u = u->Next()) { Point offset; int width = u->GetDisplayImageWidth(&offset); SpriteID pal = (u->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(u); DrawSprite(u->GetImage(dir), pal, pos + (rtl ? -offset.x : offset.x), y + 6 + offset.y); pos += rtl ? -width : width; spent_width += width; } if (v->index == selection) { DrawFrameRect((rtl ? pos : left) - 1, y - 1, (rtl ? pos : right) - 1, y + 12, COLOUR_WHITE, FR_BORDERONLY); } }
virtual void DrawWidget(const Rect &r, int widget) const { switch (widget) { case WID_M_TRACK_NR: { GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK); if (BaseMusic::GetUsedSet()->num_available == 0) { break; } StringID str = STR_MUSIC_TRACK_NONE; if (_music.IsPlaying()) { SetDParam(0, _music.GetCurrentSong().tracknr); SetDParam(1, 2); str = STR_MUSIC_TRACK_DIGIT; } DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str); break; } case WID_M_TRACK_NAME: { GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, PC_BLACK); StringID str = STR_MUSIC_TITLE_NONE; if (BaseMusic::GetUsedSet()->num_available == 0) { str = STR_MUSIC_TITLE_NOMUSIC; } else if (_music.IsPlaying()) { str = STR_MUSIC_TITLE_NAME; SetDParamStr(0, _music.GetCurrentSong().songname); } DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_FROMSTRING, SA_HOR_CENTER); break; } case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { int sw = ScaleGUITrad(slider_width); int hsw = sw / 2; DrawFrameRect(r.left + hsw, r.top + 2, r.right - hsw, r.bottom - 2, COLOUR_GREY, FR_LOWERED); byte volume = (widget == WID_M_MUSIC_VOL) ? _settings_client.music.music_vol : _settings_client.music.effect_vol; if (_current_text_dir == TD_RTL) volume = 127 - volume; int x = r.left + (volume * (r.right - r.left - sw) / 127); DrawFrameRect(x, r.top, x + sw, r.bottom, COLOUR_GREY, FR_NONE); break; } } }
CBenchmark() { for (dword i = 0; i < 4; i++) m_PerfData[i] = 0; m_SurfID = CreateSurface(300, 200, 256, 256 + 16); FillSurface(m_SurfID, 0xFFFFFFFF); DrawFrameRect(m_SurfID, 0, 0, 256, 256 + 16, 0xFF808080); ShowSurface(m_SurfID); KeEnableNotification(Nf_VirtualKey); KeEnableNotification(NfKe_TerminateProcess); double T = 0.0; dword FPS = 0; dword T1 = KeGetTime(); for (;;) { for (dword i = 0; i < 6; i++) DrawIter(T - 4.0 * (5 - i), 0xFFFFFFFF); T += 1.0; for (dword i = 0; i < 6; i++) DrawIter(T - 4.0 * (5 - i), 0x004070FF | (((i + 1) * 0x10) << 24)); WaitRedraw(); FPS++; dword T2 = KeGetTime(); if (T2 - T1 >= 1000) { dword AvgFPS = AddPerfData(FPS); T1 = T2; FPS = 0; ShowStat(AvgFPS); } CNotification<4> Nf; dword NfCount = KeGetNotificationCount(); for (dword i = 0; i < NfCount; i++) { Nf.Recv(); if (Nf.GetID() == Nf_VirtualKey) { if (Nf.GetByte(0) == VK_Esc) return; } else if (Nf.GetID() == NfKe_TerminateProcess) return; } } }
/** * Draws an image of a whole train * @param v Front vehicle * @param left The minimum horizontal position * @param right The maximum horizontal position * @param y Vertical position to draw at * @param selection Selected vehicle to draw a frame around * @param skip Number of pixels to skip at the front (for scrolling) */ void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip) { bool rtl = _dynlang.text_dir == TD_RTL; Direction dir = rtl ? DIR_E : DIR_W; DrawPixelInfo tmp_dpi, *old_dpi; /* Position of highlight box */ int highlight_l = 0; int highlight_r = 0; int max_width = right - left + 1; if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, 14)) return; old_dpi = _cur_dpi; _cur_dpi = &tmp_dpi; int px = rtl ? max_width + skip : -skip; bool sel_articulated = false; for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->Next()) { Point offset; int width = Train::From(v)->GetDisplayImageWidth(&offset); if (rtl ? px + width > 0 : px - width < max_width) { SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); DrawSprite(v->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), 7 + offset.y); } if (!v->IsArticulatedPart()) sel_articulated = false; if (v->index == selection) { /* Set the highlight position */ highlight_l = rtl ? px - width : px; highlight_r = rtl ? px - 1 : px + width - 1; sel_articulated = true; } else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) { if (rtl) { highlight_l -= width; } else { highlight_r += width; } } px += rtl ? -width : width; } if (highlight_l != highlight_r) { /* Draw the highlight. Now done after drawing all the engines, as * the next engine after the highlight could overlap it. */ DrawFrameRect(highlight_l, 0, highlight_r, 13, COLOUR_WHITE, FR_BORDERONLY); } _cur_dpi = old_dpi; }
virtual void DrawWidget(const Rect &r, int widget) const { switch (widget) { case WID_M_TRACK_NR: { GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK); StringID str = STR_MUSIC_TRACK_NONE; if (_song_is_active != 0 && _music_wnd_cursong != 0) { SetDParam(0, GetTrackNumber(_music_wnd_cursong - 1)); SetDParam(1, 2); str = STR_MUSIC_TRACK_DIGIT; } DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, Center(r.top, r.bottom - r.top, FONT_HEIGHT_SMALL), str); break; } case WID_M_TRACK_NAME: { GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, PC_BLACK); StringID str = STR_MUSIC_TITLE_NONE; if (_song_is_active != 0 && _music_wnd_cursong != 0) { str = STR_MUSIC_TITLE_NAME; SetDParamStr(0, GetSongName(_music_wnd_cursong - 1)); } DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, Center(r.top, r.bottom - r.top, FONT_HEIGHT_SMALL), str, TC_FROMSTRING, SA_HOR_CENTER); break; } case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { DrawFrameRect(r.left, r.top + 2, r.right, r.bottom - 2, COLOUR_GREY, FR_LOWERED); byte volume = (widget == WID_M_MUSIC_VOL) ? _settings_client.music.music_vol : _settings_client.music.effect_vol; int x = (volume * (r.right - r.left) / 127); if (_current_text_dir == TD_RTL) { x = r.right - x; } else { x += r.left; } DrawFrameRect(x, r.top, x + slider_width, r.bottom, COLOUR_GREY, FR_NONE); break; } } }
virtual void DrawWidget(const Rect &r, int widget) const { if (widget != AIS_WIDGET_BACKGROUND) return; AIConfig *config = this->ai_config; AIConfigItemList::const_iterator it = config->GetConfigList()->begin(); int i = 0; for (; !this->vscroll->IsVisible(i); i++) it++; bool rtl = _current_text_dir == TD_RTL; uint buttons_left = rtl ? r.right - 23 : r.left + 4; uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : 28); uint text_right = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT); int y = r.top; for (; this->vscroll->IsVisible(i) && it != config->GetConfigList()->end(); i++, it++) { int current_value = config->GetSetting((*it).name); bool editable = _game_mode == GM_MENU || !Company::IsValidID(this->slot) || (it->flags & AICONFIG_INGAME) != 0; StringID str; TextColour colour; uint idx = 0; if (StrEmpty((*it).description)) { str = STR_JUST_STRING; colour = TC_ORANGE; } else { str = STR_AI_SETTINGS_SETTING; colour = TC_LIGHT_BLUE; SetDParamStr(idx++, (*it).description); } if (((*it).flags & AICONFIG_BOOLEAN) != 0) { DrawFrameRect(buttons_left, y + 2, buttons_left + 19, y + 10, (current_value != 0) ? COLOUR_GREEN : COLOUR_RED, (current_value != 0) ? FR_LOWERED : FR_NONE); SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON); } else { DrawArrowButtons(buttons_left, y + 2, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > (*it).min_value, editable && current_value < (*it).max_value); if (it->labels != NULL && it->labels->Contains(current_value)) { SetDParam(idx++, STR_JUST_RAW_STRING); SetDParamStr(idx++, it->labels->Find(current_value)->second); } else { SetDParam(idx++, STR_JUST_INT); SetDParam(idx++, current_value); } } DrawString(text_left, text_right, y + WD_MATRIX_TOP, str, colour); y += this->line_height; } }
/** * Draws an image of a ship * @param v Front vehicle * @param left The minimum horizontal position * @param right The maximum horizontal position * @param y Vertical position to draw at * @param selection Selected vehicle to draw a frame around */ void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection) { bool rtl = _current_text_dir == TD_RTL; SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W); const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL); int x = rtl ? right - real_sprite->width - real_sprite->x_offs : left - real_sprite->x_offs; DrawSprite(sprite, GetVehiclePalette(v), x, y + 10); if (v->index == selection) { x += real_sprite->x_offs; y += real_sprite->y_offs + 10; DrawFrameRect(x - 1, y - 1, x + real_sprite->width + 1, y + real_sprite->height + 1, COLOUR_WHITE, FR_BORDERONLY); } }
/** * Draws an image of a ship * @param v Front vehicle * @param left The minimum horizontal position * @param right The maximum horizontal position * @param y Vertical position to draw at * @param selection Selected vehicle to draw a frame around */ void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type) { bool rtl = _current_text_dir == TD_RTL; SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type); const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL); int width = UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI); int x_offs = UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI); int x = rtl ? right - width - x_offs : left - x_offs; DrawSprite(sprite, GetVehiclePalette(v), x, y + 10); if (v->index == selection) { x += x_offs; y += UnScaleByZoom(real_sprite->y_offs, ZOOM_LVL_GUI) + 10; DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleByZoom(real_sprite->height, ZOOM_LVL_GUI) + 1, COLOUR_WHITE, FR_BORDERONLY); } }
virtual void DrawWidget(const Rect &r, int widget) const { if (widget != AIS_WIDGET_BACKGROUND) return; AIConfig *config = this->ai_config; AIConfigItemList::const_iterator it = config->GetConfigList()->begin(); int i = 0; for (; !this->vscroll.IsVisible(i); i++) it++; bool rtl = _dynlang.text_dir == TD_RTL; uint buttons_left = rtl ? r.right - 23 : r.left + 4; uint value_left = r.left + (rtl ? WD_FRAMERECT_LEFT : 28); uint value_right = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT); uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : 54); uint text_right = r.right - (rtl ? 54 : WD_FRAMERECT_RIGHT); int y = r.top; for (; this->vscroll.IsVisible(i) && it != config->GetConfigList()->end(); i++, it++) { int current_value = config->GetSetting((*it).name); bool editable = (_game_mode == GM_MENU) || ((it->flags & AICONFIG_INGAME) != 0); uint x = rtl ? r.right : r.left; if (((*it).flags & AICONFIG_BOOLEAN) != 0) { DrawFrameRect(buttons_left, y + 2, buttons_left + 19, y + 10, (current_value != 0) ? COLOUR_GREEN : COLOUR_RED, (current_value != 0) ? FR_LOWERED : FR_NONE); } else { DrawArrowButtons(buttons_left, y + 2, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > (*it).min_value, editable && current_value < (*it).max_value); if (it->labels != NULL && it->labels->Find(current_value) != it->labels->End()) { x = DrawString(value_left, value_right, y + WD_MATRIX_TOP, it->labels->Find(current_value)->second, TC_ORANGE); } else { SetDParam(0, current_value); x = DrawString(value_left, value_right, y + WD_MATRIX_TOP, STR_JUST_INT, TC_ORANGE); } } DrawString(max(rtl ? 0U : x + 3, text_left), min(rtl ? x - 3 : r.right, text_right), y + WD_MATRIX_TOP, (*it).description, TC_LIGHT_BLUE); y += this->line_height; } }
/** * Draws an image of an aircraft * @param v Front vehicle * @param left The minimum horizontal position * @param right The maximum horizontal position * @param y Vertical position to draw at * @param selection Selected vehicle to draw a frame around */ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection) { bool rtl = _current_text_dir == TD_RTL; SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W); const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL); int x = rtl ? right - real_sprite->width - real_sprite->x_offs : left - real_sprite->x_offs; bool helicopter = v->subtype == AIR_HELICOPTER; PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); DrawSprite(sprite, pal, x, y + 10); if (helicopter) { const Aircraft *a = Aircraft::From(v); SpriteID rotor_sprite = GetCustomRotorSprite(a, true); if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED; DrawSprite(rotor_sprite, PAL_NONE, x, y + 5); } if (v->index == selection) { x += real_sprite->x_offs; y += real_sprite->y_offs + 10 - (helicopter ? 5 : 0); DrawFrameRect(x - 1, y - 1, x + real_sprite->width + 1, y + real_sprite->height + (helicopter ? 5 : 0) + 1, COLOUR_WHITE, FR_BORDERONLY); } }
void CoronalFor3DView::ImportImageData(vtkImageData *ImageData) { m_fPixelSpacing=ImageData->GetSpacing(); int *nDataExtent=ImageData->GetExtent(); m_nWidth=nDataExtent[1]; m_nHeight=nDataExtent[3]; m_nSliceSum=nDataExtent[5]; //QString str; //str.sprintf("%d ,%d, %d", m_nWidth,m_nHeight,m_nSliceSum); //QMessageBox::information(0, tr("Information"),str); Matrix->Identity(); Transform->SetMatrix(Matrix); //Transform->RotateY(-90); //ReverseSlice(); //resliceAxial->SetInput(ImageData); //resliceAxial->Update(); vtkSmartPointer<vtkPlaneSource> greyPlane=vtkSmartPointer<vtkPlaneSource>::New(); vtkSmartPointer<vtkTransformPolyDataFilter> greyTransform=vtkSmartPointer<vtkTransformPolyDataFilter>::New(); vtkSmartPointer<vtkPolyDataNormals> greyNormals=vtkSmartPointer<vtkPolyDataNormals>::New(); vtkSmartPointer<vtkPolyDataMapper> greyMapper=vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkTexture> greyTexture=vtkSmartPointer<vtkTexture>::New(); //greyActor=vtkActor::New(); //vtkImageConstantPad *greyPadder=vtkImageConstantPad::New(); greyPadder->SetInput(ImageData); greyPadder->SetOutputWholeExtent(0,m_nWidth,0,0,0,m_nSliceSum); greyPadder->SetConstant(0); greyTransform->SetTransform(Transform); greyTransform->SetInput(greyPlane->GetOutput()); greyNormals->SetInput(greyTransform->GetOutput()); greyNormals->FlipNormalsOff(); greylut->SetWindow(400); greylut->SetLevel(40); greylut->SetTableRange(-160,240); greylut->Build(); greyMapper->SetInput(greyPlane->GetOutput()); greyMapper->ImmediateModeRenderingOn(); greyTexture->SetInput(greyPadder->GetOutput()); greyTexture->SetLookupTable(greylut); greyTexture->MapColorScalarsThroughLookupTableOn(); greyTexture->InterpolateOn(); greyActor->SetMapper(greyMapper); greyActor->SetTexture(greyTexture); fScale=(m_nSliceSum*m_fPixelSpacing[2])/((m_nWidth-1)*m_fPixelSpacing[0]); greyActor->SetScale(1, fScale, 1); ren->AddActor(greyActor); //greyPlane->Delete(); //greyTransform->Delete(); //greyNormals->Delete(); //greyMapper->Delete(); //greyTexture->Delete(); SliceNumMapper->GetTextProperty()->SetFontFamilyToArial(); SliceNumMapper->GetTextProperty()->SetFontSize(20); SliceNumMapper->GetTextProperty()->BoldOn(); SliceNumMapper->GetTextProperty()->ShadowOff(); SliceNumMapper->GetTextProperty()->ItalicOff(); SliceNumMapper->GetTextProperty()->SetVerticalJustificationToBottom(); SliceNumMapper->GetTextProperty()->SetColor(0,1,0); SliceNumActor->SetMapper(SliceNumMapper); QString sSliceNum; sSliceNum.sprintf("%d", 0); SliceNumMapper->SetInput(sSliceNum.toAscii ()); SliceNumActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay() ; SliceNumActor->GetPositionCoordinate()->SetValue( 0.85, 0.05, 0); // SliceNumActor->SetPosition(479,25) ; // textActor->SetPosition(Cutpicker->GetSelectionPoint()[0], // Cutpicker->GetSelectionPoint()[1]); // double* fSelectionPoint=picker->GetSelectionPoint(); // textActor->VisibilityOn(); ren->AddActor2D(SliceNumActor); SliceZvalueMapper->GetTextProperty()->SetFontFamilyToArial(); SliceZvalueMapper->GetTextProperty()->SetFontSize(20); SliceZvalueMapper->GetTextProperty()->BoldOn(); SliceZvalueMapper->GetTextProperty()->ShadowOff(); SliceZvalueMapper->GetTextProperty()->ItalicOff(); SliceZvalueMapper->GetTextProperty()->SetVerticalJustificationToBottom(); SliceZvalueMapper->GetTextProperty()->SetColor(0,1,0); SliceZvalueActor->SetMapper(SliceZvalueMapper); QString sSliceZvalue; sSliceZvalue.sprintf("CT Coronal: %.3f", 0.0f); SliceZvalueMapper->SetInput(sSliceZvalue.toAscii ()); SliceZvalueActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay(); SliceZvalueActor->GetPositionCoordinate()->SetValue( 0.05, 0.05, 0); ren->AddActor2D(SliceZvalueActor); DrawAxialLine(fScale); DrawSagittalLine(fScale); DrawFrameRect(renWin); SetCamera(); renWin->Render(); greyPlane->GetOutput()->ReleaseDataFlagOn(); greyTransform->GetOutput()->ReleaseDataFlagOn(); greyPadder->GetOutput()->ReleaseDataFlagOn(); }
virtual void DrawWidget(const Rect &r, int widget) const { if (widget != CW_PANEL) return; int y = r.top + WD_FRAMERECT_TOP + this->header_height; DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, y, STR_CHEATS_WARNING, TC_FROMSTRING, SA_CENTER); bool rtl = _current_text_dir == TD_RTL; uint box_left = rtl ? r.right - 12 : r.left + 5; uint button_left = rtl ? r.right - 40 : r.left + 20; uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT: 50); uint text_right = r.right - (rtl ? 50 : WD_FRAMERECT_RIGHT); for (int i = 0; i != lengthof(_cheats_ui); i++) { const CheatEntry *ce = &_cheats_ui[i]; DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + 2); switch (ce->type) { case SLE_BOOL: { bool on = (*(bool*)ce->variable); DrawFrameRect(button_left, y + 1, button_left + 20 - 1, y + FONT_HEIGHT_NORMAL - 1, on ? COLOUR_GREEN : COLOUR_RED, on ? FR_LOWERED : FR_NONE); SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF); break; } default: { int32 val = (int32)ReadValue(ce->variable, ce->type); char buf[512]; /* Draw [<][>] boxes for settings of an integer-type */ DrawArrowButtons(button_left, y, COLOUR_YELLOW, clicked - (i * 2), true, true); switch (ce->str) { /* Display date for change date cheat */ case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break; /* Draw coloured flag for change company cheat */ case STR_CHEAT_CHANGE_COMPANY: { SetDParam(0, val + 1); GetString(buf, STR_CHEAT_CHANGE_COMPANY, lastof(buf)); uint offset = 10 + GetStringBoundingBox(buf).width; DrawCompanyIcon(_local_company, rtl ? text_right - offset - 10 : text_left + offset, y + 2); break; } /* Set correct string for switch climate cheat */ case STR_CHEAT_SWITCH_CLIMATE: val += STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE; /* FALL THROUGH */ default: SetDParam(0, val); } break; } } DrawString(text_left, text_right, y + 1, ce->str); y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; } }
void DrawActiveBorder() { DrawFrameRect(m_SurfaceID, 0, 0, m_Width, m_Height, m_SurfaceActivated ? 0xFF5E8AFF : 0xFFAAAAAA); }
/** * Draws an image of a whole train * @param v Front vehicle * @param left The minimum horizontal position * @param right The maximum horizontal position * @param y Vertical position to draw at * @param selection Selected vehicle to draw a frame around * @param skip Number of pixels to skip at the front (for scrolling) * @param drag_dest The vehicle another one is dragged over, \c INVALID_VEHICLE if none. */ void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest) { bool rtl = _current_text_dir == TD_RTL; Direction dir = rtl ? DIR_E : DIR_W; DrawPixelInfo tmp_dpi, *old_dpi; /* Position of highlight box */ int highlight_l = 0; int highlight_r = 0; int max_width = right - left + 1; int height = ScaleGUITrad(14); if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, height)) return; old_dpi = _cur_dpi; _cur_dpi = &tmp_dpi; int px = rtl ? max_width + skip : -skip; bool sel_articulated = false; bool dragging = (drag_dest != INVALID_VEHICLE); bool drag_at_end_of_train = (drag_dest == v->index); // Head index is used to mark dragging at end of train. for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->Next()) { if (dragging && !drag_at_end_of_train && drag_dest == v->index) { /* Highlight the drag-and-drop destination inside the train. */ int drag_hlight_width = HighlightDragPosition(px, max_width, selection, _cursor.vehchain); px += rtl ? -drag_hlight_width : drag_hlight_width; } Point offset; int width = Train::From(v)->GetDisplayImageWidth(&offset); if (rtl ? px + width > 0 : px - width < max_width) { PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); VehicleSpriteSeq seq; v->GetImage(dir, image_type, &seq); seq.Draw(px + (rtl ? -offset.x : offset.x), height / 2 + offset.y, pal, v->vehstatus & VS_CRASHED); } if (!v->IsArticulatedPart()) sel_articulated = false; if (v->index == selection) { /* Set the highlight position */ highlight_l = rtl ? px - width : px; highlight_r = rtl ? px - 1 : px + width - 1; sel_articulated = true; } else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) { if (rtl) { highlight_l -= width; } else { highlight_r += width; } } px += rtl ? -width : width; } if (dragging && drag_at_end_of_train) { /* Highlight the drag-and-drop destination at the end of the train. */ HighlightDragPosition(px, max_width, selection, _cursor.vehchain); } if (highlight_l != highlight_r) { /* Draw the highlight. Now done after drawing all the engines, as * the next engine after the highlight could overlap it. */ DrawFrameRect(highlight_l, 0, highlight_r, height - 1, COLOUR_WHITE, FR_BORDERONLY); } _cur_dpi = old_dpi; }