Skip to content
Merged

1.5.3 #110

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified images/color-theme01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/color-theme02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/color-theme03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/color-theme04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/color-theme05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/defects/issue-106.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/defects/issue-106b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/defects/test_timeline_case01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/demo01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/gallery/gallery-DEFAULT-halfyearly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/gallery/gallery-DEFAULT-quarterly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions src/roadmapper/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .painter import Painter
from .timeline import Timeline
from .task import Task

from .helper import Helper

@dataclass
class Group:
Expand Down Expand Up @@ -133,9 +133,6 @@ def set_draw_position(self, painter: Painter, timeline: Timeline) -> None:
+ (5 * task_count)
+ (2 * (task_count - 1))
)
# print(f"{'-' * 20} Group height: {self.box_height}")
# print(f"{'-' * 20} Task count: {task_count}")
# print(f"{'-' * 20} Milestone count: {milestone_count}")

self.box_width = (
painter.width - (painter.left_margin + painter.right_margin)
Expand All @@ -156,9 +153,17 @@ def set_draw_position(self, painter: Painter, timeline: Timeline) -> None:
self.font_size,
)

Helper.printc(
f"Group: [{self.text}], x: {self.box_x}, y: {self.box_y}, width: {self.box_width}, height: {self.box_height}",
show_level="group",
)

painter.next_y_pos = self.box_y
for task in self.tasks:
task.set_draw_position(painter, self.box_x, painter.next_y_pos, timeline)
Helper.printc(
f"\tTask: [{task.text}], x: {task.box_x}, y: {task.box_y}, width: {task.box_width}, height: {task.box_height}",
show_level="task",)

painter.next_y_pos = self.box_y + self.box_height

Expand Down
29 changes: 26 additions & 3 deletions src/roadmapper/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import inspect
import logging
import uuid
from rich.console import Console
from rich.panel import Panel


class Helper:
show_timeline = False
show_group = False
show_task = True
show_task = False
show_parallel_task = False
show_milestone = False
show_marker = False
show_title = False
show_header = False
show_footer = False
show_logo = False
show_timeline = True

@staticmethod
def should_show_message(show_level: str) -> bool:
Expand All @@ -60,19 +61,41 @@ def printc(
end: str = "\n",
rich_type: str = "text",
show_level: str = "general",
true_condition: bool = True,
):
"""Print text in color"""

root_logger = logging.getLogger()

call_depth = len(inspect.stack())

if call_depth < 5:
call_depth = 0
else:
call_depth -= 5

caller = inspect.stack()[1].function

# determine the caller class name
if "self" in inspect.stack()[1].frame.f_locals:
caller_class = inspect.stack()[1].frame.f_locals["self"].__class__.__name__

# add \t tab to the print message if for each level of call depth
message = "\t" * call_depth + message

if (
root_logger.getEffectiveLevel() == logging.DEBUG
and Helper.should_show_message(show_level)
and true_condition
):
console = Console()
if rich_type == "text":
style_attribute = "reverse" if reverse else ""
console.print(message, end=end, style=style_attribute)
console.print(
f"{caller_class}.{caller}(): {message}",
end=end,
style=style_attribute,
)
elif rich_type == "panel":
console.print(Panel(message), style="blue")

Expand Down
35 changes: 30 additions & 5 deletions src/roadmapper/marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from dataclasses import dataclass, field
from .painter import Painter
from .timeline import Timeline
from .helper import Helper


@dataclass(kw_only=True)
Expand All @@ -47,6 +48,7 @@ class Marker:
line_to_x: int = field(init=False, default=0)
line_to_y: int = field(init=False, default=0)
not_in_timeline_range: bool = field(init=False, default=False)
current_date: datetime = field(init=False, default=None)

def set_label_draw_position(self, painter: Painter, timeline: Timeline) -> None:
"""Set marker label draw position
Expand All @@ -55,20 +57,29 @@ def set_label_draw_position(self, painter: Painter, timeline: Timeline) -> None:
painter (Painter): Pillow wrapper class instance
timeline (Timeline): Timeline instance
"""
current_date = datetime.now()
current_date = current_date.replace(hour=0, minute=0, second=0, microsecond=0)
self.current_date = datetime.now()


current_date = self.current_date.replace(hour=0, minute=0, second=0, microsecond=0)
label_pos_percentage = 0
correct_timeline = False
for timeline_item in timeline.timeline_items:
if timeline_item.start <= current_date <= timeline_item.end:
if timeline_item.start <= self.current_date <= timeline_item.end:
# calc label position
# --- FIX for #106 Missing marker (Start) ---
# Ignore correct_time. Always set to True
(
correct_timeline,
_,
label_pos_percentage,
) = timeline_item.get_timeline_pos_percentage(
timeline.mode, current_date
)
if correct_timeline is True:

# If the current date is the same as the start date of the timeline item,
# then the marker should be displayed at the start of the timeline item.
correct_timeline = True
# --- FIX for #106 Missing marker (End) ---
if correct_timeline:
break

self.not_in_timeline_range = not correct_timeline
Expand All @@ -81,6 +92,7 @@ def set_label_draw_position(self, painter: Painter, timeline: Timeline) -> None:
)
self.label_x = self.line_from_x - (self.label_width / 2) + 1
self.line_from_y = self.label_y + self.label_height + 4

painter.next_y_pos = self.label_y + self.label_height

def set_line_draw_position(self, painter: Painter) -> None:
Expand All @@ -98,6 +110,19 @@ def draw(self, painter: Painter) -> None:
Args:
painter (Painter): Pillow wrapper class instance
"""
Helper.printc(
f"Marker current date: {self.current_date}",
show_level="marker",
)
Helper.printc(
f"Marker label: x: {self.label_x}, y: {self.label_y}, width: {self.label_width}, height: {self.label_height}",
show_level="marker",
)
Helper.printc(
f"Marker line: x: {self.line_from_x}, y: {self.line_from_y}, line_to_x: {self.line_to_x}, line_to_y: {self.line_to_y}",
show_level="marker",
)

if self.not_in_timeline_range is False:
painter.draw_text(
self.label_x,
Expand Down
15 changes: 0 additions & 15 deletions src/roadmapper/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from .milestone import Milestone
from .painter import Painter
from .timeline import Timeline
from .helper import Helper


@dataclass(kw_only=True)
Expand Down Expand Up @@ -422,11 +421,6 @@ def set_task_position(
previous_start = timeline_start_period
previous_end = timeline_end_period

Helper.printc(
f"timeline ({timeline_start_period}, {timeline_end_period}), task ({task_start_period}, {task_end_period})",
show_level="task",
)

### Check if the task is within the timeline period
if (
self.is_task_in_range(
Expand All @@ -437,7 +431,6 @@ def set_task_position(
)
is True
):
Helper.printc("\tIn range...", show_level="task")
(
_,
start_pos_percentage,
Expand All @@ -463,7 +456,6 @@ def set_task_position(
)
is True
):
Helper.printc("Task begins here ends here...", show_level="task")
self.box_x = timeline_item.box_x + (
timeline_item.box_width * start_pos_percentage
)
Expand All @@ -482,7 +474,6 @@ def set_task_position(
)
is True
):
Helper.printc("is_task_begins_past_ends_here...", show_level="task")
self.box_x = timeline_item.box_x
if bar_start_x_pos == 0:
bar_start_x_pos = self.box_x
Expand All @@ -498,9 +489,6 @@ def set_task_position(
)
is True
):
Helper.printc(
"is_task_begins_here_ends_future...", show_level="task"
)
self.box_x = timeline_item.box_x + (
timeline_item.box_width * start_pos_percentage
)
Expand All @@ -519,9 +507,6 @@ def set_task_position(
)
is True
):
Helper.printc(
"is_task_begins_past_ends_future...", show_level="task"
)
self.box_x = timeline_item.box_x
self.box_width = timeline_item.box_width

Expand Down
Loading