void St1_QMStateDiscrete::go(const shared_ptr<State>& state, const shared_ptr<Material>& mat, const Body* b) { QMStateDiscrete* qms = static_cast <QMStateDiscrete*>(state.get()); shared_ptr<QMParameters> par = YADE_PTR_DYN_CAST<QMParameters>(mat); QMGeometry* qmg = dynamic_cast<QMGeometry* >(b->shape.get()); if(!par or !qmg) { std::cerr << "ERROR: St1_QMStateDiscrete::go : No material, no geometry. Cannot proceed."; exit(1);}; size_t dim = par->dim; if(dim > 3) { throw std::runtime_error("\n\nERROR: St1_QMStateDiscrete::go does not work with dim > 3.\n\n");}; if(not qms->wasGenerated) { std::vector<Real> sizeNew(dim); for(size_t i=0 ; i<dim ; i++) sizeNew[i]=(qmg->extents[i]*2.0); qms->setSpatialSize(sizeNew); if(qms->isAnalytic() and qms->gridSize.size() == 0) { qms->gridSize.resize(par->dim,7); // fist run on analytic may need to pick arbitrarily some gridSize, if it wasn't defined by user // use '7' as default to make it apparent ↓ if it was defined, then use it for(size_t i=0 ; i < qms->gridSize.size() ; i++) if(qmg->step[i]>0) qms->gridSize[i]=size_t(qms->getSpatialSize()[i]/qmg->step[i]); // need to recalculate step, because of rounding errors for gridSize for(size_t i=0 ; i < qms->gridSize.size() ; i++) qmg->step[i]=qms->getSpatialSize()[i]/((Real)(qms->gridSize[i])); } //HERE2; this->calculateTableValuesPosition(par,dynamic_cast<QMState*>(qms)); try { qms->setMaterialAndGenerator(par,shared_from_this()); } catch(const boost::bad_weak_ptr& e) { // FIXME - serialization of StateDispatcher gone wrong? std::cerr << "St1_QMStateDiscrete::go() exception boost::bad_weak_ptr, there's no shared_ptr to this="<<this<<" class. FIXME:I see it in StateDispatcher, why??. Serialization gone wrong?\n"; } } else if(qms->isAnalytic() and this->changesWithTime()) { //HERE2; qms->wasGenerated = false;// keep on calculating, since it is analytic this->calculateTableValuesPosition(par,qms); } }
BOOL CRectItem::UpdateExtent() { // get size in pixels CSize size; if (!GetCachedExtent(&size)) return FALSE; // blank Invalidate(); // invalidate the old size/position CSize sizeBase = GetBaseSize(); if (size == sizeBase) // no change return FALSE; // if new object (i.e. m_extent is empty) setup position if (sizeBase == CSize(0,0)) { // convert to document coords CSize sizeNew(MulDiv(size.cx, 10, 254), - MulDiv(size.cy, 10, 254)); SetSize(sizeNew); } else { if (!IsInPlaceActive() && size != sizeBase) { // data changed and not inplace, so scale up rect as well CSize sizeCur = GetSize(); sizeCur.cx = MulDiv(sizeCur.cx, size.cx, sizeBase.cx); sizeCur.cy = - MulDiv(-sizeCur.cy, size.cy, sizeBase.cy); SetSize(sizeCur); } } SetBaseSize(size); Invalidate(); // as well as the new size/position return TRUE; }
void CLogDialog::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); CSize sizeNew(cx, cy); if(m_bInit) { CRect rcBtn; m_rcEdit.BottomRight() = sizeNew - m_ptEdit; m_wndOutput.MoveWindow(&m_rcEdit); rcBtn = m_rcButton + sizeNew; m_wndCancel.MoveWindow(&rcBtn); } }
void CExtAviLabel::DoPaint( CDC * pDC, CRect & rcClient ) { ASSERT_VALID( this ); CSize sizeClient = rcClient.Size(); if( sizeClient.cx <= 0 || sizeClient.cy <= 0 ) return; if( ! ::RectVisible( pDC->GetSafeHdc(), &rcClient ) ) return; CExtMemoryDC dc( pDC, &rcClient ); CRgn rgnClient; if( rgnClient.CreateRectRgnIndirect( &rcClient ) ) dc.SelectClipRgn( &rgnClient ); OnEraseBackground( dc, rcClient ); if( ( ! AviIsEmpty() ) && ( m_bSeek || m_bPlaying || ( ( ! m_bPlaying ) && ( ( AviStyleGet() & __EXT_AVI_EMPTY_BACKGROUND_ON_STOP ) == 0 ) ) ) ) { // OnAviPaintCurrentFrame( dc, rcClient, m_sizeAvi ); DWORD dwWndStyle = GetStyle(); DWORD dwWndType = (dwWndStyle&SS_TYPEMASK); bool bCenterImage = ( (dwWndStyle&SS_CENTERIMAGE) != 0 ); e_ImageMode_t eImageMode = GetImageMode(); if( eImageMode == eStretch ) { CSize sizeAvi = rcClient.Size(); OnAviPaintCurrentFrame( dc, rcClient, sizeAvi ); } else if( eImageMode == eTouchInside || eImageMode == eTouchOutside ) { CRect rcTouchSurface = rcClient; CExtMemoryDC dcTouch( &dc, rcTouchSurface, CExtMemoryDC::MDCOPT_TO_MEMORY|CExtMemoryDC::MDCOPT_FILL_BITS|CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY ); if( dcTouch.GetSafeHdc() ) { CSize sizeTouchSrc = rcTouchSurface.Size(); CSize sizeBmp = m_sizeAvi; double lfAspectX = double(rcTouchSurface.Width()) / double(sizeBmp.cx); double lfAspectY = double(rcTouchSurface.Height()) / double(sizeBmp.cy); double lfAspect = ( eImageMode == eTouchInside ) ? ( min( lfAspectX, lfAspectY ) ) : ( max( lfAspectX, lfAspectY ) ); CSize sizeNew( LONG(double(sizeBmp.cx)*lfAspect), LONG(double(sizeBmp.cy)*lfAspect) ); CRect rcTouchDst( rcTouchSurface.left, rcTouchSurface.top, rcTouchSurface.left + sizeNew.cx, rcTouchSurface.top + sizeNew.cy ); if( eImageMode == eTouchInside ) { if( sizeNew.cx > sizeTouchSrc.cx ) rcTouchDst.OffsetRect( ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 ); if( sizeNew.cy > sizeTouchSrc.cy ) rcTouchDst.OffsetRect( 0, ( sizeNew.cy - sizeTouchSrc.cy ) / 2 ); } else { rcTouchDst.OffsetRect( - ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 ); rcTouchDst.OffsetRect( 0, - ( sizeNew.cy - sizeTouchSrc.cy ) / 2 ); } CSize sizeAvi = rcTouchDst.Size(); OnAviPaintCurrentFrame( dcTouch, rcTouchDst, sizeAvi ); } } else if( eImageMode == eTile ) { UINT nStepCountH = sizeClient.cx / m_sizeAvi.cx + ( ( sizeClient.cx % m_sizeAvi.cx ) ? 1 : 0 ); UINT nStepCountV = sizeClient.cy / m_sizeAvi.cy + ( ( sizeClient.cy % m_sizeAvi.cy ) ? 1 : 0 ); if( nStepCountH > 0 && nStepCountV > 0 ) { UINT nStepIndexH, nStepIndexV; for( nStepIndexV = 0; nStepIndexV < nStepCountV; nStepIndexV ++ ) { CRect rcWalk( rcClient.TopLeft(), m_sizeAvi ); rcWalk.OffsetRect( 0, m_sizeAvi.cy * nStepIndexV ); for( nStepIndexH = 0; nStepIndexH < nStepCountH; nStepIndexH ++ ) { if( ::RectVisible( dc.GetSafeHdc(), &rcWalk ) ) OnAviPaintCurrentFrame( dc, rcWalk, m_sizeAvi ); rcWalk.OffsetRect( m_sizeAvi.cx, 0 ); } } } } else if( eImageMode == eAlign ) { CRect rcDst( rcClient.left, rcClient.top, rcClient.left + m_sizeAvi.cx, rcClient.top + m_sizeAvi.cy ); bool bCenterHorizontally = false; switch( dwWndType ) { case SS_RIGHT: rcDst.OffsetRect( rcClient.right - rcDst.right, 0 ); break; case SS_CENTER: bCenterHorizontally = true; break; default: /* all the other types assumed as left */ break; } if( bCenterHorizontally ) rcDst.OffsetRect( ( (rcClient.right - rcClient.left) - (rcDst.right - rcDst.left) ) / 2, 0 ); if( bCenterImage ) rcDst.OffsetRect( 0, ( (rcClient.bottom - rcClient.top) - (rcDst.bottom - rcDst.top) ) / 2 ); OnAviPaintCurrentFrame( dc, rcDst, m_sizeAvi ); } } PmBridge_GetPM()->OnPaintSessionComplete( this ); if( rgnClient.GetSafeHandle() != NULL ) dc.SelectClipRgn( &rgnClient ); }
void CExtLabel::DoPaint( CDC * pDC, CRect & rcClient ) { ASSERT_VALID( this ); ASSERT_VALID( pDC ); CExtMemoryDC dc( pDC, &rcClient ); CRgn rgnClient; if( rgnClient.CreateRectRgnIndirect( &rcClient ) ) dc.SelectClipRgn( &rgnClient ); OnEraseBackground( dc, rcClient ); DWORD dwWndStyle = GetStyle(); DWORD dwWndType = (dwWndStyle&SS_TYPEMASK); bool bCenterImage = ( (dwWndStyle&SS_CENTERIMAGE) != 0 ); if( ! m_bmp.IsEmpty() ) { bool bSmootherAsPossible = true; e_ImageMode_t eImageMode = GetImageMode(); if( eImageMode == eStretch ) m_bmp.AlphaBlendSkinParts( dc.GetSafeHdc(), rcClient, CRect(0,0,0,0), CExtBitmap::__EDM_STRETCH, true, bSmootherAsPossible ); else if( eImageMode == eTouchInside || eImageMode == eTouchOutside ) { CRect rcTouchSurface = rcClient; CExtMemoryDC dcTouch( &dc, rcTouchSurface, CExtMemoryDC::MDCOPT_TO_MEMORY|CExtMemoryDC::MDCOPT_FILL_BITS|CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY ); if( dcTouch.GetSafeHdc() ) { CSize sizeTouchSrc = rcTouchSurface.Size(); CSize sizeBmp = m_bmp.GetSize(); double lfAspectX = double(rcTouchSurface.Width()) / double(sizeBmp.cx); double lfAspectY = double(rcTouchSurface.Height()) / double(sizeBmp.cy); double lfAspect = ( eImageMode == eTouchInside ) ? ( min( lfAspectX, lfAspectY ) ) : ( max( lfAspectX, lfAspectY ) ); CSize sizeNew( LONG(double(sizeBmp.cx)*lfAspect), LONG(double(sizeBmp.cy)*lfAspect) ); CRect rcTouchDst( rcTouchSurface.left, rcTouchSurface.top, rcTouchSurface.left + sizeNew.cx, rcTouchSurface.top + sizeNew.cy ); if( eImageMode == eTouchInside ) { if( sizeNew.cx > sizeTouchSrc.cx ) rcTouchDst.OffsetRect( ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 ); if( sizeNew.cy > sizeTouchSrc.cy ) rcTouchDst.OffsetRect( 0, ( sizeNew.cy - sizeTouchSrc.cy ) / 2 ); } else { rcTouchDst.OffsetRect( - ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 ); rcTouchDst.OffsetRect( 0, - ( sizeNew.cy - sizeTouchSrc.cy ) / 2 ); } INT nOldStretchBltMode = bSmootherAsPossible ? ( ::GetStretchBltMode( dcTouch.m_hDC ) ) : ( COLORONCOLOR ) ; if( bSmootherAsPossible ) ::SetStretchBltMode( dcTouch.m_hDC, ( g_PaintManager.m_bIsWinNT ) ? HALFTONE : COLORONCOLOR ); m_bmp.AlphaBlend( dcTouch.m_hDC, rcTouchDst ); if( bSmootherAsPossible ) ::SetStretchBltMode( dcTouch.m_hDC, nOldStretchBltMode ); } } else if( eImageMode == eTile ) m_bmp.AlphaBlendSkinParts( dc.GetSafeHdc(), rcClient, CRect(0,0,0,0), CExtBitmap::__EDM_TILE, true, bSmootherAsPossible ); else if( eImageMode == eAlign ) { CSize szSize = m_bmp.GetSize(); CRect rcDst( rcClient.left, rcClient.top, rcClient.left + szSize.cx, rcClient.top + szSize.cy ); bool bCenterHorizontally = false; switch( dwWndType ) { case SS_RIGHT: rcDst.OffsetRect( rcClient.right - rcDst.right, 0 ); break; case SS_CENTER: bCenterHorizontally = true; break; default: /* all the other types assumed as left */ break; } if( bCenterHorizontally ) rcDst.OffsetRect( ( (rcClient.right - rcClient.left) - (rcDst.right - rcDst.left) ) / 2, 0 ); if( bCenterImage ) rcDst.OffsetRect( 0, ( (rcClient.bottom - rcClient.top) - (rcDst.bottom - rcDst.top) ) / 2 ); CRect rcSrc( 0, 0, szSize.cx, szSize.cy ); rcDst.top = max( rcDst.top, rcClient.top ); rcDst.left = max( rcDst.left, rcClient.left ); rcDst.bottom = min( rcDst.bottom, rcClient.bottom ); rcDst.right = min( rcDst.right, rcClient.right ); if( ::RectVisible( dc.GetSafeHdc(), &rcDst ) ) { INT nOldStretchBltMode = bSmootherAsPossible ? ( ::GetStretchBltMode( dc.m_hDC ) ) : ( COLORONCOLOR ); if( bSmootherAsPossible ) ::SetStretchBltMode( dc.m_hDC, ( g_PaintManager.m_bIsWinNT ) ? HALFTONE : COLORONCOLOR ); m_bmp.AlphaBlend( dc.m_hDC, rcDst, rcSrc ); if( bSmootherAsPossible ) ::SetStretchBltMode( dc.m_hDC, nOldStretchBltMode ); } } } else if( dwWndType == SS_ICON ) { HICON hIcon = GetIcon(); if( hIcon != NULL ) { CExtCmdIcon _icon; _icon.AssignFromHICON( hIcon, true ); CSize szIcon = _icon.GetSize(); int nOffsetX = bCenterImage ? (rcClient.Width() - szIcon.cx) / 2 : 0; int nOffsetY = bCenterImage ? (rcClient.Height() - szIcon.cy) / 2 : 0; _icon.Paint( PmBridge_GetPM(), dc.GetSafeHdc(), rcClient.left + nOffsetX, rcClient.top + nOffsetY, -1, -1, IsWindowEnabled() ? CExtCmdIcon::__PAINT_NORMAL : CExtCmdIcon::__PAINT_DISABLED ); } } else { CExtSafeString strText; int nTextLen = GetWindowTextLength(); if( nTextLen > 0 ) { GetWindowText( strText.GetBuffer( nTextLen + 2 ), nTextLen + 1 ); strText.ReleaseBuffer(); } if( strText.GetLength() > 0 ) { DWORD dwDrawTextFlags = 0; switch( dwWndType ) { case SS_RIGHT: dwDrawTextFlags = DT_RIGHT; break; case SS_CENTER: dwDrawTextFlags = DT_CENTER; break; case SS_LEFTNOWORDWRAP: dwDrawTextFlags = DT_LEFT; break; default: /* all the other types assumed as left */ dwDrawTextFlags = DT_LEFT; break; } // switch( dwWndType ) if( strText.Find( _T('\t') ) != -1 ) // do tabs expanding dwDrawTextFlags |= DT_EXPANDTABS; if( (dwWndType == SS_SIMPLE) || (dwWndStyle&(SS_CENTERIMAGE|SS_ENDELLIPSIS|SS_PATHELLIPSIS)) != 0 ) { dwDrawTextFlags |= DT_SINGLELINE; if( (dwWndStyle&SS_CENTERIMAGE) != 0 ) dwDrawTextFlags |= DT_VCENTER; if( (dwWndStyle&SS_ENDELLIPSIS) != 0 ) dwDrawTextFlags |= DT_END_ELLIPSIS; if( (dwWndStyle&SS_PATHELLIPSIS) != 0 ) dwDrawTextFlags |= DT_PATH_ELLIPSIS; } else dwDrawTextFlags |= DT_WORDBREAK; if( dwWndType == SS_LEFTNOWORDWRAP ) dwDrawTextFlags &= ~(DT_WORDBREAK|DT_SINGLELINE); if( (dwWndStyle&SS_NOPREFIX) != 0 ) dwDrawTextFlags |= DT_NOPREFIX; bool bEnabled = IsWindowEnabled() ? true : false; OnDrawLabelText( dc, rcClient, strText, dwDrawTextFlags, bEnabled ); } // if( strText.GetLength() > 0 ) } PmBridge_GetPM()->OnPaintSessionComplete( this ); if( rgnClient.GetSafeHandle() != NULL ) dc.SelectClipRgn( &rgnClient ); }