void WidgetBase::setView (ViewNumber::Enum viewNumber, const G3D::Vector2& clickedPoint) { G3D::Rect2D viewRect = GetViewRect (viewNumber); if (viewRect.contains (clickedPoint)) GetSettingsPtr ()->SetViewNumber (viewNumber); }
void Light_Manager::DrawWallShadow(sf::RenderTarget *App,sf::View *camera,float angle,Lumiere soleil) { angle-=90; sf::Vector2f vect(cos(angle*M_PI/180) * (100-soleil.hauteur) * 0.02, sin(angle*M_PI/180) * (100-soleil.hauteur) * 0.01); for(int y = GetViewRect(*camera).top * 2 / SECTOR_SIZE + m_origin_sector.y - 1; y < (GetViewRect(*camera).top * 2 + GetViewRect(*camera).height * 2) / SECTOR_SIZE + 1 + m_origin_sector.y; ++y) if(y >= 0 && y < (int)m_sectors.size()) for(int x = GetViewRect(*camera).left / SECTOR_SIZE + m_origin_sector.x - 1; x < (GetViewRect(*camera).left + GetViewRect(*camera).width) / SECTOR_SIZE + 1 + m_origin_sector.x; ++x) if(x >= 0 && x < (int)m_sectors[y].size()) for (std::vector<int>::iterator IterWall=m_sectors[y][x].begin(); IterWall!=m_sectors[y][x].end();++IterWall) { m_wall[*IterWall].m_shadow[0] = sf::Vertex(sf::Vector2f(m_wall[*IterWall].pt2.x,m_wall[*IterWall].pt2.y*0.5),sf::Color(0,0,0,(int)(255))); m_wall[*IterWall].m_shadow[1] = sf::Vertex(sf::Vector2f(m_wall[*IterWall].pt1.x,m_wall[*IterWall].pt1.y*0.5),sf::Color(0,0,0,(int)(255))); m_wall[*IterWall].m_shadow[2] = sf::Vertex(sf::Vector2f(m_wall[*IterWall].pt1.x-m_wall[*IterWall].hauteur1 * vect.x, m_wall[*IterWall].pt1.y*0.5+m_wall[*IterWall].hauteur1 * vect.y),sf::Color(0,0,0,(int)(255))); m_wall[*IterWall].m_shadow[3] = sf::Vertex(sf::Vector2f(m_wall[*IterWall].pt2.x-m_wall[*IterWall].hauteur2 * vect.x, m_wall[*IterWall].pt2.y*0.5+m_wall[*IterWall].hauteur2 * vect.y),sf::Color(0,0,0,(int)(255))); App->draw(m_wall[*IterWall].m_shadow, 4, sf::Quads); } }
void WidgetBase::contextMenuEvent (QContextMenuEvent *event) { QMenu menu (m_widget); ViewNumber::Enum viewNumber = GetViewNumber (); const ViewSettings& vs = GetViewSettings (viewNumber); size_t property = vs.GetBodyOrOtherScalar (); QPoint contextMenuPosWindow = event->pos (); if (vs.IsScalarShown () && property != OtherScalar::DMP_COLOR && ! vs.IsScalarContext () && GetSettings ().GetColorMapScalarRectWithLabels ( viewNumber, GetViewRect ()).contains ( QtToOpenGl (contextMenuPosWindow, m_widget->height ()))) contextMenuEventColorMapScalar (&menu); else if (vs.IsVelocityShown () && GetSettings ().GetColorMapVelocityRectWithLabels ( viewNumber, GetViewRect ()).contains ( QtToOpenGl (contextMenuPosWindow, m_widget->height ()))) contextMenuEventColorMapVelocity (&menu); else contextMenuEventView (&menu); menu.exec (event->globalPos()); }
// On affiche toutes les lumières actives void Light_Manager::Draw(sf::RenderTarget *App,sf::View *camera) { for (Iter=m_DynamicLight.begin();Iter!=m_DynamicLight.end();++Iter) if (Iter->m_actif) if (Iter->GetPosition().x + Iter->GetRadius() > GetViewRect(*camera).left && Iter->GetPosition().x - Iter->GetRadius() < GetViewRect(*camera).left + GetViewRect(*camera).width && Iter->GetPosition().y + Iter->GetRadius() > 2 * GetViewRect(*camera).top && Iter->GetPosition().y - Iter->GetRadius() < 2 * (GetViewRect(*camera).top + GetViewRect(*camera).height)) Iter->Draw(App); for (Iter=m_StaticLight.begin();Iter!=m_StaticLight.end();++Iter) if (Iter->m_actif) if (Iter->GetPosition().x + Iter->GetRadius() > GetViewRect(*camera).left && Iter->GetPosition().x - Iter->GetRadius() < GetViewRect(*camera).left + GetViewRect(*camera).width && Iter->GetPosition().y + Iter->GetRadius() > 2 * GetViewRect(*camera).top && Iter->GetPosition().y - Iter->GetRadius() < 2 * (GetViewRect(*camera).top + GetViewRect(*camera).height)) Iter->Draw(App); }
void CMainFrame::OnInitialUpdate() { // Set the styles for splitter panes DWORD dwStyle = DS_NO_UNDOCK | DS_NO_CAPTION | DS_CLIENTEDGE; SetDockStyle(dwStyle); CRect rcView = GetViewRect(); // Add the bottom pane first. It is a child of the main pane. m_pDockTree = static_cast<CDockTree*>(AddDockedChild(new CDockTree, dwStyle|DS_DOCKED_BOTTOM, rcView.Height()/2)); // Add the bottom right pane. It is a child of the bottom pane m_pDockList = static_cast<CDockList*>(m_pDockTree->AddDockedChild(new CDockList, dwStyle|DS_DOCKED_RIGHT, rcView.Width()/2)); // Add the top right pane. It is a child of the main pane. m_pDockText = static_cast<CDockText*>(AddDockedChild(new CDockText, dwStyle|DS_DOCKED_RIGHT, rcView.Width()/2)); }
// Updated version of the lens flare render. void Render( Context * pcontext ) { m_vec = Vector(0, 0, 1); const Rect& rect = GetViewRect()->GetValue(); Point pointCenter = rect.Center(); float scale = rect.XSize() / 800.0f; Point pointLight; if( GetCamera()->TransformDirectionToImage( m_vec, pointLight )) { pointLight = rect.TransformNDCToImage(pointLight); if( rect.Inside( pointLight ) ) { pointLight = pointLight - pointCenter; pcontext->SetBlendMode(BlendModeAdd); pcontext->SetShadeMode(ShadeModeFlat); pcontext->Translate(pointCenter); int count = ArrayCount(g_lensFlareData); for(int index = 0; index < count; index++) { pcontext->PushState(); pcontext->Translate(pointLight * g_lensFlareData[index].m_pos); pcontext->Scale2(scale * g_lensFlareData[index].m_scale); float angle = 0; int indexSurface = g_lensFlareData[index].m_index; if (indexSurface == 1) { pcontext->Rotate((pointLight.X() + pointLight.Y()) / 200.0f); } pcontext->DrawImage3D(m_psurfaces[indexSurface], g_lensFlareData[index].m_color, true); pcontext->PopState(); } } } }
void CBeatDetectView::OnDraw(CDC* pDC) { CBeatDetectDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); RECT rcView; GetViewRect( &rcView ); CList<CDataStream*,CDataStream*> lstStream; HRESULT hr = CreateStreamsList( &lstStream ); if( S_OK == hr ) { ////////////////// // Draw Time Ruler RECT rcRuler = rcView; rcRuler.bottom = rcRuler.top + RULER_HEIGHT; rcView.top = rcRuler.bottom; DrawTimeRuler( pDC, &rcRuler ); ////////////////// // Draw Data Streams // Determine rects for drawing streams INT32 nStreams = lstStream.GetCount(); INT32 nStreamHeight = rcView.bottom/nStreams; RECT rcStream = rcView; rcStream.bottom = rcStream.top + nStreamHeight; POSITION pos = lstStream.GetHeadPosition(); while( pos != NULL ) { CDataStream* pStrm = lstStream.GetNext(pos); // Draw DrawStream( pDC, pStrm, &rcStream ); // Offset stream rect OffsetRect( &rcStream, 0, nStreamHeight ); } } ////////////////// }
void Render(Context* pcontext) { Rect rect = GetViewRect()->GetValue(); pcontext->Translate(rect.Center()); pcontext->Scale2(0.5f * rect.XSize()); pcontext->Begin3DLayer(GetCamera(), false); #ifndef FixPermedia pcontext->SetShadeMode(ShadeModeCopy); #endif pcontext->SetShadeMode(ShadeModeGlobalColor); pcontext->SetGlobalColor( Color::White() ); pcontext->SetBlendMode( BlendModeAlphaStampThrough ); TList<PosterData, DefaultNoEquals>::Iterator iter(m_list); while (!iter.End()) { PosterData& data = iter.Value(); Point point; if (pcontext->TransformDirectionToImage(data.m_vec, point)) { pcontext->SetTexture(data.m_pimage->GetSurface()); pcontext->PushState(); pcontext->Multiply(data.m_mat); #ifdef FixPermedia Geo::GetWhiteEmissiveSquare()->Render(pcontext); #else Geo::GetSquare()->Render(pcontext); #endif pcontext->PopState(); } iter.Next(); } pcontext->End3DLayer(); }
void CBeatDetectView::OnSize ( UINT nType, int cx, int cy ) { CScrollView::OnSize(nType, cx, cy); ////////// // Make vertical dimension equal to client size... SIZE szTotal; RECT rcView; GetViewRect(&rcView); szTotal.cx = rcView.right; RECT rcWnd; GetClientRect(&rcWnd); szTotal.cy = rcWnd.bottom-rcWnd.top; SetScrollSizes(MM_TEXT, szTotal); ////////// }
void Render(Context* pcontext) { int count = m_data.GetCount(); if (count > 0) { Camera* pcamera = GetCamera(); float focus = pcamera->GetFocus(); const Rect& rect = GetViewRect()->GetValue(); float scale = focus * rect.XSize() / 2; float xc = rect.Center().X(); float yc = rect.Center().Y(); const Orientation& orient = GetCamera()->GetOrientation(); VertexScreen* pvertex = pcontext->GetVertexScreenBuffer(count * 2); WORD* pindex = pcontext->GetIndexBuffer(count * 2); int index = 0; int indexPoint = count * 2; for(int indexSource = 0; indexSource < count; indexSource++) { StarData& data = m_data.Get(indexSource); Color& color = data.m_color; Vector& direction = data.m_direction; Point& pointOld = data.m_pointOld; // // orient the start based on the current camera // Vector vec = orient.TimesInverse(direction); // // fold up the stars for higher density // if (vec.z > 0) { vec.SetX(-vec.X()); vec.SetY(-vec.Y()); vec.SetZ(-vec.Z()); } // // project the star onto the screen // float x = (float)(int)(scale * vec.X() + xc); float y = (float)(int)(yc - scale * vec.Y()); float xold; float yold; if (data.m_bFirstFrame) { xold = x; yold = y; data.m_bFirstFrame = false; } else { xold = pointOld.X(); yold = pointOld.Y(); } if (rect.Inside(Point(x, y))) { float dx = abs(x - xold); float dy = abs(y - yold); float length = dx + dy; if (length <= 1.0f) { // // Draw a point // indexPoint--; pvertex[indexPoint].x = x; pvertex[indexPoint].y = y; pvertex[indexPoint].z = 0; pvertex[indexPoint].qw = (float)1.0f/10000.0f; pvertex[indexPoint].color = MakeD3DCOLOR(color); pvertex[indexPoint].specular = 0; } else { // // Draw a line // if (length > 16.0f) { float scale = 16.0f / length; xold = x + (xold - x) * scale; yold = y + (yold - y) * scale; } if (rect.Inside(Point(xold, yold))) { float alpha = 1.0f - 0.1f * length; if (alpha < 0.25f) { alpha = 0.25f; } pvertex[index * 2].x = x; pvertex[index * 2].y = y; pvertex[index * 2].z = 0; pvertex[index * 2].qw = (float)1.0f/10000.0f; pvertex[index * 2].color = MakeD3DCOLOR(color * alpha); pvertex[index * 2].specular = 0; pvertex[index * 2 + 1].x = xold; pvertex[index * 2 + 1].y = yold; pvertex[index * 2 + 1].z = 0; pvertex[index * 2 + 1].qw =(float)1.0f/10000.0f; pvertex[index * 2 + 1].color = MakeD3DCOLOR(color * alpha); pvertex[index * 2 + 1].specular = 0; pindex[index * 2 ] = index * 2; pindex[index * 2 + 1] = index * 2 + 1; index += 1; } } } pointOld.SetX(x); pointOld.SetY(y); }; // // Do the rendering // pcontext->SetShadeMode(ShadeModeFlat); pcontext->DrawPoints(pvertex + indexPoint, count * 2 - indexPoint); if (index != 0) { pcontext->SetBlendMode(BlendModeAdd); pcontext->DrawLines(pvertex, index * 2, pindex, index * 2); } } }
void CSynAoiDimObj::SetEyeSight( float fEyeSight ) { if(fEyeSight < 0) { GenErr("AOI的EyeSight不允许设置小于0的值"); } if (fabs(m_fEyeSight - fEyeSight) < 0.01) { return; } //第一次view rect加入quad tree if (m_fEyeSight == 0 && !m_pViewRectNode) { m_fEyeSight = fEyeSight; //设置aoi的view rect SetViewRect(m_Pos, GetScene()->GetSceneBox()); static VecDimObject_t vecMyObject; vecMyObject.clear(); QueryObserveeWithViewRect(vecMyObject); UpdateSeeRelationForMyEnterObject(vecMyObject); GetScene()->InsertViewRectToQuad(this); return; } //如果eye sight为0,则把view rect从quad tree中删除 if (fEyeSight == 0 && m_pViewRectNode) { static VecDimObject_t vecMyObject; vecMyObject.clear(); GetScene()->RemoveViewRectFrQuad(this); QueryObserveeWithViewRect(vecMyObject); UpdateSeeRelationForMyLeaveObject(vecMyObject,GetPosition()); m_fEyeSight = 0; return; } if(fEyeSight > m_fEyeSight) { //如果新设置的eye sight大于以前的eye sight,那么我就会看见一些新的对象 static VecDimObject_t vecMyObjEnter; vecMyObjEnter.clear(); float OldEyeSight = m_fEyeSight; CFRect OldRect = GetViewRect(); m_fEyeSight = fEyeSight; GetScene()->SetAoiViewRect(this); //查找eye sight扩大之后,新能被我看见的对象 GetScene()->QueryObservee(this, vecMyObjEnter, m_rcViewRect, OldRect); UpdateSeeRelationForMyStayObject(m_Pos, OldEyeSight, fEyeSight); UpdateSeeRelationForMyEnterObject(vecMyObjEnter, fEyeSight); } else { static VecDimObject_t vecMyObjLeave; vecMyObjLeave.clear(); float OldEyeSight = m_fEyeSight; CFRect NewRect; GetRadiusRect(NewRect, m_Pos, fEyeSight, GetScene()->GetSceneBox()); //查找eye sight缩小以后,我先前能看见但是现在不能看见的对象 GetScene()->QueryObservee(this, vecMyObjLeave, m_rcViewRect, NewRect); m_fEyeSight = fEyeSight; GetScene()->SetAoiViewRect(this); UpdateSeeRelationForMyLeaveObject(vecMyObjLeave, m_Pos, OldEyeSight); UpdateSeeRelationForMyStayObject(m_Pos, OldEyeSight, fEyeSight); } }
// Layout tabs (optional, e.g. if resizing window) void wxTabView::LayoutTabs(void) { // Make a list of the tab controls, deleting the wxTabLayers. wxList controls; wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst(); while (layerNode) { wxTabLayer *layer = (wxTabLayer *)layerNode->GetData(); wxList::compatibility_iterator tabNode = layer->GetFirst(); while (tabNode) { wxTabControl *tab = (wxTabControl *)tabNode->GetData(); controls.Append(tab); wxList::compatibility_iterator next = tabNode->GetNext(); layer->Erase(tabNode); tabNode = next; } wxTabLayerList::compatibility_iterator nextLayerNode = layerNode->GetNext(); delete layer; m_layers.Erase(layerNode); layerNode = nextLayerNode; } wxTabControl *lastTab = NULL; wxTabLayer *currentLayer = new wxTabLayer; m_layers.Append(currentLayer); wxList::compatibility_iterator node = controls.GetFirst(); while (node) { wxTabControl *tabControl = (wxTabControl *)node->GetData(); if (lastTab) { // Start another layer (row). // Tricky choice: can't just check if will be overlapping the edge, because // this happens anyway for 2nd and subsequent rows. // Should check this for 1st row, and then subsequent rows should not exceed 1st // in length. if (((currentLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing()) > GetViewRect().width)) || ((currentLayer != m_layers.GetFirst()->GetData()) && (currentLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount()))) { currentLayer = new wxTabLayer; m_layers.Append(currentLayer); lastTab = NULL; } } int layer = m_layers.GetCount() - 1; tabControl->SetRowPosition(currentLayer->GetCount()); tabControl->SetColPosition(layer); // Top of new tab int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); // Offset from view top-left int horizontalOffset = 0; if (!lastTab) horizontalOffset = layer*GetHorizontalTabOffset(); else horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); tabControl->SetPosition(horizontalOffset, verticalOffset); tabControl->SetSize(GetTabWidth(), GetTabHeight()); currentLayer->Append(tabControl); lastTab = tabControl; node = node->GetNext(); } // Move the selected tab to the bottom wxTabControl *control = FindTabControlForId(m_tabSelection); if (control) MoveSelectionTab(control); }
bool RenderHandler::GetRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect) { return GetViewRect(browser, rect); }
void CSynAoiDimObj::QueryObserveeWithViewRect(VecDimObject_t& vecObject)const { CFRect Rect = GetViewRect(); GetScene()->QueryObservee(vecObject,Rect); }
void PixelInfoListCtrl::ResizeColumns() { wxSize sz = GetClientSize(); wxRect rc = GetViewRect(); SetColumnWidth( 1, sz.GetWidth() - GetColumnWidth( 0 ) - ( rc.GetHeight() > sz.GetHeight() ? 18 : 0 ) ); }
// Automatically positions tabs // TODO: this should just add the tab to a list, and then // a layout function (e.g. Realize) should be called when all tabs have been added. // The view rect could easily change as the view window is resized. wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *existingTab) { // First, find which layer we should be adding to. wxTabLayerList::compatibility_iterator node = m_layers.GetLast(); if (!node) { wxTabLayer *newLayer = new wxTabLayer; node = m_layers.Append(newLayer); } // Check if adding another tab control would go off the // right-hand edge of the layer. wxTabLayer *tabLayer = (wxTabLayer *)node->GetData(); wxList::compatibility_iterator lastTabNode = tabLayer->GetLast(); if (lastTabNode) { wxTabControl *lastTab = (wxTabControl *)lastTabNode->GetData(); // Start another layer (row). // Tricky choice: can't just check if will be overlapping the edge, because // this happens anyway for 2nd and subsequent rows. // Should check this for 1st row, and then subsequent rows should not exceed 1st // in length. if (((tabLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing()) > GetViewRect().width)) || ((tabLayer != m_layers.GetFirst()->GetData()) && (tabLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount()))) { tabLayer = new wxTabLayer; m_layers.Append(tabLayer); lastTabNode = wxList::compatibility_iterator(); } } int layer = m_layers.GetCount() - 1; wxTabControl *tabControl = existingTab; if (!existingTab) tabControl = OnCreateTabControl(); tabControl->SetRowPosition(tabLayer->GetCount()); tabControl->SetColPosition(layer); wxTabControl *lastTab = NULL; if (lastTabNode) lastTab = (wxTabControl *)lastTabNode->GetData(); // Top of new tab int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); // Offset from view top-left int horizontalOffset = 0; if (!lastTab) horizontalOffset = layer*GetHorizontalTabOffset(); else horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); tabControl->SetPosition(horizontalOffset, verticalOffset); tabControl->SetSize(GetTabWidth(), GetTabHeight()); tabControl->SetId(id); tabControl->SetLabel(label); tabControl->SetFont(* GetTabFont()); tabLayer->Append(tabControl); m_noTabs ++; return tabControl; }
bool RenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) { return GetViewRect(GetJNIBrowser(browser), rect); }
// Draw all tabs void wxTabView::Draw(wxDC& dc) { // Don't draw anything if there are no tabs. if (GetNumberOfTabs() == 0) return; // Draw top margin area (beneath tabs and above view area) if (GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) { dc.SetPen(*wxTRANSPARENT_PEN); if(GetBackgroundBrush()) dc.SetBrush(*GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. dc.DrawRectangle( m_tabViewRect.x, (m_tabViewRect.y - m_topMargin), (m_tabViewRect.width + 1), (m_topMargin + 1) ); } // Draw layers in reverse order wxTabLayerList::compatibility_iterator node = m_layers.GetLast(); while (node) { wxTabLayer *layer = (wxTabLayer *)node->GetData(); wxList::compatibility_iterator node2 = layer->GetFirst(); while (node2) { wxTabControl *control = (wxTabControl *)node2->GetData(); control->OnDraw(dc, (!node2->GetNext())); node2 = node2->GetNext(); } node = node->GetPrevious(); } #ifndef wxUSE_NEW_METHOD if (GetTabStyle() & wxTAB_STYLE_DRAW_BOX) { dc.SetPen(* GetShadowPen()); // Draw bottom line dc.DrawLine( (GetViewRect().x + 1), (GetViewRect().y + GetViewRect().height), (GetViewRect().x + GetViewRect().width + 1), (GetViewRect().y + GetViewRect().height) ); // Draw right line dc.DrawLine( (GetViewRect().x + GetViewRect().width), (GetViewRect().y - GetTopMargin() + 1), (GetViewRect().x + GetViewRect().width), (GetViewRect().y + GetViewRect().height) ); dc.SetPen(* wxBLACK_PEN); // Draw bottom line dc.DrawLine( (GetViewRect().x), (GetViewRect().y + GetViewRect().height + 1), #if defined(__WXMOTIF__) (GetViewRect().x + GetViewRect().width + 1), #else (GetViewRect().x + GetViewRect().width + 2), #endif (GetViewRect().y + GetViewRect().height + 1) ); // Draw right line dc.DrawLine( (GetViewRect().x + GetViewRect().width + 1), (GetViewRect().y - GetTopMargin()), (GetViewRect().x + GetViewRect().width + 1), (GetViewRect().y + GetViewRect().height + 1) ); } #endif }
void CMainFrame::OnDraw(CDC* pDC) { CRect rc = GetViewRect(); tString tsHello = LoadString(IDS_HELLO); pDC->DrawText(tsHello.c_str(), tsHello.length(), rc, DT_SINGLELINE | DT_VCENTER | DT_CENTER); }