void keyTyped(KeyEventDetails* const details) { if(details->getKey() == KeyEventDetails::KEY_Q && details->getModifiers() & KeyEventDetails::KEY_MODIFIER_COMMAND) { dynamic_cast<WindowEventProducer*>(details->getSource())->closeWindow(); } switch(details->getKey()) { case KeyEventDetails::KEY_1: case KeyEventDetails::KEY_2: case KeyEventDetails::KEY_3: case KeyEventDetails::KEY_4: case KeyEventDetails::KEY_5: case KeyEventDetails::KEY_6: case KeyEventDetails::KEY_7: case KeyEventDetails::KEY_8: case KeyEventDetails::KEY_9: { UInt8 Index(details->getKeyChar() - '1'); if(Index < Sounds.size()) { Sounds[Index]->play(); } } break; case KeyEventDetails::KEY_P: SoundGroups[0]->pause(); break; case KeyEventDetails::KEY_U: SoundGroups[0]->unpause(); break; case KeyEventDetails::KEY_MINUS: { Real32 Volume(SoundGroups[0]->getVolume()); Volume -= 0.1; if(Volume < 0.0) Volume = 0.0; SoundGroups[0]->setVolume(Volume); } break; case KeyEventDetails::KEY_EQUALS: case KeyEventDetails::KEY_PLUS: { Real32 Volume(SoundGroups[0]->getVolume()); Volume += 0.1; if(Volume > 1.0) Volume = 1.0; SoundGroups[0]->setVolume(Volume); } break; } }
virtual void keyTyped(const KeyEventUnrecPtr e) { if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL) { TheWindowEventProducer->closeWindow(); } switch(e->getKey()) { case KeyEvent::KEY_1: case KeyEvent::KEY_2: case KeyEvent::KEY_3: case KeyEvent::KEY_4: case KeyEvent::KEY_5: case KeyEvent::KEY_6: case KeyEvent::KEY_7: case KeyEvent::KEY_8: case KeyEvent::KEY_9: { UInt8 Index(e->getKeyChar() - '1'); if(Index < Sounds.size()) { Sounds[Index]->play(); } } break; case KeyEvent::KEY_P: SoundGroups[0]->pause(); break; case KeyEvent::KEY_U: SoundGroups[0]->unpause(); break; case KeyEvent::KEY_MINUS: { Real32 Volume(SoundGroups[0]->getVolume()); Volume -= 0.1; if(Volume < 0.0) Volume = 0.0; SoundGroups[0]->setVolume(Volume); } break; case KeyEvent::KEY_EQUALS: { Real32 Volume(SoundGroups[0]->getVolume()); Volume += 0.1; if(Volume > 1.0) Volume = 1.0; SoundGroups[0]->setVolume(Volume); } break; } }
Krypta::Krypta(QWidget *parent) : QMainWindow(parent), ui(new Ui::Krypta) { ui->setupUi(this); ui->txtKeyfile->setEnabled(false); ui->btnKeyFile->setEnabled(false); connect(ui->chkUnhide, SIGNAL(clicked()), this, SLOT(hide_UhidePasswords())); connect(ui->chk1Pass, SIGNAL(clicked()), this, SLOT(onePassword())); connect(ui->chkKeyfile, SIGNAL(clicked()), this, SLOT(useKeyfile())); connect(ui->chkUnhideKey, SIGNAL(clicked()), this, SLOT(hide_uhideKeyfile())); connect(ui->btnEncrypt, SIGNAL(clicked()), this, SLOT(Encrypt())); connect(ui->btnDecrypt, SIGNAL(clicked()), this, SLOT(Decrypt())); connect(ui->btnVolumes, SIGNAL(clicked()), this, SLOT(Volume())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(AboutD())); connect(ui->actionChoose_File, SIGNAL(triggered()), this, SLOT(Choose())); connect(ui->btnChoose, SIGNAL(clicked()), this, SLOT(Choose())); connect(ui->actionChoose_Keyfile, SIGNAL(triggered()), this, SLOT(ChooseKeyfile())); connect(ui->btnKeyFile, SIGNAL(clicked()), this, SLOT(ChooseKeyfile())); connect(ui->actionClear, SIGNAL(triggered()), this, SLOT(Clear())); connect(ui->actionDecrypt, SIGNAL(triggered()), this, SLOT(Decrypt())); connect(ui->actionEncrypt, SIGNAL(triggered()), this, SLOT(Encrypt())); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(Exit())); ui->txtPass->setStyleSheet("QLineEdit { border: 2px solid gray ; border-radius: 8px ; padding: 0 6px }"); ui->txtPass2->setStyleSheet("QLineEdit { border: 2px solid gray ; border-radius: 8px ; padding: 0 6px }"); ui->txtPass3->setStyleSheet("QLineEdit { border: 2px solid gray ; border-radius: 8px ; padding: 0 6px }"); }
void TransportControlGroup::_UpdateVolume() { if (IsMuted()) SetMuted(false); VolumeChanged(Volume()); }
void EngineChannel::ExecuteProgramChange(uint8_t Program) { dmsg(1,("Received MIDI program change (prog=%d)\n",Program)); std::vector<int> maps = MidiInstrumentMapper::Maps(); if (maps.empty()) return; SetMidiProgram(Program); if (UsesNoMidiInstrumentMap()) return; if (MidiInstrumentMapper::GetMapCount() == 0) return; // retrieve the MIDI instrument map this engine channel is assigned to int iMapID = (UsesDefaultMidiInstrumentMap()) ? MidiInstrumentMapper::GetDefaultMap() /*default*/ : GetMidiInstrumentMap(); // is there an entry for this MIDI bank&prog pair in that map? midi_prog_index_t midiIndex; midiIndex.midi_bank_msb = GetMidiBankMsb(); midiIndex.midi_bank_lsb = GetMidiBankLsb(); midiIndex.midi_prog = GetMidiProgram(); optional<MidiInstrumentMapper::entry_t> mapping = MidiInstrumentMapper::GetEntry(iMapID, midiIndex); if (mapping) { // if mapping exists ... InstrumentManager::instrument_id_t id; id.FileName = mapping->InstrumentFile; id.Index = mapping->InstrumentIndex; //TODO: we should switch the engine type here InstrumentManager::LoadInstrumentInBackground(id, this); Volume(mapping->Volume); } }
void Mpris::updateStatus() { QVariantMap map; if (MPDStatus::self()->repeat()!=status.repeat) { map.insert("LoopStatus", LoopStatus()); } if (MPDStatus::self()->random()!=status.random) { map.insert("Shuffle", Shuffle()); } if (MPDStatus::self()->volume()!=status.volume) { map.insert("Volume", Volume()); } if (MPDStatus::self()->playlistLength()!=status.playlistLength) { map.insert("CanGoNext", CanGoNext()); map.insert("CanGoPrevious", CanGoPrevious()); } if (MPDStatus::self()->state()!=status.state) { map.insert("PlaybackStatus", PlaybackStatus()); map.insert("CanPlay", CanPlay()); map.insert("CanPause", CanPause()); map.insert("CanSeek", CanSeek()); } if (MPDStatus::self()->timeElapsed()!=status.timeElapsed) { map.insert("Position", convertTime(MPDStatus::self()->timeElapsed())); } if (!map.isEmpty() || MPDStatus::self()->songId()!=status.songId) { if (!map.contains("Position")) { map.insert("Position", convertTime(MPDStatus::self()->timeElapsed())); } map.insert("Metadata", Metadata()); signalUpdate(map); } status=MPDStatus::self()->getValues(); }
void MediaPlayer2Player::volumeChanged(float newVol) const { Q_UNUSED(newVol) QVariantMap properties; properties["Volume"] = Volume(); signalPropertiesChange(properties); }
void CAVPlayer::VolumeIncrease() { if (m_pVLC_Player) { int iVol = libvlc_audio_get_volume(m_pVLC_Player); Volume((int)ceil(iVol * 1.1)); } }
void CAVPlayer::VolumeReduce() { if (m_pVLC_Player) { int iVol = libvlc_audio_get_volume(m_pVLC_Player); Volume((int)floor(iVol * 0.9)); } }
bool ICHull::IsInside(const Vec3<Real> & pt0, const double eps) { const Vec3<double> pt(pt0.X(), pt0.Y(), pt0.Z()); if (m_isFlat) { size_t nT = m_mesh.m_triangles.GetSize(); Vec3<double> ver0, ver1, ver2, a, b, c; double u,v; for(size_t t = 0; t < nT; t++) { ver0.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.X(); ver0.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Y(); ver0.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Z(); ver1.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.X(); ver1.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Y(); ver1.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Z(); ver2.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.X(); ver2.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Y(); ver2.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Z(); a = ver1 - ver0; b = ver2 - ver0; c = pt - ver0; u = c * a; v = c * b; if ( u >= 0.0 && u <= 1.0 && v >= 0.0 && u+v <= 1.0) { return true; } m_mesh.m_triangles.Next(); } return false; } else { size_t nT = m_mesh.m_triangles.GetSize(); Vec3<double> ver0, ver1, ver2; double vol; for(size_t t = 0; t < nT; t++) { ver0.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.X(); ver0.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Y(); ver0.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Z(); ver1.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.X(); ver1.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Y(); ver1.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Z(); ver2.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.X(); ver2.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Y(); ver2.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Z(); vol = Volume(ver0, ver1, ver2, pt); if ( vol < eps) { return false; } m_mesh.m_triangles.Next(); } return true; } }
bool ICHull::ComputePointVolume(double &totalVolume, bool markVisibleFaces) { // mark visible faces CircularListElement<TMMTriangle> * fHead = m_mesh.GetTriangles().GetHead(); CircularListElement<TMMTriangle> * f = fHead; CircularList<TMMVertex> & vertices = m_mesh.GetVertices(); CircularListElement<TMMVertex> * vertex0 = vertices.GetHead(); bool visible = false; Vec3<double> pos0 = Vec3<double>(vertex0->GetData().m_pos.X(), vertex0->GetData().m_pos.Y(), vertex0->GetData().m_pos.Z()); double vol = 0.0; totalVolume = 0.0; Vec3<double> ver0, ver1, ver2; do { ver0.X() = f->GetData().m_vertices[0]->GetData().m_pos.X(); ver0.Y() = f->GetData().m_vertices[0]->GetData().m_pos.Y(); ver0.Z() = f->GetData().m_vertices[0]->GetData().m_pos.Z(); ver1.X() = f->GetData().m_vertices[1]->GetData().m_pos.X(); ver1.Y() = f->GetData().m_vertices[1]->GetData().m_pos.Y(); ver1.Z() = f->GetData().m_vertices[1]->GetData().m_pos.Z(); ver2.X() = f->GetData().m_vertices[2]->GetData().m_pos.X(); ver2.Y() = f->GetData().m_vertices[2]->GetData().m_pos.Y(); ver2.Z() = f->GetData().m_vertices[2]->GetData().m_pos.Z(); vol = Volume(ver0, ver1, ver2, pos0); if ( vol < -sc_eps) { vol = fabs(vol); totalVolume += vol; if (markVisibleFaces) { f->GetData().m_visible = true; m_trianglesToDelete.push_back(f); } visible = true; } f = f->GetNext(); } while (f != fHead); if (m_trianglesToDelete.size() == m_mesh.m_triangles.GetSize()) { for(size_t i = 0; i < m_trianglesToDelete.size(); i++) { m_trianglesToDelete[i]->GetData().m_visible = false; } visible = false; } // if no faces visible from p then p is inside the hull if (!visible && markVisibleFaces) { vertices.Delete(); m_trianglesToDelete.clear(); return false; } return true; }
void Mpris2::EmitNotification(const QString& name) { QVariant value; if (name == "PlaybackStatus") value = PlaybackStatus(); else if (name == "LoopStatus") value = LoopStatus(); else if (name == "Shuffle") value = Shuffle(); else if (name == "Metadata") value = Metadata(); else if (name == "Volume") value = Volume(); else if (name == "Position") value = Position(); if (value.isValid()) EmitNotification(name, value); }
MPEGaudio:: MPEGaudio(MPEGstream *stream, bool initSDL) : sdl_audio(initSDL) { /* Initialize MPEG audio */ mpeg = stream; initialize(); /* Just be paranoid. If all goes well, this will be set to true */ valid_stream = false; /* Analyze the MPEG audio stream */ if ( loadheader() ) { SDL_AudioSpec wanted; WantedSpec(&wanted); /* Calculate the samples per frame */ samplesperframe = 32*wanted.channels; if( layer == 3 ) { samplesperframe *= 18; if ( version == 0 ) { samplesperframe *= 2; } } else { samplesperframe *= SCALEBLOCK; if ( layer == 2 ) { samplesperframe *= 3; } } if ( sdl_audio ) { /* Open the audio, get actual audio hardware format and convert */ bool audio_active; SDL_AudioSpec actual; audio_active = (SDL_OpenAudio(&wanted, &actual) == 0); if ( audio_active ) { ActualSpec(&actual); valid_stream = true; } else { SetError(SDL_GetError()); } SDL_PauseAudio(0); } else { /* The stream is always valid if we don't initialize SDL */ valid_stream = true; } Volume(100); } /* For using system timestamp */ for (int i=0; i<N_TIMESTAMPS; i++) timestamp[i] = -1; }
Volume Volume::fromCloudBBox(const PointCloud& cloud) { PointType minCoordinates, maxCoordinates; pcl::getMinMax3D(cloud, minCoordinates, maxCoordinates); pcl::PointXYZ minCoordinates2, maxCoordinates2; minCoordinates2.x = minCoordinates.x; minCoordinates2.y = minCoordinates.y; minCoordinates2.z = minCoordinates.z; maxCoordinates2.x = maxCoordinates.x; maxCoordinates2.y = maxCoordinates.y; maxCoordinates2.z = maxCoordinates.z; return Volume(minCoordinates2, maxCoordinates2); }
double TechUtils::CalulateAMA(const std::vector<KData>& data, const KData& current, size_t mins){ double totalExchangePrice = current.TurnOver(); long long totalVolume = current.Volume(); long long leftedge = current.Timestamp() - mins * 60 - 1; for (auto it = data.rbegin(); it != data.rend(); it++) { if (it->Timestamp() > leftedge){ totalExchangePrice += it->TurnOver(); totalVolume += it->Volume(); } else{ break; } } //assert(totalVolume != 0); //assert(totalExchangePrice >= 0.0); return totalExchangePrice / totalVolume; }
double TechUtils::CalulateAMA(const std::vector<TickWrapper>& data, const TickWrapper& current, size_t seconds) { double totalExchangePrice = current.TurnOver(); long long totalVolume = current.Volume(); long long leftedge = current.toTimeStamp() - seconds * 2; for (auto it = data.rbegin(); it != data.rend(); it++) { if (it->toTimeStamp() > leftedge){ totalExchangePrice += it->TurnOver(); totalVolume += it->Volume(); } else{ break; } } //assert(totalVolume != 0); //assert(totalExchangePrice >= 0.0); return totalExchangePrice / totalVolume; }
void SynthInit() { for (uint8_t i = 0; i < MAX_MIDI_CHANNELS; i++) for (uint8_t j = 0; j < MAX_KEYS; j++) { key[i][j].note = 0xFF; key[i][j].voice = 0xFF; } ResetAllControllers(); for (uint8_t i = 0; i < MAX_MIDI_CHANNELS; i++) { program[i] = 0x7F; ProgramChange(i, 0); Volume(i, 0x7F); FineTuning(i, 0x40, 0x00); CoarseTuning(i, 0x40); } ChipSynthInit(); }
// difference in the sense of chi square double Histogram::Diff( Histogram &hist ) { if ( val == NULL ) return -1.0; if ( hist.val == NULL ) return -1.0; if ( n != hist.n ) return -1.0; double R = Volume(); double S = hist.Volume(); double r = ( S/R ); double temp; int knstrn = 0; double df = n - knstrn; double chsq = 0.0; for (int j=0;j<n;j++) { if (val[j] == 0.0 && hist.val[j] == 0.0) { --df; //--(*df); No data means one less degree of freeelse } else { temp = fabs( r * val[j] - hist.val[j] ) / ( r * val[j] + hist.val[j] );; //temp = fabs( val[j] - hist.val[j] ) / ( val[j] + hist.val[j] ); chsq += temp;// * temp / ( val[j] + hist.val[j]); } } //double prob=gammq(0.5*(df),0.5*(chsq)); //Chi-square probability function. See §6.2. return 1.0 / chsq; }
double ICHull::ComputeVolume() { size_t nV = m_mesh.m_vertices.GetSize(); if (nV == 0 || m_isFlat) { return 0.0; } Vec3<double> bary(0.0, 0.0, 0.0); for(size_t v = 0; v < nV; v++) { bary.X() += m_mesh.m_vertices.GetHead()->GetData().m_pos.X(); bary.Y() += m_mesh.m_vertices.GetHead()->GetData().m_pos.Y(); bary.Z() += m_mesh.m_vertices.GetHead()->GetData().m_pos.Z(); m_mesh.m_vertices.Next(); } bary /= static_cast<double>(nV); size_t nT = m_mesh.m_triangles.GetSize(); Vec3<double> ver0, ver1, ver2; double totalVolume = 0.0; for(size_t t = 0; t < nT; t++) { ver0.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.X(); ver0.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Y(); ver0.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[0]->GetData().m_pos.Z(); ver1.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.X(); ver1.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Y(); ver1.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[1]->GetData().m_pos.Z(); ver2.X() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.X(); ver2.Y() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Y(); ver2.Z() = m_mesh.m_triangles.GetHead()->GetData().m_vertices[2]->GetData().m_pos.Z(); totalVolume += Volume(ver0, ver1, ver2, bary); m_mesh.m_triangles.Next(); } return totalVolume; }
Bibliographic FieldBuilder::buildField(const KeyValuePair& kvp) { String key = kvp.getKey(); Bibliographic field = Bibliographic(kvp); if (key == "author") { field = (Author)field; return field; } else if (key == "doi") { field = Doi(); } else if (key == "issn") { field = Issn(); } else if (key == "journal") { field = Journal(); } else if (key == "month") { field = Month(); } else if (key == "number") { field = Number(); } else if (key == "pages") { field = Pages(); } else if (key == "title") { field = Title(); } else if (key == "url") { field = Url(); } else if (key == "urldate") { field = UrlDate(); } else if (key == "volume") { field = Volume(); } else if (key == "year") { field = Year(); } else { field = Bibliographic(); field.setKey(kvp.getKey()); } field.setValue(kvp.getValue()); return field; }
void MediaPlayer2Player::volumeChanged() const { QVariantMap properties; properties["Volume"] = Volume(); Mpris2::signalPropertiesChange(this, properties); }
double radTg3d::VolumeWithSym() { int TotMult = TotalMultiplicity(); return TotMult*Volume(); }
void Base::CreateGravityObject() { gravityCenter.BecomePavet(Volume(0.5,0.5,0.5),Ogre::ColourValue::Green); }
void MpvHandler::SetProperties() { Volume(volume); Speed(speed); Mute(mute); }
/** * @brief Right hand side operator E (i.e. forward transform) * * @param in Image * @param sm Sensitivities * @param nx Sizes & co. * @param fts FT operators * @return K-space */ template <class T> inline static Matrix< std::complex<T> > E (const Matrix< std::complex<T> >& in, const Matrix< std::complex<T> >& sm, const std::vector<size_t>& nx, const std::vector<NFFT<T> >& fts) { Matrix< std::complex<T> > out (nx[2],nx[1]); #pragma omp parallel for default (shared) for (int j = 0; j < nx[1]; j++) Column (out, j, fts[omp_get_thread_num()] * (resize(((nx[0] == 2) ? Slice (sm, j) : Volume (sm, j)),size(in)) * in)); return out; }
MPEGaudio:: MPEGaudio(MPEGstream *stream, bool initSDL) : sdl_audio(initSDL) , mpeg(stream) , valid_stream(0) , stereo(false) , rate_in_s(0.0) , frags_playing(0) , frag_time(0) #ifdef THREADED_AUDIO , decoding(false) , decode_thread(NULL) #endif { memset(&sideinfo, '\0', sizeof (sideinfo)); /* Initialize MPEG audio */ initialize(); /* Just be paranoid. If all goes well, this will be set to true */ valid_stream = false; /* Analyze the MPEG audio stream */ if ( loadheader() ) { SDL_AudioSpec wanted; WantedSpec(&wanted); /* Calculate the samples per frame */ samplesperframe = 32*wanted.channels; if( layer == 3 ) { samplesperframe *= 18; if ( version == 0 ) { samplesperframe *= 2; } } else { samplesperframe *= SCALEBLOCK; if ( layer == 2 ) { samplesperframe *= 3; } } if ( sdl_audio ) { /* Open the audio, get actual audio hardware format and convert */ bool audio_active; SDL_AudioSpec actual; audio_active = (SDL_OpenAudio(&wanted, &actual) == 0); if ( audio_active ) { ActualSpec(&actual); valid_stream = true; } else { SetError(SDL_GetError()); } SDL_PauseAudio(0); } else { /* The stream is always valid if we don't initialize SDL */ valid_stream = true; } Volume(100); } /* For using system timestamp */ for (int i=0; i<N_TIMESTAMPS; i++) timestamp[i] = -1; }
void AudioSettings::setVolume( int volume ) { updateVolumeLabel( volume ); emit( Volume(volume) ); }
void HalfEdgeMesh::Update() { // Calculate and store all differentials and area // First update all face normals and triangle areas for(unsigned int i = 0; i < GetNumFaces(); i++){ f(i).normal = FaceNormal(i); } // Then update all vertex normals and curvature for(unsigned int i = 0; i < GetNumVerts(); i++){ // Vertex normals are just weighted averages mVerts.at(i).normal = VertexNormal(i); } // Then update vertex curvature for(unsigned int i = 0; i < GetNumVerts(); i++){ mVerts.at(i).curvature = VertexCurvature(i); // std::cerr << mVerts.at(i).curvature << "\n"; } // Finally update face curvature for(unsigned int i = 0; i < GetNumFaces(); i++){ f(i).curvature = FaceCurvature(i); } std::cerr << "Area: " << Area() << ".\n"; std::cerr << "Volume: " << Volume() << ".\n"; // Update vertex and face colors if (mVisualizationMode == CurvatureVertex) { std::vector<Vertex>::iterator iter = mVerts.begin(); std::vector<Vertex>::iterator iend = mVerts.end(); float minCurvature = (std::numeric_limits<float>::max)(); float maxCurvature = -(std::numeric_limits<float>::max)(); while (iter != iend) { if (minCurvature > (*iter).curvature) minCurvature = (*iter).curvature; if (maxCurvature < (*iter).curvature) maxCurvature = (*iter).curvature; iter++; } std::cerr << "Mapping color based on vertex curvature with range [" << minCurvature << "," << maxCurvature << "]" << std::endl; iter = mVerts.begin(); while (iter != iend) { (*iter).color = mColorMap->Map((*iter).curvature, minCurvature, maxCurvature); iter++; } } else if (mVisualizationMode == CurvatureFace) { std::vector<Face>::iterator iter = mFaces.begin(); std::vector<Face>::iterator iend = mFaces.end(); float minCurvature = (std::numeric_limits<float>::max)(); float maxCurvature = -(std::numeric_limits<float>::max)(); while (iter != iend) { if (minCurvature > (*iter).curvature) minCurvature = (*iter).curvature; if (maxCurvature < (*iter).curvature) maxCurvature = (*iter).curvature; iter++; } std::cerr << "Mapping color based on face curvature with range [" << minCurvature << "," << maxCurvature << "]" << std::endl; iter = mFaces.begin(); while (iter != iend) { (*iter).color = mColorMap->Map((*iter).curvature, minCurvature, maxCurvature); iter++; } } }
void View::setSize(double size) { recipe_->setSize(Volume(size, recipe_->size().unit())); }
static DD4hep::Geometry::Ref_t createTkLayoutTrackerBarrel(DD4hep::Geometry::LCDD& lcdd, DD4hep::XML::Handle_t xmlElement, DD4hep::Geometry::SensitiveDetector sensDet) { // shorthands DD4hep::XML::DetElement xmlDet = static_cast<DD4hep::XML::DetElement>(xmlElement); Dimension dimensions(xmlDet.dimensions()); // get sensitive detector type from xml DD4hep::XML::Dimension sdTyp = xmlElement.child(_Unicode(sensitive)); // sensitive detector used for all sensitive parts of this detector sensDet.setType(sdTyp.typeStr()); // definition of top volume // has min/max dimensions of tracker for visualization etc. std::string detectorName = xmlDet.nameStr(); DetElement topDetElement(detectorName, xmlDet.id()); Acts::ActsExtension::Config barrelConfig; barrelConfig.isBarrel = true; // detElement owns extension Acts::ActsExtension* detWorldExt = new Acts::ActsExtension(barrelConfig); topDetElement.addExtension<Acts::IActsExtension>(detWorldExt); DD4hep::Geometry::Tube topVolumeShape( dimensions.rmin(), dimensions.rmax(), (dimensions.zmax() - dimensions.zmin()) * 0.5); Volume topVolume(detectorName, topVolumeShape, lcdd.air()); topVolume.setVisAttributes(lcdd.invisible()); // counts all layers - incremented in the inner loop over repeat - tags unsigned int layerCounter = 0; double integratedModuleComponentThickness = 0; double phi = 0; // loop over 'layer' nodes in xml DD4hep::XML::Component xLayers = xmlElement.child(_Unicode(layers)); for (DD4hep::XML::Collection_t xLayerColl(xLayers, _U(layer)); nullptr != xLayerColl; ++xLayerColl) { DD4hep::XML::Component xLayer = static_cast<DD4hep::XML::Component>(xLayerColl); DD4hep::XML::Component xRods = xLayer.child("rods"); DD4hep::XML::Component xRodEven = xRods.child("rodOdd"); DD4hep::XML::Component xRodOdd = xRods.child("rodEven"); DD4hep::XML::Component xModulesEven = xRodEven.child("modules"); DD4hep::XML::Component xModulePropertiesOdd = xRodOdd.child("moduleProperties"); DD4hep::XML::Component xModulesOdd = xRodOdd.child("modules"); DD4hep::Geometry::Tube layerShape(xLayer.rmin(), xLayer.rmax(), dimensions.zmax()); Volume layerVolume("layer", layerShape, lcdd.material("Air")); layerVolume.setVisAttributes(lcdd.invisible()); PlacedVolume placedLayerVolume = topVolume.placeVolume(layerVolume); placedLayerVolume.addPhysVolID("layer", layerCounter); DetElement lay_det(topDetElement, "layer" + std::to_string(layerCounter), layerCounter); Acts::ActsExtension::Config layConfig; layConfig.isLayer = true; // the local coordinate systems of modules in dd4hep and acts differ // see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html layConfig.axes = "XzY"; // correct translation of local x axis in dd4hep to local x axis in acts // detElement owns extension Acts::ActsExtension* layerExtension = new Acts::ActsExtension(layConfig); lay_det.addExtension<Acts::IActsExtension>(layerExtension); lay_det.setPlacement(placedLayerVolume); DD4hep::XML::Component xModuleComponentsOdd = xModulePropertiesOdd.child("components"); integratedModuleComponentThickness = 0; int moduleCounter = 0; Volume moduleVolume; for (DD4hep::XML::Collection_t xModuleComponentOddColl(xModuleComponentsOdd, _U(component)); nullptr != xModuleComponentOddColl; ++xModuleComponentOddColl) { DD4hep::XML::Component xModuleComponentOdd = static_cast<DD4hep::XML::Component>(xModuleComponentOddColl); moduleVolume = Volume("module", DD4hep::Geometry::Box(0.5 * xModulePropertiesOdd.attr<double>("modWidth"), 0.5 * xModuleComponentOdd.thickness(), 0.5 * xModulePropertiesOdd.attr<double>("modLength")), lcdd.material(xModuleComponentOdd.materialStr())); unsigned int nPhi = xRods.repeat(); DD4hep::XML::Handle_t currentComp; for (unsigned int phiIndex = 0; phiIndex < nPhi; ++phiIndex) { double lX = 0; double lY = 0; double lZ = 0; if (0 == phiIndex % 2) { phi = 2 * M_PI * static_cast<double>(phiIndex) / static_cast<double>(nPhi); currentComp = xModulesEven; } else { currentComp = xModulesOdd; } for (DD4hep::XML::Collection_t xModuleColl(currentComp, _U(module)); nullptr != xModuleColl; ++xModuleColl) { DD4hep::XML::Component xModule = static_cast<DD4hep::XML::Component>(xModuleColl); double currentPhi = atan2(xModule.Y(), xModule.X()); double componentOffset = integratedModuleComponentThickness - 0.5 * xModulePropertiesOdd.attr<double>("modThickness") + 0.5 * xModuleComponentOdd.thickness(); lX = xModule.X() + cos(currentPhi) * componentOffset; lY = xModule.Y() + sin(currentPhi) * componentOffset; lZ = xModule.Z(); DD4hep::Geometry::Translation3D moduleOffset(lX, lY, lZ); DD4hep::Geometry::Transform3D lTrafo(DD4hep::Geometry::RotationZ(atan2(lY, lX) + 0.5 * M_PI), moduleOffset); DD4hep::Geometry::RotationZ lRotation(phi); PlacedVolume placedModuleVolume = layerVolume.placeVolume(moduleVolume, lRotation * lTrafo); if (xModuleComponentOdd.isSensitive()) { placedModuleVolume.addPhysVolID("module", moduleCounter); moduleVolume.setSensitiveDetector(sensDet); DetElement mod_det(lay_det, "module" + std::to_string(moduleCounter), moduleCounter); mod_det.setPlacement(placedModuleVolume); ++moduleCounter; } } } integratedModuleComponentThickness += xModuleComponentOdd.thickness(); } ++layerCounter; } Volume motherVol = lcdd.pickMotherVolume(topDetElement); PlacedVolume placedGenericTrackerBarrel = motherVol.placeVolume(topVolume); placedGenericTrackerBarrel.addPhysVolID("system", topDetElement.id()); topDetElement.setPlacement(placedGenericTrackerBarrel); return topDetElement; }