# Path: pytripgui/field_vc/field_model.py
# class FieldModel(Field):
#     def __init__(self, field=Field(), angles_standard=AnglesStandard.TRIP):
#         super().__init__(field)
#         self.angles_standard = angles_standard
# 
#     @property
#     def gantry_angle_trip98(self):
#         return self.gantry
# 
#     @property
#     def couch_angle_trip98(self):
#         return self.couch
# 
#     @gantry_angle_trip98.setter
#     def gantry_angle_trip98(self, angle):
#         self.gantry = angle
# 
#     @couch_angle_trip98.setter
#     def couch_angle_trip98(self, angle):
#         self.couch = angle
# 
# Path: pytripgui/plan_executor/patient_model.py
# class PatientModel:
#     def __init__(self):
#         self.name = "Patient"
#         self.ctx = None
#         self.vdx = None
#         self.dcm = None
# 
#         self.plans = []
# 
#     def open_ctx(self, path):
#         ctx = pt.CtxCube()
#         ctx.read(path)
#         self.ctx = ctx
#         self.name = ctx.basename
# 
#     def open_vdx(self, path):
#         vdx = pt.VdxCube(self.ctx)
#         vdx.read(path)
#         self.vdx = vdx
#         if self.name != vdx.basename:
#             logger.error("CTX | VDX patient name not match")
# 
#     def open_dicom(self, path):
#         self.dcm = pt.dicomhelper.read_dicom_dir(path)
# 
#         if 'images' in self.dcm:
#             self.ctx = pt.CtxCube()
#             self.ctx.read_dicom(self.dcm)
#             self.name = self.ctx.basename
# 
#         if 'rtss' in self.dcm:
#             self.vdx = pt.VdxCube(self.ctx)
#             self.vdx.read_dicom(self.dcm)
#             self.name = self.vdx.basename


import logging
from anytree import NodeMixin
from pytripgui.field_vc.field_model import FieldModel
from pytripgui.plan_executor.patient_model import PatientModel
from pytrip.tripexecuter.plan import Plan
from pytrip.tripexecuter.kernel import KernelModel



logger = logging.getLogger(__name__)


class TreeItem(NodeMixin):
    def __init__(self):
        self.children = ()
        self.data = None
        self.state = None

    # For qt TreeView
    def has_index(self, p_int):
        return p_int < len(self.children)

    def has_children(self):
        return len(self.children) > 0

    def row_count(self):
        return len(self.children)

    def index(self, p_int, p_int_1):
        # only one column is supported
        if not self.has_index(p_int) or p_int_1 != 0:

# Path: pytripgui/field_vc/field_model.py
# class FieldModel(Field):
#     def __init__(self, field=Field(), angles_standard=AnglesStandard.TRIP):
#         super().__init__(field)
#         self.angles_standard = angles_standard
# 
#     @property
#     def gantry_angle_trip98(self):
#         return self.gantry
# 
#     @property
#     def couch_angle_trip98(self):
#         return self.couch
# 
#     @gantry_angle_trip98.setter
#     def gantry_angle_trip98(self, angle):
#         self.gantry = angle
# 
#     @couch_angle_trip98.setter
#     def couch_angle_trip98(self, angle):
#         self.couch = angle
# 
# Path: pytripgui/plan_executor/patient_model.py
# class PatientModel:
#     def __init__(self):
#         self.name = "Patient"
#         self.ctx = None
#         self.vdx = None
#         self.dcm = None
# 
#         self.plans = []
# 
#     def open_ctx(self, path):
#         ctx = pt.CtxCube()
#         ctx.read(path)
#         self.ctx = ctx
#         self.name = ctx.basename
# 
#     def open_vdx(self, path):
#         vdx = pt.VdxCube(self.ctx)
#         vdx.read(path)
#         self.vdx = vdx
#         if self.name != vdx.basename:
#             logger.error("CTX | VDX patient name not match")
# 
#     def open_dicom(self, path):
#         self.dcm = pt.dicomhelper.read_dicom_dir(path)
# 
#         if 'images' in self.dcm:
#             self.ctx = pt.CtxCube()
#             self.ctx.read_dicom(self.dcm)
#             self.name = self.ctx.basename
# 
#         if 'rtss' in self.dcm:
#             self.vdx = pt.VdxCube(self.ctx)
#             self.vdx.read_dicom(self.dcm)
#             self.name = self.vdx.basename


# Path: pytripgui/tree_vc/tree_items.py
import logging
from anytree import NodeMixin
from pytripgui.field_vc.field_model import FieldModel
from pytripgui.plan_executor.patient_model import PatientModel
from pytrip.tripexecuter.plan import Plan
from pytrip.tripexecuter.kernel import KernelModel




logger = logging.getLogger(__name__)


class TreeItem(NodeMixin):
    def __init__(self):
        self.children = ()
        self.data = None
        self.state = None

    # For qt TreeView
    def has_index(self, p_int):
        return p_int < len(self.children)

    def has_children(self):
        return len(self.children) > 0

    def row_count(self):
        return len(self.children)

    def index(self, p_int, p_int_1):
        # only one column is supported
        if not self.has_index(p_int) or p_int_1 != 0:

            return None