from usecases.clear_work_space_document_use_case import (
    ClearWorkSpaceDocumentUseCase,
)
from geometric_feasibility_predicate.usecases.get_collision_at_primitive_use_case import (
    GetCollisionAtPrimitiveUseCase,
)
from usecases.get_part_primitive_coordinates_use_case import (
    GetPartPrimitiveCoordinatesUseCase,
)
from usecases.init_parts_parse_use_case import (
    InitPartsParseUseCase,
)
from usecases.render_primitive_use_case import (
    RenderPrimitiveUseCase,
)


class RenderPrimitivesScenario(object):
    def __init__(
        self,
        initPartsParseUseCase: InitPartsParseUseCase,
        getPartPrimitiveCoordinatesUseCase: GetPartPrimitiveCoordinatesUseCase,
        renderPrimitiveUseCase: RenderPrimitiveUseCase,
        getCollisionAtPrimitives: GetCollisionAtPrimitiveUseCase,
        clearWorkSpaceDocument: ClearWorkSpaceDocumentUseCase,
    ) -> None:
        self.initPartsParseUseCase = initPartsParseUseCase
        self.getPartPrimitiveCoordinatesUseCase = getPartPrimitiveCoordinatesUseCase
        self.renderPrimitiveUseCase = renderPrimitiveUseCase
        self.getCollisionAtPrimitives = getCollisionAtPrimitives
        self.clearWorkSpaceDocument = clearWorkSpaceDocument

    def call(self) -> None:
        meshCoordinates = []
        detailSquares = {}
        parts = self.initPartsParseUseCase.call()
        meshCoordinates = self.getPartPrimitiveCoordinatesUseCase.call(parts)
        self.renderPrimitiveUseCase.call(meshCoordinates, detailSquares)
        matrix = self.getCollisionAtPrimitives.call(parts, detailSquares)
        self.clearWorkSpaceDocument.call(detailSquares)
        return matrix
