//--------------------------------------------------------------------------- void __fastcall TFrDeviceExplorer::btnWriteClick(TObject *Sender) { TBluetoothLEDevice * ADevice = NULL; ADevice = GetCurrentDevice(); if(ADevice != NULL) { TBluetoothGattService * AService = ADevice->Services->Items[CurrentService]; TBluetoothGattCharacteristic * AChar = AService->Characteristics->Items[CurrentCharacteristic]; if((AChar->Properties.Contains(TBluetoothProperty::Write)) || (AChar->Properties.Contains(TBluetoothProperty::WriteNoResponse)) || (AChar->Properties.Contains(TBluetoothProperty::SignedWrite))) { if(CbWriteTypes->ItemIndex == 0) AChar->SetValueAsString(EdCharacWrite->Text); if(CbWriteTypes->ItemIndex == 1) AChar->SetValueAsString(EdCharacWrite->Text, false); if(CbWriteTypes->ItemIndex == 2) AChar->SetValueAsUInt8(UInt8(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 3) AChar->SetValueAsUInt16(UInt16(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 4) AChar->SetValueAsUInt32(UInt32(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 5) AChar->SetValueAsUInt64(StrToInt(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 6) AChar->SetValueAsInt8(Int8(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 7) AChar->SetValueAsInt16(Int16(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 8) AChar->SetValueAsInt32(Int32(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 9) AChar->SetValueAsInt64(StrToInt(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 10) AChar->SetValueAsDouble(StrToFloat(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 11) AChar->SetValueAsSingle(StrToFloat(EdCharacWrite->Text)); ADevice->WriteCharacteristic(AChar); } else { ShowMessage("This characteristic doesn''t allow Write"); } } else { ShowMessage(EdCurrentDevice->Text + " is not available"); } }
void runTests(bool write,BinaryDataHandler &pMem) { runTest (write,pMem, std::string("Hallo") ); runTest1 (write,pMem, Time(222.22) ); runTest (write,pMem, Color3f(1.1,2.2,3.3) ); runTest (write,pMem, Color4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Color3ub(1,2,3) ); runTest (write,pMem, Color4ub(1,2,3,4) ); runTest (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) ); runTest (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) ); runTest1 (write,pMem, BitVector(0xabcd) ); runTest (write,pMem, Plane(Vec3f(1.0,0),0.222) ); runTest (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ); runTest (write,pMem, Quaternion(Vec3f(1,2,3),22) ); runTest2<bool>(write,pMem, true ); runTest (write,pMem, Int8(-22) ); runTest (write,pMem, UInt8(11) ); runTest (write,pMem, Int16(-10233) ); runTest (write,pMem, UInt16(20233) ); runTest (write,pMem, Int32(-222320233) ); runTest (write,pMem, UInt32(522320233) ); runTest<Int64> (write,pMem, Int64(-522323334) ); runTest (write,pMem, UInt64(44523423) ); runTest (write,pMem, Real32(22.333224) ); runTest (write,pMem, Real64(52.334534533224) ); runTest (write,pMem, Vec2f(1.1,2.2) ); runTest (write,pMem, Vec3f(1.1,2.2,3.3) ); runTest (write,pMem, Vec4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt2f(1.1,2.2) ); runTest (write,pMem, Pnt2d(1.1,2.2) ); runTest (write,pMem, Pnt3f(1.1,2.2,3.3) ); runTest (write,pMem, Pnt3d(1.1,2.2,3.3) ); runTest (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) ); }
/*! The mouseMove is called by the viewer when the mouse is moved in the viewer and this handle is the active one. \param x the x-pos of the mouse (pixel) \param y the y-pos of the mouse (pixel) */ void Manipulator::mouseMove(const Int16 x, const Int16 y) { //SLOG << "Manipulator::mouseMove() enter\n" << std::flush; // get the beacon's core (must be ComponentTransform) and it's center if( getTarget() != NULL ) { // get transformation of beacon Transform *t = dynamic_cast<Transform *>(getTarget()->getCore()); if( t != NULL ) { UInt16 coord(0); // active coordinate: X=0, Y=1, Z=2 Int16 xDiff; // the mousepos x delta Int16 yDiff; // the mousepos y delta Vec3f centerV; // center of beacon Vec3f handleCenterV; // center of subhandle Vec2f mouseScreenV; // mouse move vector Vec2f handleScreenV; // handle vec in (cc) Real32 handleScreenVLen; // len of handle vec in (cc) Vec3f translation; // for matrix decomposition Quaternion rotation; Vec3f scaleFactor; Quaternion scaleOrientation; // TODO: das ist ja schon ein wenig haesslich static const Vec3f coordVector[3] = { Vec3f(1.0f, 0.0f, 0.0f), Vec3f(0.0f, 1.0f, 0.0f), Vec3f(0.0f, 0.0f, 1.0f) }; // check for the active handle if( getActiveSubHandle() == getHandleXNode()) { coord = 0; } else if(getActiveSubHandle() == getHandleYNode()) { coord = 1; } else if(getActiveSubHandle() == getHandleZNode()) { coord = 2; } // TODO: only for debugging, -> FDEBUG //SLOG << "moving " << ( coord == 0 ? "x\n" : // coord == 1 ? "y\n" : // "z\n" ) // << std::flush; // calculate diffs between current and last mouse position xDiff = x - Int16(getLastMousePos()[0]); yDiff = y - Int16(getLastMousePos()[1]); // set the vector resulting from user mouse movement and calc its length mouseScreenV.setValues(xDiff, -yDiff); t->getMatrix().getTransform(translation, rotation, scaleFactor, scaleOrientation); // calculate the camera coordinate of the center centerV = translation; Pnt2f centerPixPos = calcScreenProjection(centerV.addToZero(), getViewport()); // calculate the camera coordinate of the handle center handleCenterV = centerV + coordVector[coord]*getLength()[coord]; Pnt2f handleCenterPixPos = calcScreenProjection(handleCenterV.addToZero(), getViewport()); handleScreenV = handleCenterPixPos - centerPixPos; handleScreenVLen = handleScreenV.length(); Real32 s = handleScreenV.dot(mouseScreenV) / handleScreenVLen; doMovement(t, coord, s * getLength()[coord] * 0.01, translation, rotation, scaleFactor, scaleOrientation); } else { SWARNING << "handled object has no parent transform!\n"; } callExternalUpdateHandler(); } else { SWARNING << "Handle has no target.\n"; } setLastMousePos(Pnt2f(Real32(x), Real32(y))); updateHandleTransform(); //SLOG << "Manipulator::mouseMove() leave\n" << std::flush; }
BaseSkeletonJointBase::BaseSkeletonJointBase(void) : Inherited(), _sfSkeleton (NULL), _sfJointId (Int16(BaseSkeletonJoint::INVALID_JOINT_ID)) { }
bool TiledImageBlockAccessor::readBlockA16(Vec2i vSampleOrigin, Int32 iTextureSize, Int16 *pTarget, Int32 iTargetSizeBytes) { Vec2i vLow (vSampleOrigin.x(), vSampleOrigin.y()); Vec2i vHeigh(vSampleOrigin.x() + iTextureSize, vSampleOrigin.y() + iTextureSize); UInt32 iFound = 0; Int32 iLow = -1; Int32 iHeigh = -1; for(UInt32 i = 0; i < _vSampleDescs.size(); ++i) { if(_vSampleDescs[i].contains(vLow) == true) { iLow = i; ++iFound; } if(_vSampleDescs[i].contains(vHeigh) == true) { iHeigh = i; ++iFound; } if(iFound == 2) break; } if(iLow == -1 && iHeigh == -1) { UInt32 destIdx = 0; for(Int32 y = 0; y < iTextureSize; y++) { for(Int32 x = 0; x < iTextureSize; x++) { pTarget[destIdx] = Int16(_fNoDataValue); destIdx++; } } } else if(iLow == iHeigh) { Vec2i vNewSampleOrigin(vSampleOrigin.x() - _vSampleDescs[iLow].x0, vSampleOrigin.y() - _vSampleDescs[iLow].y0); return _vImages[iLow]->readBlockA16(vNewSampleOrigin, iTextureSize, pTarget, iTargetSizeBytes); } else if( (iHeigh - iLow) == 1) { read2HBlocksA16(iLow, iHeigh, vSampleOrigin, iTextureSize, pTarget, iTargetSizeBytes); } else if( (iHeigh - iLow) == Int32(_uiColumns)) { read2VBlocksA16(iLow, iHeigh, vSampleOrigin, iTextureSize, pTarget, iTargetSizeBytes); } else if( (iHeigh - iLow) == Int32(_uiColumns + 1)) { read4BlocksA16(iLow, iHeigh, vSampleOrigin, iTextureSize, pTarget, iTargetSizeBytes); } else if(iLow != -1 && iHeigh == -1) { Vec2i vNewSampleOrigin(vSampleOrigin.x() - _vSampleDescs[iLow].x0, vSampleOrigin.y() - _vSampleDescs[iLow].y0); return _vImages[iLow]->readBlockA16(vNewSampleOrigin, iTextureSize, pTarget, iTargetSizeBytes); } else { UInt32 destIdx = 0; for(Int32 y = 0; y < iTextureSize; y++) { for(Int32 x = 0; x < iTextureSize; x++) { pTarget[destIdx] = 15000; destIdx++; } } } return true; }
bool GDALBlockAccessor::readBlockA16(Vec2i vSampleOrigin, Int32 iTextureSize, Int16 *pTarget, Int32 iTargetSizeBytes) { #ifdef OSG_WITH_GDAL Int32 xMin = vSampleOrigin.x(); Int32 xMax = vSampleOrigin.x() + iTextureSize; Int32 yMin = vSampleOrigin.y(); Int32 yMax = vSampleOrigin.y() + iTextureSize; if(xMax > _vSize[0] || yMax > _vSize[1]) { UInt32 destIdx = 0; UInt32 srcIdx = 0; _vI16Buffer.resize(iTextureSize * iTextureSize); Int32 iSampleX = osgMin(_vSize[0] - vSampleOrigin.x(), iTextureSize); Int32 iSampleY = osgMin(_vSize[1] - vSampleOrigin.y(), iTextureSize); _pBand->RasterIO(GF_Read, vSampleOrigin.x(), vSampleOrigin.y(), iSampleX, iSampleY, &(_vI16Buffer[0]), iSampleX, iSampleY, GDT_Int16, 0, 0); for(Int32 y = yMin; y < yMax; y++) { for(Int32 x = xMin; x < xMax; x++) { if(x >= _vSize[0] || y >= _vSize[1]) { pTarget[destIdx] = Int16(_fNoDataValue); } else { pTarget[destIdx] = _vI16Buffer[srcIdx]; srcIdx++; } destIdx++; } } } else { _pBand->RasterIO(GF_Read, vSampleOrigin.x(), vSampleOrigin.y(), iTextureSize, iTextureSize, pTarget, iTextureSize, iTextureSize, GDT_Int16, 0, 0); } #endif return true; }