本文整理汇总了C++中Composition类的典型用法代码示例。如果您正苦于以下问题:C++ Composition类的具体用法?C++ Composition怎么用?C++ Composition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Composition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateComposition_
void TFCompositeModifier::change_check(){
if(managing_)
{
updateComposition_();
return;
}
bool recalculate = false;
Common::TimeStamp lastChange = palette_->lastPaletteChange();
if(lastPaletteChange_ != lastChange)
{
lastPaletteChange_ = lastChange;
editors_ = palette_->getEditors();
//editors_.swap(palette_->getEditors());
bool compositionEnabled = false;
Composition newComposition;
Composition::iterator found;
for(TFPalette::Editors::iterator it = editors_.begin(); it != editors_.end(); ++it)
{
if(!it->second->hasAttribute(TFEditor::Composition) &&
it->second->getDimension() == TF_DIMENSION_1)
{
compositionEnabled = true;
found = composition_.find(it->first);
if(found != composition_.end())
{
newComposition.insert(*found);
composition_.erase(found);
}
}
}
if(!composition_.empty()) recalculate = true;
for(Composition::iterator it = composition_.begin(); it != composition_.end(); ++it)
{
layout_->removeWidget(it->second->name);
delete it->second;
}
composition_.swap(newComposition);
compositeTools_->manageButton->setEnabled(compositionEnabled);
}
for(Composition::iterator it = composition_.begin(); it != composition_.end(); ++it)
{
lastChange = it->second->editor->lastChange();
if(it->second->change != lastChange)
{
recalculate = true;
it->second->change = lastChange;
}
it->second->updateName();
}
if(recalculate) computeResultFunction_();
}
示例2: QVBoxLayout
CompositionEditor::CompositionEditor(Composition &composition, Library &library, QWidget *parent) :
QSplitter{Qt::Horizontal, parent},
draw{composition, this},
componentModel{QtListFactory::createComponentList(library.getComponents(), this)},
instances{QtListFactory::createInstanceList(composition.getInstances(), componentModel, this)},
connections{QtListFactory::createConnectionList(composition.getConnections(), this)}
{
this->addWidget(&draw);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(new QLabel("Instances"));
layout->addWidget(&instanceView);
layout->addWidget(new QLabel("Connections"));
layout->addWidget(&connectionView);
QWidget *rightPanel = new QWidget();
rightPanel->setLayout(layout);
this->addWidget(rightPanel);
instanceView.setItemDelegateForColumn(QtNameTypeItem<IComponentInstance>::TYPE_INDEX, new ComboboxItemDelegate(modelFromTypeIndex<IComponentInstance>)); //FIXME memory leak
instanceView.setModel(instances);
connectionView.setModel(connections);
connect(&draw, SIGNAL(addInstance(Point,Composition&)), this, SIGNAL(addInstance(Point,Composition&)));
}
示例3:
void
AudioSegmentResizeFromStartCommand::execute()
{
Composition *c = m_segment->getComposition();
if (!m_newSegment) {
RealTime oldRT = c->getElapsedRealTime(m_oldStartTime);
RealTime newRT = c->getElapsedRealTime(m_newStartTime);
m_newSegment = m_segment->clone(false);
m_newSegment->setStartTime(m_newStartTime);
// Compute an audio start time that will keep the audio exactly where
// it was in time.
RealTime audioStartTime =
m_segment->getAudioStartTime() - (oldRT - newRT);
// Do not allow a negative audio start time.
// ??? This is a stopgap measure as the audio segment preview code
// will crash if the audio start time is negative. Need to fix the
// preview code, then check to see if the playback code works
// properly given a negative start time. Then this can be removed.
if (audioStartTime <= RealTime::zeroTime)
m_newSegment->setAudioStartTime(RealTime::zeroTime);
else
m_newSegment->setAudioStartTime(
m_segment->getAudioStartTime() - (oldRT - newRT));
}
c->addSegment(m_newSegment);
m_newSegment->setEndMarkerTime(m_segment->getEndMarkerTime());
c->detachSegment(m_segment);
m_detached = false;
}
示例4: makeSegment
void
SegmentJoinCommand::execute()
{
Composition *composition = m_oldSegments[0]->getComposition();
if (!composition) {
RG_DEBUG << "SegmentJoinCommand::execute: ERROR: old segments are not in composition!";
return ;
}
if (!m_newSegment) {
m_newSegment = makeSegment(m_oldSegments);
}
composition->addSegment(m_newSegment);
// Select this new joined segment.
RosegardenMainWindow::self()->getView()->getTrackEditor()->
getCompositionView()->getModel()->setSelected(m_newSegment);
for (size_t i = 0; i < m_oldSegments.size(); ++i) {
composition->detachSegment(m_oldSegments[i]);
}
m_detached = true;
}
示例5: clef
void
MupExporter::writeClefAndKey(std::ofstream &str, TrackId trackNo)
{
Composition *c = m_composition;
for (Composition::iterator i = c->begin(); i != c->end(); ++i) {
if ((*i)->getTrack() == trackNo) {
Clef clef((*i)->getClefAtTime((*i)->getStartTime()));
Rosegarden::Key key((*i)->getKeyAtTime((*i)->getStartTime()));
str << "staff " << trackNo + 1 << "\n";
if (clef.getClefType() == Clef::Treble) {
str << "\tclef=treble\n";
} else if (clef.getClefType() == Clef::Alto) {
str << "\tclef=alto\n";
} else if (clef.getClefType() == Clef::Tenor) {
str << "\tclef=tenor\n";
} else if (clef.getClefType() == Clef::Bass) {
str << "\tclef=bass\n";
}
str << "\tkey=" << key.getAccidentalCount()
<< (key.isSharp() ? "#" : "&")
<< (key.isMinor() ? "minor" : "major") << std::endl;
m_clefKeyMap[trackNo] = ClefKeyPair(clef, key);
return ;
}
}
}
示例6: visit
void RizzlyPrint::visit(const Composition &composition)
{
for (const auto *inst : composition.getInstances()) {
inst->accept(*this);
}
for (const auto *con : composition.getConnections()) {
con->accept(*this);
}
}
示例7: CompositionInstanceMock
void CompositionTest::has_instance_with_his_parent_component()
{
ICompositionInstance *compInstance = new CompositionInstanceMock();
Composition *composition = new Composition(compInstance);
CPPUNIT_ASSERT_EQUAL(compInstance, composition->getSelfInstance());
CompositionFactory::dispose(composition);
}
示例8:
QStringList
ProjectPackager::getAudioFiles()
{
QStringList list;
// get the Composition from the document, so we can iterate through it
Composition *comp = &m_doc->getComposition();
// We don't particularly care about tracks here, so just iterate through the
// entire Composition to find the audio segments and get the associated
// file IDs from which to obtain a list of actual files. This could
// conceivably pick up audio segments that are residing on MIDI tracks and
// wouldn't otherwise be functional, but the important thing is to never
// miss a single file that has any chance of being worth preserving.
for (Composition::iterator i = comp->begin(); i != comp->end(); ++i) {
if ((*i)->getType() == Segment::Audio) {
AudioFileManager *manager = &m_doc->getAudioFileManager();
unsigned int id = (*i)->getAudioFileId();
AudioFile *file = manager->getAudioFile(id);
// some polite sanity checking to avoid possible crashes
if (!file) continue;
list << file->getFilename();
}
}
// QStringList::removeDuplicates() would have been easy, but it's only in Qt
// 4.5.0 and up. So here's the algorithm from Qt 4.5.0, courtesy of (and
// originally Copyright 2009) Nokia
QStringList *that = &list;
int n = that->size();
int j = 0;
QSet<QString> seen;
seen.reserve(n);
for (int i = 0; i < n; ++i) {
const QString &s = that->at(i);
if (seen.contains(s))
continue;
seen.insert(s);
if (j != i)
(*that)[j] = s;
++j;
}
if (n != j)
that->erase(that->begin() + j, that->end());
// return n - j;
return list;
}
示例9: Composition
void CompositionTest::getInstance()
{
Composition *composition = new Composition(new CompositionInstanceMock());
Component *component = ComponentFactory::produce("Component", {}, {});
IComponentInstance *instance = InstanceFactory::produce(component, "instance", Point(0,0));
composition->getInstances().add(instance);
CPPUNIT_ASSERT_EQUAL(instance, composition->getInstance("instance"));
CompositionFactory::dispose(composition);
ComponentFactory::dispose(component);
}
示例10: Leaf
void MainWindow::testComposition()
{
Leaf *pLeaf = new Leaf();
pLeaf->operation();
Composition *pComposion = new Composition();
pComposion->add(pLeaf);
pComposion->operation();
Component *pCom2 = pComposion->child(0);
pCom2->operation();
}
示例11: clearLayout_
void TFCompositeModifier::updateComposition_(){
Selection selection = manager_.getComposition();
clearLayout_();
bool recalculate = false;
M4D::Common::TimeStamp lastChange;
Editor* editor;
Composition newComposition;
Composition::iterator found;
for(Selection::iterator it = selection.begin(); it != selection.end(); ++it)
{
found = composition_.find(*it);
if(found == composition_.end())
{
editor = new Editor(editors_.find(*it)->second);
newComposition.insert(std::make_pair<TF::Size, Editor*>(
*it,
editor)
);
recalculate = true;
}
else
{
lastChange = found->second->editor->lastChange();
if(found->second->change != lastChange)
{
recalculate = true;
found->second->change = lastChange;
}
editor = found->second;
editor->updateName();
newComposition.insert(*found);
composition_.erase(found);
}
layout_->addWidget(editor->name);
}
layout_->addItem(pushUpSpacer_);
if(!composition_.empty()) recalculate = true;
for(Composition::iterator it = composition_.begin(); it != composition_.end(); ++it)
{
layout_->removeWidget(it->second->name);
delete it->second;
}
composition_.swap(newComposition);
if(recalculate) computeResultFunction_();
}
示例12: assert
SpecializedComponentBase CompositionObj::getSpecialized(std::shared_ptr<ComponentObj> _obj, std::string name){
assert(this == _obj.get());
if (auto spec = dynamic_cast<SpecializedComponentObjBase *>(this)) {
auto obj = std::dynamic_pointer_cast<CompositionObj>(spec->getOrginal());
assert(obj);
auto s = SpecializedComponentObj<CompositionObj>::make(obj, pool, name);
s->configuration = spec->configuration;
s->replaced_children = spec->replaced_children;
s->setActive(spec->isActive());
return s;
}
Composition obj = std::dynamic_pointer_cast<CompositionObj>(_obj);
assert(obj.get());
return SpecializedComponentObj<CompositionObj>::make(obj, pool,name);
}
示例13: Note
timeT
MatrixPercussionInsertionCommand::getEndTime(Segment &segment,
timeT time,
Event &event)
{
timeT endTime =
time + Note(Note::Semibreve,
0).getDuration();
timeT barEndTime = segment.getBarEndForTime(time);
timeT segmentEndTime = segment.getEndMarkerTime();
if (barEndTime > endTime)
endTime = barEndTime;
if (endTime > segmentEndTime)
endTime = segmentEndTime;
int pitch = 0;
if (event.has(PITCH)) {
pitch = event.get<Int>(PITCH);
}
for (Segment::iterator i = segment.findTime(time);
segment.isBeforeEndMarker(i); ++i) {
if ((*i)->has(PITCH) &&
(*i)->get
<Int>(PITCH) == pitch) {
if ((*i)->getAbsoluteTime() > time &&
(*i)->isa(Note::EventType)) {
endTime = (*i)->getAbsoluteTime();
}
}
}
Composition *comp = segment.getComposition();
std::pair<timeT, timeT> barRange =
comp->getBarRangeForTime(time);
timeT barDuration = barRange.second - barRange.first;
if (endTime > time + barDuration) {
endTime = time + barDuration;
}
return endTime;
}
示例14: printer
void RizzlyPrintTest::onlyInstance()
{
std::stringstream ss;
RizzlyPrint printer(ss);
Component *component = ComponentFactory::produce("Component", {}, {});
Instance *instance = InstanceFactory::produce(component, "instance", Point(0,0));
Composition *composition = new Composition(new CompositionInstanceMock());
composition->getInstances().add(instance);
printer.print(*composition);
std::vector<std::string> listing = asList(ss);
CPPUNIT_ASSERT_EQUAL(size_t(1), listing.size());
CPPUNIT_ASSERT_EQUAL(std::string("instance: Component;"), listing[0]);
CompositionFactory::dispose(composition);
ComponentFactory::dispose(component);
}
示例15: getTempoChange
// Get the current tempos of the composition
// @param A composition
// @param Reference to a TempoMap, to be filled.
// @author Tom Breton (Tehom)
void
FitToBeatsCommand::getCurrentTempi(Composition &composition, TempoMap &Tempos)
{
const int numTempoChanges = composition.getTempoChangeCount();
for (int i = 0; i < numTempoChanges; ++i) {
TempoChange tempoChange =
getTempoChange(composition, i);
Tempos[tempoChange.first] = tempoChange.second;
}
}