bool LayeredConstruction_Impl::insertLayer(unsigned layerIndex, const Material& material) { OS_ASSERT(material.model() == model()); layerIndex = mf_clearNullLayers(layerIndex); unsigned n = numLayers(); MaterialVector layers = this->layers(); MaterialVector::iterator layersBegin = layers.begin(); MaterialVector::iterator layersEnd = layers.end(); MaterialVector::iterator insertAtIt = layersBegin; while ((static_cast<unsigned>(insertAtIt - layersBegin) < layerIndex) && (insertAtIt != layersEnd)) { ++insertAtIt; } layers.insert(insertAtIt, material); OS_ASSERT(layers.size() == ++n); if ((model().strictnessLevel() < StrictnessLevel::Final) || LayeredConstruction::layersAreValid(layers)) { IdfExtensibleGroup idfGroup = insertExtensibleGroup(layerIndex,StringVector()); OS_ASSERT(!idfGroup.empty()); ModelExtensibleGroup group = idfGroup.cast<ModelExtensibleGroup>(); bool ok = group.setPointer(0,material.handle()); OS_ASSERT(ok); return true; } return false; }
void CSobeyView::ComputerTimeLineLength(MaterialVector& timeLine) { m_timeLineLength = 0; if (timeLine.empty()) return; for (MaterialVector::iterator it = timeLine.begin(); it != timeLine.end(); ++it) { m_timeLineLength += abs(it->endTime - it->beginTime); } }
void CSobeyView::ComputerTimeLineRect(MaterialVector& timeLine) { ComputerTimeLineLength(timeLine); m_timeLineRect.clear(); if (timeLine.empty()) return; int top = 10; int left = 10; int width = 0; int height = 50; CRect windowRect; GetWindowRect(&windowRect); // 计算出窗体的大小作为比率 int base = windowRect.right - windowRect.left - 20; for (MaterialVector::iterator it = timeLine.begin(); it != timeLine.end(); ++it) { left += width + 1; // 素材的宽度等于素材时间长度和时间线总长的比值乘以窗体大小 width = abs(it->endTime - it->beginTime) * base / m_timeLineLength; m_timeLineRect.push_back(CRect(left, top, left + width, top + height)); } }