}
#[typetag::serde]
-pub trait OccultedPieceTrait: OutlineTrait {
+pub trait InertPieceTrait: OutlineTrait {
fn svg(&self, f: &mut Html, id: VisiblePieceId) -> Result<(),IE>;
fn describe_html(&self) -> Result<Html,IE>;
}
pub occultable: PieceSpecLoadedOccultable,
}
pub type PieceSpecLoadedOccultable =
- Option<(OccultIlkName, Arc<dyn OccultedPieceTrait>)>;
+ Option<(OccultIlkName, Arc<dyn InertPieceTrait>)>;
#[typetag::serde(tag="type")]
pub trait PieceSpec: Debug + Sync + Send + 'static {
fn count(&self, _pcaliases: &PieceAliases) -> usize { 1 }
fn load(&self, i: usize, gpc: &mut GPiece, ig: &Instance, depth: SpecDepth)
-> Result<PieceSpecLoaded, SpecError>;
- fn load_occult(&self, _ig: &Instance, _:SpecDepth)
- -> Result<Box<dyn OccultedPieceTrait>, SpecError> {
- throw!(SpE::ComplexPieceWhereSimpleRequired)
+ /// Used when a piece wants to use another for its occulted form
+ fn load_inert(&self, _ig: &Instance, _:SpecDepth)
+ -> Result<Box<dyn InertPieceTrait>, SpecError> {
+ throw!(SpE::ComplexPieceWhereInertRequired)
}
}
#[throws(IE)]
pub fn show_or_instead<'p>(&self, ioccults: &'p IOccults,
y: Option<ShowUnocculted>)
- -> Either<ShowUnocculted, &'p dyn OccultedPieceTrait> {
+ -> Either<ShowUnocculted, /*occulted*/ &'p dyn InertPieceTrait> {
match y {
Some(y) => Left(y),
None => Right({
#[derive(Debug,Serialize,Deserialize)]
pub struct OccultIlkData {
- pub p_occ: Arc<dyn OccultedPieceTrait>,
+ pub p_occ: Arc<dyn InertPieceTrait>,
}
type Id = OccultIlkId;
r
}
#[throws(SpecError)]
- fn load_occult(&self, ig: &Instance, depth: SpecDepth)
- -> Box<dyn OccultedPieceTrait> {
- self.resolve(&ig.pcaliases)?.load_occult(ig, self.new_depth(depth)?)?
+ fn load_inert(&self, ig: &Instance, depth: SpecDepth)
+ -> Box<dyn InertPieceTrait> {
+ self.resolve(&ig.pcaliases)?.load_inert(ig, self.new_depth(depth)?)?
}
}
impl<P,Z> PriOccultedGeneral<P,Z> {
#[throws(IE)]
pub fn instead<'p>(&self, ioccults: &'p IOccults, p: &'p IPiece)
- -> Either<ShowUnocculted, &'p dyn OccultedPieceTrait>
+ -> Either<ShowUnocculted, /*occulted*/ &'p dyn InertPieceTrait>
{
p.show_or_instead(ioccults, self.fully_visible())?
}
descs: IndexVec<DescId, Html>,
outline: Outline,
#[serde(default)]
- back: Option<Arc<dyn OccultedPieceTrait>>,
+ back: Option<Arc<dyn InertPieceTrait>>,
}
#[derive(Debug,Serialize,Deserialize)]
-struct ItemOccultable {
+struct ItemInertForOcculted {
desc: Html,
svgd: Arc<Html>,
xform: FaceTransform,
}
#[dyn_upcast]
-impl OutlineTrait for ItemOccultable { delegate! { to self.outline {
+impl OutlineTrait for ItemInertForOcculted { delegate! { to self.outline {
fn outline_path(&self, scale: f64) -> Result<Html, IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
fn bbox_approx(&self) -> Result<Rect, IE>;
}}}
#[typetag::serde(name="Lib")]
-impl OccultedPieceTrait for ItemOccultable {
+impl InertPieceTrait for ItemInertForOcculted {
#[throws(IE)]
fn svg(&self, f: &mut Html, _: VisiblePieceId) {
self.xform.write_svgd(f, &self.svgd)?;
}
#[typetag::serde(name="LibItem")]
-impl OccultedPieceTrait for Item {
+impl InertPieceTrait for Item {
#[throws(IE)]
fn svg(&self, f: &mut Html, id: VisiblePieceId) {
self.svg_face(f, default(), id)?;
.map_err(|e| SpE::InternalError(format!("reckoning transform: {}",&e)))?;
let mut face = ItemFace { svg, desc, xform };
let mut faces = index_vec![ face ];
- let mut back = None::<Arc<dyn OccultedPieceTrait>>;
+ let mut back = None::<Arc<dyn InertPieceTrait>>;
if idata.group.d.flip {
face.xform.scale[0] *= -1.;
faces.push(face);
} else if let Some(back_spec) = &idata.group.d.back {
- match back_spec.load_occult(ig, depth) {
+ match back_spec.load_inert(ig, depth) {
Err(SpecError::AliasNotFound) => { },
Err(e) => throw!(e),
Ok(p) => {
)?;
Ok(Arc::new(occ_data))
}).clone()?;
- let it = Arc::new(ItemOccultable {
+ let it = Arc::new(ItemInertForOcculted {
svgd,
xform: occ.xform.clone(),
desc: occ.desc.clone(),
outline: occ.outline.clone(),
- }) as Arc<dyn OccultedPieceTrait>;
+ }) as Arc<dyn InertPieceTrait>;
Some((OccultIlkName(occ_name.into_inner()), it))
},
};
self.find_load(ig,depth)?.into()
}
#[throws(SpecError)]
- fn load_occult(&self, ig: &Instance, depth: SpecDepth)
- -> Box<dyn OccultedPieceTrait> {
- self.find_load(ig,depth)?.0 as Box<dyn OccultedPieceTrait>
+ fn load_inert(&self, ig: &Instance, depth: SpecDepth)
+ -> Box<dyn InertPieceTrait> {
+ self.find_load(ig,depth)?.0 as Box<dyn InertPieceTrait>
}
}
#[error("specified with of edges, but no edges")] SpecifiedWidthOfNoEdges,
#[error("shape not supported")] UnsupportedShape,
#[error("negative timeout")] NegativeTimeout,
- #[error("complex piece where simple needed")] ComplexPieceWhereSimpleRequired,
+ #[error("complex piece where inert needed")] ComplexPieceWhereInertRequired,
#[error("piece alias not found")] AliasNotFound,
#[error("piece alias target is multi spec")] AliasTargetMultiSpec,
#[error("piece alias loop")] AliasLoop(String),