QVector<QVector2D> QAttribute::asVector2D() const { Q_D(const QAttribute); char* rawBuffer = d->m_buffer->data().data(); rawBuffer += d->m_byteOffset; float* fptr; int stride; switch (dataType()) { case QAttribute::Float: stride = sizeof(float) * dataSize(); break; default: qCDebug(Render::Io) << Q_FUNC_INFO << "can't convert" << dataType() << "x" << dataSize() << "to QVector3D"; return QVector<QVector2D>(); } if (d->m_byteStride != 0) stride = d->m_byteStride; QVector<QVector2D> result; result.resize(d->m_count); for (uint c = 0; c < d->m_count; ++c) { QVector2D v; fptr = reinterpret_cast<float*>(rawBuffer); for (uint i = 0, m = qMin(dataSize(), 2U); i < m; ++i) v[i] = fptr[i]; result[c] = v; rawBuffer += stride; } return result; }
void QAttribute::dump(int count) { Q_D(const QAttribute); const char* rawBuffer = d->m_buffer->data().data(); rawBuffer += d->m_byteOffset; const float* fptr; const quint16* usptr; int stride = d->m_byteStride; for (int c=0; c<count; ++c) { switch (dataType()) { case QAttribute::UnsignedShort: if (stride == 0) stride = sizeof(quint16); usptr = reinterpret_cast<const quint16*>(rawBuffer + stride * c); qCDebug(Render::Io) << c << ":u16:" << usptr[0]; break; case QAttribute::UnsignedInt: if (stride == 0) stride = sizeof(quint32); qCDebug(Render::Io) << c << ":u32:" << reinterpret_cast<const quint32*>(rawBuffer + stride * c)[0]; break; case QAttribute::Float: if (stride == 0) stride = sizeof(float) * dataSize(); fptr = reinterpret_cast<const float*>(rawBuffer + stride * c); qCDebug(Render::Io) << c << QString::fromLatin1(":vec") + QString::number(dataSize()) << fptr[0] << fptr[1]; break; default: qCDebug(Render::Io) << Q_FUNC_INFO << "unspported type:" << dataType(); } } }
char HStringAttribute::write(const std::string & str) { herr_t status = H5Awrite(fObjectId, dataType(), str.c_str()); if(status < 0) return 0; return 1; }
AMDSFlatArray *AmptekSDD123Detector::readSpectrumData(const QByteArray &spectrumData, int numChannels) { if (numChannels != bufferSize()) { AMDSRunTimeSupport::debugMessage(AMDSRunTimeSupport::AlertMsg, this, AMPTEK_ALERT_CHANNEL_NUMBER_UNMATCH, QString("Spectrum channel number (%1) doesn't match with the expected buffer size (%2)").arg(numChannels).arg(bufferSize())); } AMDSFlatArray *spectrumArray = new AMDSFlatArray(dataType(), bufferSize()); QList<double> spectrum; QByteArray tmpData; bool ok; //qDebug() << spectrumData.size(); for(int index = 0; index < numChannels; index++) { backwardsMid(index*3, 3, spectrumData, tmpData); spectrum.append(tmpData.toHex().toInt(&ok, 16)); // spectrumArray->setValue(index, tmpData.toHex().toInt(&ok, 16)); // spectrumArray->setValue(index, spectrum.last()); spectrumArray->setValue(index, (quint16)(spectrum.last())); } //qDebug() << "Spectrum ready:\n " << spectrum; emit spectrumChanged(spectrum); return spectrumArray; }
char HIntAttribute::read(int *data) { herr_t status = H5Aread(fObjectId, dataType(), data); if(status < 0) return 0; return 1; }
KDEVPLATFORMLANGUAGE_EXPORT void ConstantIntegralType::setValueInternal<double>(double value) { if(dataType() != TypeDouble) { kDebug() << "setValue(double) called on non-double type"; } memcpy(&d_func_dynamic()->m_value, &value, sizeof(double)); }
KDEVPLATFORMLANGUAGE_EXPORT void ConstantIntegralType::setValueInternal<float>(float value) { if(dataType() != TypeFloat) { kDebug() << "setValue(float) called on non-float type"; } memcpy(&d_func_dynamic()->m_value, &value, sizeof(float)); }
RemoteInformation deserializeDataSourceData( const ::zeq::Event& event ) { if( event.getType() != EVENT_DATASOURCE_DATA ) return RemoteInformation(); auto data = GetVolumeInformation( event.getData( )); RemoteInformation info; livre::VolumeInformation& vi = info.second; info.first.low() = data->eventLow(); info.first.high() = data->eventHigh(); vi.isBigEndian = data->isBigEndian(); vi.compCount = data->compCount(); vi.dataType = DataType( data->dataType( )); vi.overlap = _deserializeVector3< unsigned >( data->overlap( )); vi.maximumBlockSize = _deserializeVector3< unsigned >( data->maximumBlockSize( )); vi.minPos = _deserializeVector3< float >( data->minPos( )); vi.maxPos = _deserializeVector3< float >( data->maxPos( )); vi.voxels = _deserializeVector3< unsigned >( data->voxels( )); vi.worldSize = _deserializeVector3< float >( data->worldSize( )); vi.boundingBox.getMin() = _deserializeVector3< float >( data->boundingBoxMin( )); vi.boundingBox.getMax() = _deserializeVector3< float >( data->boundingBoxMax( )); vi.worldSpacePerVoxel = data->worldSpacePerVoxel(); const Vector3ui& blockSize = vi.maximumBlockSize - vi.overlap * 2; Vector3ui blocksSize = vi.voxels / blockSize; blocksSize = blocksSize / ( 1u << data->depth( )); vi.rootNode = RootNode( data->depth(), blocksSize ); return info; }
void CategoryTree::onSelChanged( wxTreeEvent& pEvent ) { wxArrayTreeItemIds ids; this->GetSelections( ids ); // Only raise events if only one entry was selected if ( ids.Count( ) == 1 ) { auto itemData = static_cast<const CategoryTreeItem*>( this->GetItemData( ids[0] ) ); if ( !itemData ) { return; } // raise the correct event switch ( itemData->dataType( ) ) { case CategoryTreeItem::DT_Category: for ( ListenerSet::iterator it = m_listeners.begin( ); it != m_listeners.end( ); it++ ) { ( *it )->onTreeCategoryClicked( *this, *static_cast<const DatIndexCategory*>( itemData->data( ) ) ); } break; case CategoryTreeItem::DT_Entry: for ( ListenerSet::iterator it = m_listeners.begin( ); it != m_listeners.end( ); it++ ) { ( *it )->onTreeEntryClicked( *this, *static_cast<const DatIndexEntry*>( itemData->data( ) ) ); } } } }
wxTreeItemId CategoryTree::addCategoryEntry( const wxTreeItemId& p_parent, const wxString& p_displayName ) { wxTreeItemIdValue cookie; wxTreeItemId previous; auto child = this->GetFirstChild( p_parent, cookie ); while ( child.IsOk( ) ) { auto text = this->GetItemText( child ); // Compare if ( text > p_displayName ) { break; } // Categories have nullptr item data auto data = static_cast<const CategoryTreeItem*>( this->GetItemData( child ) ); if ( data->dataType( ) != CategoryTreeItem::DT_Category ) { break; } // Move to next previous = child; child = this->GetNextChild( p_parent, cookie ); } // This item should be first if there *is* something in this list, but previous is nothing if ( child.IsOk( ) && !previous.IsOk( ) ) { return this->InsertItem( p_parent, 0, p_displayName, CategoryTreeImageList::IT_ClosedFolder ); } // This item should be squashed in if both child and previous are ok if ( child.IsOk( ) && previous.IsOk( ) ) { return this->InsertItem( p_parent, previous, p_displayName, CategoryTreeImageList::IT_ClosedFolder ); } // If the above fails, it means we went through the entire list without finding a proper spot return this->AppendItem( p_parent, p_displayName, CategoryTreeImageList::IT_ClosedFolder ); }
void writeArray(H5::Group &group, const std::string &name, const std::string &value) { StrType dataType(0, value.length() + 1); DataSpace dataSpace = getDataSpace(1); H5::DataSet data = group.createDataSet(name, dataType, dataSpace); data.write(value, dataType); }
Nd4jStatus LegacyScalarOp::validateAndExecute(Context &block) { auto x = INPUT_VARIABLE(0); int offset = 0; auto z = OUTPUT_VARIABLE(0); int opNum = block.opNum() < 0 ? this->_opNum : block.opNum(); if (block.width() > 1) { auto y = INPUT_VARIABLE(1); y->printIndexedBuffer("scalar"); // FIXME NativeOpExcutioner::execScalar(opNum, x->getBuffer(), x->getShapeInfo(), z->getBuffer(), z->getShapeInfo(), y->buffer(), y->shapeInfo(), block.getTArguments()->data()); } else if (block.getTArguments()->size() > 0) { auto y = NDArrayFactory::create(x->dataType(), T_ARG(0), block.getWorkspace()); offset++; // FIXME NativeOpExcutioner::execScalar(opNum, x->getBuffer(), x->getShapeInfo(), z->getBuffer(), z->getShapeInfo(), y.buffer(), y.shapeInfo(), block.getTArguments()->data() + offset); } else { // FIXME NativeOpExcutioner::execScalar(opNum, x->getBuffer(), x->getShapeInfo(), z->getBuffer(), z->getShapeInfo(), _scalar.buffer(), _scalar.shapeInfo(), block.getTArguments()->data()); } STORE_RESULT(*z); return Status::OK(); }
// --------------------------------------------------------- // CBrCtlApiTestObserver::HandleDownloadL // --------------------------------------------------------- // TBool CBrCtlApiTestObserver::HandleDownloadL(RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray) { TInt i = 0; TInt count = aTypeArray->Count(); for (i = 0; i < count; i++) { if ((*aTypeArray)[i] == EParamLocalFileName && aDesArray[i].Length() > 0) { TInt j = 0; for (j = 0; j < count; j++) { if ((*aTypeArray)[j] == EParamReceivedContentType) { HBufC8* dataType8 = HBufC8::NewLC((*aDesArray)[j].Length()); dataType8->Des().Copy((*aDesArray)[j]); TDataType dataType(*dataType8); iHandler->OpenFileEmbeddedL((*aDesArray)[i], dataType); CleanupStack::PopAndDestroy(); break; } } break; } } return EFalse; }
int CategoryTree::OnCompareItems( const wxTreeItemId& p_item1, const wxTreeItemId& p_item2 ) { int Result = 0; auto itemData1 = static_cast<const CategoryTreeItem*>( this->GetItemData( p_item1 ) ); auto itemData2 = static_cast<const CategoryTreeItem*>( this->GetItemData( p_item2 ) ); if ( itemData1->dataType() == CategoryTreeItem::DT_Entry && itemData2->dataType() == CategoryTreeItem::DT_Entry ) { auto itemEntry1 = static_cast<const DatIndexEntry*>( itemData1->data() ); auto itemEntry2 = static_cast<const DatIndexEntry*>( itemData2->data() ); if ( itemEntry1->baseId() > itemEntry2->baseId() ) { Result = 1; } else if ( itemEntry1->baseId() < itemEntry2->baseId() ) { Result = -1; } } return Result; }
std::shared_ptr<QgsMeshMemoryDatasetGroup> QgsMeshCalcUtils::create( const QString &datasetGroupName ) const { const auto dp = mMeshLayer->dataProvider(); std::shared_ptr<QgsMeshMemoryDatasetGroup> grp; for ( int group_i = 0; group_i < dp->datasetGroupCount(); ++group_i ) { const auto meta = dp->datasetGroupMetadata( group_i ); const QString name = meta.name(); if ( name == datasetGroupName ) { grp = std::make_shared<QgsMeshMemoryDatasetGroup>(); grp->isScalar = meta.isScalar(); grp->type = meta.dataType(); grp->maximum = meta.maximum(); grp->minimum = meta.minimum(); grp->name = meta.name(); int count = ( meta.dataType() == QgsMeshDatasetGroupMetadata::DataOnFaces ) ? dp->faceCount() : dp->vertexCount(); for ( int dataset_i = 0; dataset_i < dp->datasetCount( group_i ); ++dataset_i ) { const QgsMeshDatasetIndex index( group_i, dataset_i ); const auto dsMeta = dp->datasetMetadata( index ); std::shared_ptr<QgsMeshMemoryDataset> ds = create( grp->type ); ds->maximum = dsMeta.maximum(); ds->minimum = dsMeta.minimum(); ds->time = dsMeta.time(); ds->valid = dsMeta.isValid(); const QgsMeshDataBlock block = dp->datasetValues( index, 0, count ); Q_ASSERT( block.count() == count ); for ( int value_i = 0; value_i < count; ++value_i ) ds->values[value_i] = block.value( value_i ); const QgsMeshDataBlock active = dp->areFacesActive( index, 0, dp->faceCount() ); Q_ASSERT( active.count() == dp->faceCount() ); for ( int value_i = 0; value_i < dp->faceCount(); ++value_i ) ds->active[value_i] = active.active( value_i ); grp->addDataset( ds ); } break; } } return grp; }
/** @SYMTestCaseID APPFWK-APPARC-0036 @SYMPREQ Policing server apis @SYMTestCaseDesc Testing whether untrusted applications are able to override MIME types mapping @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions To connect to RApaLsSession and try to register trusted and untrusted apps for mime types. @SYMTestExpectedResults Test should complete without any panic. */ void CT_DataTypeMappingWithSid1::ExecuteL(RApaLsSession& aLs) { TInt ret; TBool added=EFalse; _LIT8(KLitAudioFake, "audio/fakedata"); TDataType dataType( KLitAudioFake ); TUid trustedAppUid = {0x10207f8f}; TUid untrustedAppUid = {0xA3010010}; TUid retAppUid( KNullUid ); ret=aLs.InsertDataMapping(dataType, KDataTypePriorityHigh, trustedAppUid); INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityHigh")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); TEST(retAppUid == trustedAppUid); ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, untrustedAppUid, added); INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), untrustedAppUid, retAppUid); TEST(retAppUid == untrustedAppUid); ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, trustedAppUid, added); INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); TEST(retAppUid == trustedAppUid); ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh+1, untrustedAppUid, added); INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with KDataTypePriorityTrustedHigh+1")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); TEST(retAppUid == trustedAppUid); //delete data type mapping ret=aLs.DeleteDataMapping(dataType); INFO_PRINTF3(_L("Deleting data mapping: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); }
void writeArray(H5::Group &group, const std::string &name, const std::vector<int32_t> &values) { DataType dataType(PredType::NATIVE_INT32); DataSpace dataSpace = getDataSpace(values); DSetCreatPropList propList = getPropList(values.size()); auto data = group.createDataSet(name, dataType, dataSpace, propList); data.write(&(values[0]), dataType); }
char HVLStringAttribute::write(const std::string & str) { const char *string_att[1]; string_att[0] = str.c_str(); herr_t status = H5Awrite(fObjectId, dataType(), &string_att); if(status < 0) return 0; return 1; }
int instance2xml(CMPIInstance *ci, UtilStringBuffer * sb, unsigned int flags) { ClInstance *inst = (ClInstance *) ci->hdl; int i, m = ClInstanceGetPropertyCount(inst); char *type; UtilStringBuffer *qsb = UtilFactory->newStrinBuffer(1024); _SFCB_ENTER(TRACE_CIMXMLPROC, "instance2xml"); SFCB_APPENDCHARS_BLOCK(sb, "<INSTANCE CLASSNAME=\""); sb->ft->appendChars(sb, instGetClassName(ci)); SFCB_APPENDCHARS_BLOCK(sb, "\">\n"); if (flags & FL_includeQualifiers) quals2xml(inst->quals, sb); for (i = 0; i < m; i++) { CMPIString name; CMPIData data; qsb->ft->reset(qsb); if (ClInstanceIsPropertyAtFiltered(inst, i)) { continue; } data = __ift_internal_getPropertyAt(ci, i, (char **) &name.hdl, NULL, 1); if (data.type & CMPI_ARRAY) { DATA2XML(&data, ci, &name, NULL, "<PROPERTY.ARRAY NAME=\"", "</PROPERTY.ARRAY>\n", sb, qsb, 1, 0); } else { type = dataType(data.type); if (*type == '*') DATA2XML(&data, ci, &name, NULL, "<PROPERTY.REFERENCE NAME=\"", "</PROPERTY.REFERENCE>\n", sb, qsb, 1, 0); else DATA2XML(&data, ci, &name, NULL, "<PROPERTY NAME=\"", "</PROPERTY>\n", sb, qsb, 1, 0); } if (data.type & (CMPI_ENC | CMPI_ARRAY)) { // don't get confused // using generic release if ((data.state & ~CMPI_keyValue) == 0 && data.type != CMPI_instance) data.value.inst->ft->release(data.value.inst); } } SFCB_APPENDCHARS_BLOCK(sb, "</INSTANCE>\n"); qsb->ft->release(qsb); _SFCB_RETURN(0); }
/** @SYMTestCaseID T-MimeStep-testTDataTypeL @SYMPREQ @SYMTestCaseDesc Test TDataType structure by creating new automatic variables @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions The test creates new TDataType automatic variables. It creates a first TDataType using the constructor taking a UID. The data type must be a native Symbian data type, with an associated UID equal to the original UID from which the UID was constructed.\n A second TDataType is created using a pointer descriptor to the data type previously created. Also, the data type must be a native Symbian data type, with the same associated UID than the previously data type created.\n API Calls:\n TDataType::TDataType() \n TDataType::TDataType(const TDesC8& aDataType) \n TDataType::IsNative() \n TDataType::Uid() \n @SYMTestExpectedResults Test should complete without any panic. */ void CT_MimeStep::testTDataTypeL() // check TDataType constructors { TUid uid={0x12345678}; TDataType dataType(uid); TEST(dataType.IsNative()); TEST(dataType.Uid()==uid); TDataType secondType(dataType.Des8()); TEST(secondType==dataType); TEST(secondType.IsNative()); TEST(secondType.Uid()==uid); }
char HStringAttribute::read(std::string & str) { const int d = dataSpaceDimension(); char * t = new char[d + 1]; herr_t status = H5Aread(fObjectId, dataType(), t); if(status < 0) return 0; t[d] = '\0'; str = std::string(t); delete[] t; return 1; }
value_type operator()(size_type i, size_type j) const { #ifndef _OPTIMIZED if(i>= _brows*BLOCK || j >=_bcols*BLOCK) { std::cerr << "error:sparse_bcsr:operator() out of bounds\n"; exit(1); } #endif bool in_sparsity = true; size_type bidx = bindex_of(i/BLOCK, j/BLOCK, in_sparsity); return (in_sparsity) ? data[index(bidx, i%BLOCK, j%BLOCK)] : dataType(0); }
bool PreviewPanel::previewFile( DatFile& p_datFile, const DatIndexEntry& p_entry ) { auto entryData = p_datFile.readFile( p_entry.mftEntry( ) ); if ( !entryData.GetSize( ) ) { return false; } // Create file reader auto reader = FileReader::readerForData( entryData, p_datFile, p_entry.fileType( ) ); if ( reader ) { if ( m_currentView ) { // Check if we can re-use the current viewer if ( m_currentDataType == reader->dataType( ) ) { m_currentView->setReader( reader ); return true; } // Destroy the old viewer if ( m_currentView ) { this->GetSizer( )->Remove( 0 ); m_currentView->Destroy( ); } } m_currentView = this->createViewerForDataType( reader->dataType( ), p_datFile ); if ( m_currentView ) { // Workaround for wxWidgets fuckups this->GetSizer( )->Add( m_currentView, wxSizerFlags( ).Expand( ).Proportion( 1 ) ); this->GetSizer( )->Layout( ); this->GetSizer( )->Fit( this ); // Set the reader m_currentView->setReader( reader ); m_currentDataType = reader->dataType( ); return true; } } return false; }
void CategoryTree::onContextMenu( wxTreeEvent& p_event ) { wxArrayTreeItemIds ids; this->GetSelections( ids ); if ( ids.Count( ) > 0 ) { // Start with counting the total amount of entries uint count = 0; const DatIndexEntry* firstEntry = nullptr; for ( uint i = 0; i < ids.Count( ); i++ ) { auto itemData = static_cast<const CategoryTreeItem*>( this->GetItemData( ids[i] ) ); if ( itemData->dataType( ) == CategoryTreeItem::DT_Entry ) { if ( !firstEntry ) { firstEntry = ( const DatIndexEntry* ) itemData->data( ); } count++; } else if ( itemData->dataType( ) == CategoryTreeItem::DT_Category ) { auto category = static_cast<const DatIndexCategory*>( itemData->data( ) ); count += category->numEntries( true ); if ( !firstEntry && category->numEntries( ) ) { firstEntry = category->entry( 0 ); } } } // Create the menu if ( count > 0 ) { wxMenu newMenu; if ( count == 1 ) { newMenu.Append( wxID_SAVE, wxString::Format( wxT( "Extract file %s..." ), firstEntry->name( ) ) ); newMenu.Append( wxID_SAVEAS, wxString::Format( wxT( "Extract file %s (raw)..." ), firstEntry->name( ) ) ); } else { newMenu.Append( wxID_SAVE, wxString::Format( wxT( "Extract %d files..." ), count ) ); newMenu.Append( wxID_SAVEAS, wxString::Format( wxT( "Extract %d files (raw)..." ), count ) ); } this->PopupMenu( &newMenu ); } } }
JacobiPreconditioner(const sparse_csr<dataType> &A) : AdiagInv(A.rows(), dataType(0)) { for(size_type i=0; i<A.rows(); ++i) { value_type aii = A(i,i); AdiagInv(i) = value_type(1)/aii; if(aii == value_type(0)) { std::cerr << "Warning: JacobiPreconditioner found 0.0 on diag of A." << std::endl; std::cerr << "\tResults using this preconditioner may be bad." << std::endl; std::cerr << "\tPlacing value_type(1) in the preconditioner at location: " << i << std::endl; } } }
// ---------------------------------------------------------------------- void QmvTupleAttribute::load(const QString & data) { original_value = data; // Conversions based on datatype switch ( dataType() ) { case QmvAttribute::Timestamp: if ( data.length() > 0 ) original_value = formatTimestamp( data ); break; default: break; } // conversions based on input method switch ( inputMethod() ) { case QmvAttribute::Colour: // convert to presentation form #XXXXXX bool ok; original_value.replace( QRegExp("#"), "").toUInt( &ok, 16); if (ok) { original_value = original_value.rightJustify(8, '0'); original_value.prepend("#"); } break; // case QmvAttribute::List: // colour_group.setColor( QColorGroup::Base, QColor("yellow") ); // setColourGroup(colour_group); // break; default: break; } current_value = original_value; QColor alert_colour = alertColour(); alert = alert_colour.isValid(); if ( alert ) { colour_group.setColor( QColorGroup::Base, alert_colour ); setColourGroup(colour_group); } else local_colour_group = false; }
bool ShDataVariant<T, DT>::equals(const ShVariant* other) const { if(!other || (size() != other->size()) || !other->typeMatches(valueType(), dataType())) return false; const ShDataVariant* castOther = variant_cast<T, DT>(other); const_iterator I, J; I = m_begin; J = castOther->begin(); for(; I != m_end; ++I, ++J) { if(!shDataTypeEqual((*I), (*J))) return false; } return true; }
QByteArray QgsRasterDataProvider::noValueBytes( int theBandNo ) { int type = dataType( theBandNo ); int size = dataTypeSize( theBandNo ) / 8; QByteArray ba; ba.resize( size ); char * data = ba.data(); double noval = mNoDataValue[theBandNo-1]; unsigned char uc; unsigned short us; short s; unsigned int ui; int i; float f; double d; switch ( type ) { case Byte: uc = ( unsigned char )noval; memcpy( data, &uc, size ); break; case UInt16: us = ( unsigned short )noval; memcpy( data, &us, size ); break; case Int16: s = ( short )noval; memcpy( data, &s, size ); break; case UInt32: ui = ( unsigned int )noval; memcpy( data, &ui, size ); break; case Int32: i = ( int )noval; memcpy( data, &i, size ); break; case Float32: f = ( float )noval; memcpy( data, &f, size ); break; case Float64: d = ( double )noval; memcpy( data, &d, size ); break; default: QgsLogger::warning( "GDAL data type is not supported" ); } return ba; }
Array<const DatIndexEntry*> CategoryTree::getSelectedEntries( ) const { wxArrayTreeItemIds ids; this->GetSelections( ids ); if ( ids.GetCount( ) == 0 ) { return Array<const DatIndexEntry*>( ); } // Doing this in two steps since reallocating takes far longer than iterating // Start with counting the total amount of entries uint count = 0; for ( uint i = 0; i < ids.Count( ); i++ ) { auto itemData = static_cast<const CategoryTreeItem*>( this->GetItemData( ids[i] ) ); if ( itemData->dataType( ) == CategoryTreeItem::DT_Entry ) { count++; } else if ( itemData->dataType( ) == CategoryTreeItem::DT_Category ) { count += static_cast<const DatIndexCategory*>( itemData->data( ) )->numEntries( true ); } } // Create and populate the array to return Array<const DatIndexEntry*> retval( count ); if ( count ) { uint index = 0; for ( uint i = 0; i < ids.Count( ); i++ ) { auto itemData = static_cast<const CategoryTreeItem*>( this->GetItemData( ids[i] ) ); if ( itemData->dataType( ) == CategoryTreeItem::DT_Entry ) { retval[index++] = static_cast<const DatIndexEntry*>( itemData->data( ) ); } else if ( itemData->dataType( ) == CategoryTreeItem::DT_Category ) { this->addCategoryEntriesToArray( retval, index, *static_cast<const DatIndexCategory*>( itemData->data( ) ) ); } } Assert( index == count ); } return retval; }
void CategoryTree::addEntry( const DatIndexEntry& p_entry ) { auto category = this->ensureHasCategory( *p_entry.category( ) ); if ( category.IsOk( ) ) { if ( this->IsExpanded( category ) ) { auto node = this->addEntry( category, p_entry ); this->SetItemData( node, new CategoryTreeItem( CategoryTreeItem::DT_Entry, &p_entry ) ); } else { auto itemData = static_cast<CategoryTreeItem*>( this->GetItemData( category ) ); if ( itemData->dataType( ) != CategoryTreeItem::DT_Category ) { return; } itemData->setDirty( true ); } } }