/*
* Copyright 2019 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Text;
namespace SourceGen {
///
/// A visualization with animated contents.
///
///
/// References to Visualization objects (such as a 3D mesh or list of bitmaps) are held
/// here. The VisGenParams property holds animation properties, such as frame rate and
/// view angles.
///
public class VisualizationAnimation : Visualization {
///
/// Frame delay parameter.
///
public const string FRAME_DELAY_MSEC_PARAM = "frame-delay-msec";
///
/// Fake visualization generation identifier.
///
public const string ANIM_VIS_GEN = "(animation)";
///
/// Serial numbers of visualizations, e.g. bitmap frames.
///
///
/// We don't reference the Visualization objects directly because they might get
/// edited (e.g. the tag gets renamed), which replaces them with a new object with
/// the same serial number. We don't do things like renames in place because that
/// makes undo/redo harder.
///
/// (We could reference the Visualization objects and then do a serial number lookup
/// before using it. Some opportunities for optimization should the need arise. This
/// might also allow us to avoid exposing the serial number as a public property, though
/// there's not much advantage to that.)
///
private List mSerialNumbers;
///
/// Constructor.
///
/// Unique identifier.
/// Visualization generator identifier.
/// Parameters for visualization generator.
/// Serial numbers of referenced Visualizations.
public VisualizationAnimation(string tag, string visGenIdent,
ReadOnlyDictionary visGenParams, List visSerialNumbers)
: base(tag, visGenIdent, visGenParams) {
Debug.Assert(visSerialNumbers != null);
mSerialNumbers = visSerialNumbers;
}
///
/// Returns true if this visualization holds a reference to the specified serial number.
///
public bool ContainsSerial(int serial) {
// Linear search. We don't do this a lot and our lists our short, so okay for now.
foreach (int ser in mSerialNumbers) {
if (ser == serial) {
return true;
}
}
return false;
}
}
}