void DFSCorrection::RecordTrajectories() { dfs_trace(dfs_trace::level_2)<<"Recording data for segment "<<itsSegment<<endl; size_t nbpms = bpms.Size(); // Simulated data acquisition size_t nstates = theEnergyAdjustmentPolicy->GetNumEnergyStates(); RealVector xy0(bpms.Size()); for(size_t nes=0; nes<nstates; nes++) { theEnergyAdjustmentPolicy->SetEnergyState(nes); theSimulationModel->TrackBeam(nes); if(nes==0) { xy0 = bpms; // difference to design absolute orbit cData(Range(0,nbpms-1)) = xy0-refdata[0]; } else // difference from design 'difference orbit' for off-energy state { cData(Range(nes*nbpms,(nes+1)*nbpms-1)) = (static_cast<RealVector>(bpms)-xy0)-refdata[nes]; } } theEnergyAdjustmentPolicy->Restore(); if(dfs_trace::verbosity>=dfs_trace::level_3) { double rms = sqrt(cData*cData); dfs_trace(dfs_trace::level_3)<<"segment data rms = "<<rms<<endl; } }
// Cylinder - Box by CroTeam // Ported by Nguyen Binh int dCollideCylinderBox(dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, int skip) { dIASSERT (skip >= (int)sizeof(dContactGeom)); dIASSERT (o1->type == dCylinderClass); dIASSERT (o2->type == dBoxClass); dIASSERT ((flags & NUMC_MASK) >= 1); sCylinderBoxData cData(o1, o2, flags, contact, skip); return cData.PerformCollisionChecking(); }
/* * Common routime to free a CSSM_X509_EXTENSIONS. Used to free * CSSM_X509_TBS_CERTLIST.extensions and * CSSM_X509_REVOKED_CERT_ENTRY.extensions. * We just cook up a CssmOid and a CssmOwnedData for each extension * and pass to CL_freeCrlFieldData(). */ static void CL_freeCssmExtensions( CSSM_X509_EXTENSIONS &extens, Allocator &alloc) { for(uint32 dex=0; dex<extens.numberOfExtensions; dex++) { CSSM_X509_EXTENSION_PTR exten = &extens.extensions[dex]; const CSSM_OID *fieldOid; /* * The field OID is either the same as the extension's OID (if we parsed * it) or CSSMOID_X509V3CertificateExtensionCStruct (if we didn't). */ switch(exten->format) { case CSSM_X509_DATAFORMAT_ENCODED: fieldOid = &CSSMOID_X509V3CertificateExtensionCStruct; break; case CSSM_X509_DATAFORMAT_PARSED: case CSSM_X509_DATAFORMAT_PAIR: fieldOid = &exten->extnId; break; default: clErrorLog("CL_freeCssmExtensions: bad exten->format (%d)", (int)exten->format); CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER); } const CssmOid &fieldId = CssmOid::overlay(*fieldOid); if (exten->extnId.Data != NULL) // if this is null, something threw when it was instantiated { CssmData cData((uint8 *)exten, sizeof(CSSM_X509_EXTENSION)); CssmRemoteData fieldValue(alloc, cData); CL_freeCrlFieldData(fieldId, fieldValue, false); fieldValue.release(); // but no free (via reset() */ } } alloc.free(extens.extensions); memset(&extens, 0, sizeof(CSSM_X509_EXTENSIONS)); }
/** * @brief * Save text to clipboard */ void ClipBoard::SetText(const String &sText) { // Set text DataObject cData(sText); m_pImpl->SetData(cData); }
void BitmapView::MouseMoved( BPoint cNewPos, uint32 nCode, const BMessage* pcData ) { int32 nButtons = 0x01; Window()->CurrentMessage()->FindInt32("buttons", &nButtons); m_cLastPos = cNewPos; if ( (nButtons & 0x01) == 0 ) { return; } if ( m_bSelRectActive ) { SetDrawingMode( B_OP_INVERT ); DrawFrame( m_cSelRect, FRAME_TRANSPARENT | FRAME_THIN ); m_cSelRect.right = cNewPos.x; m_cSelRect.bottom = cNewPos.y; BRect cSelRect = m_cSelRect; if ( cSelRect.left > cSelRect.right ) { float nTmp = cSelRect.left; cSelRect.left = cSelRect.right; cSelRect.right = nTmp; } if ( cSelRect.top > cSelRect.bottom ) { float nTmp = cSelRect.top; cSelRect.top = cSelRect.bottom; cSelRect.bottom = nTmp; } BFont* pcFont = GetFont(); SetDrawingMode( B_OP_COPY ); for ( uint i = 0 ; i < m_cIcons.size() ; ++i ) { m_cIcons[i]->Select( this, cSelRect.Contains( m_cIcons[i]->GetFrame( pcFont ) ) ); } SetDrawingMode( B_OP_INVERT ); DrawFrame( m_cSelRect, FRAME_TRANSPARENT | FRAME_THIN ); Flush(); return; } if ( m_bCanDrag ) { Flush(); Icon* pcSelIcon = NULL; BRect cSelFrame( 1000000, 1000000, -1000000, -1000000 ); BFont* pcFont = GetFont(); BMessage cData(1234); for ( uint i = 0 ; i < m_cIcons.size() ; ++i ) { if ( m_cIcons[i]->m_bSelected ) { cData.AddString( "file/path", m_cIcons[i]->GetName().c_str() ); cSelFrame = cSelFrame | m_cIcons[i]->GetFrame( pcFont ); pcSelIcon = m_cIcons[i]; } } if ( pcSelIcon != NULL ) { m_cDragStartPos = cNewPos; // + cSelFrame.LeftTop() - cNewPos; if ( (cSelFrame.Width()+1.0f) * (cSelFrame.Height()+1.0f) < 12000 ) { BBitmap cDragBitmap( cSelFrame, B_RGB32, true ); BView* pcView = new BView( cSelFrame.OffsetToCopy(0,0), "", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ); cDragBitmap.AddChild( pcView ); pcView->SetHighColor( 255, 255, 255, 0 ); pcView->FillRect( cSelFrame.OffsetToCopy(0,0) ); for ( uint i = 0 ; i < m_cIcons.size() ; ++i ) { if ( m_cIcons[i]->m_bSelected ) { m_cIcons[i]->Draw( pcView, -cSelFrame.LeftTop(), true, false ); } } cDragBitmap.Sync(); uint32* pRaster = (uint32*)cDragBitmap.Bits(); for ( int y = 0 ; y < cSelFrame.Height() + 1.0f ; ++y ) { for ( int x = 0 ; x < cSelFrame.Width()+1.0f ; ++x ) { if ( pRaster[x + y * int(cSelFrame.Width()+1.0f)] != 0x00ffffff && (pRaster[x + y * int(cSelFrame.Width()+1.0f)] & 0xff000000) == 0xff000000 ) { pRaster[x + y * int(cSelFrame.Width()+1.0f)] = (pRaster[x + y * int(cSelFrame.Width()+1.0f)] & 0x00ffffff) | 0xb0000000; } } } DragMessage( &cData, &cDragBitmap, cNewPos - cSelFrame.LeftTop() ); } else { DragMessage( &cData, cNewPos - cSelFrame.LeftTop(), cSelFrame.OffsetToCopy(0,0) ); } } m_bCanDrag = false; } Flush(); }