Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9c11401
GUI: user interface
ChedvaErblich Aug 4, 2024
1501851
GUI: Update .gitignore and remove ignored files from tracking
RivkiYagelnik Jul 30, 2024
480f528
GUI: Modified to ensure processes terminate and allowed the user to s…
chayaRoten Jul 31, 2024
be598ae
GUI: Make all proccesses run together and fix the end button
Tamar-Leibovitz Jul 31, 2024
ef7feee
GUI: Background completion on the entire window
chaniweisblum Aug 4, 2024
86515f3
GUI: Connect the Binary Json to the GUI
DvoraNovogrotzki Aug 4, 2024
644faf2
GUI: Log handler with update about this in mainWindow
RivkiYagelnik Aug 4, 2024
4d44f07
GUI: Add copy ctor's dragbleSquer and Process. Add members to log_han…
RivkiYagelnik Aug 5, 2024
23b2c9a
GUI: Update the process map according to information from the JSON file
RivkiYagelnik Aug 5, 2024
4e63353
GUI: Completing the log handler and creating frames
RivkiYagelnik Aug 11, 2024
816e251
GUI: Refactored MainWindow: Add deletion functionality
chayaRoten Aug 5, 2024
5ea4a58
GUI: Add editing functionality
chayaRoten Aug 7, 2024
33a4199
GUI: Enable running script files
chayaRoten Aug 7, 2024
ca2e514
GUI: Dynamic frames with information from log file
DvoraNovogrotzki Aug 14, 2024
23b0698
GUI: Finish with all test functions
Tamar-Leibovitz Aug 15, 2024
0039898
GUI: Modify code to create project configuration file with project ID
s7932 Sep 1, 2024
451284d
GUI: Move all source files to gui directory and add include directory
Sep 5, 2024
072b579
GUI: Omitting an unnecessary function named findProcessCoordinatesById
RivkiYagelnik Sep 8, 2024
62fdb49
GUI: Registering for the logger and using it in MainWindow
RivkiYagelnik Sep 8, 2024
9c781fc
GUI: Insertion of error debug sentences and information throughout th…
RivkiYagelnik Sep 8, 2024
5a6f5b6
GUI: Separate compile and run processes
Sep 10, 2024
181f49a
GUI: Allow stopping a single process while running
s7932 Sep 12, 2024
f5abe19
GUI: Change styleSheet to squers
RivkiYagelnik Sep 12, 2024
b894ccd
GUI: Add test to log_handler
RivkiYagelnik Sep 12, 2024
847d14c
GUI: Fix test functions and update CMakeLists.txt file
Sep 15, 2024
91cbfba
GUI: Add state save and load functionality
DvoraNovogrotzki Sep 15, 2024
3d31e12
GUI: Update Square Frames visualisation
DvoraNovogrotzki Sep 15, 2024
b40dcdc
GUI: Add load and show simulation buttons
DvoraNovogrotzki Sep 15, 2024
29c6fa3
GUI: Support for CTest and individual test execution
Sep 16, 2024
cdb6e59
GUI:Update executable path option and add file selection UI
chayaRoten Sep 16, 2024
955c098
GUI:Handle missing build directory creation and execute program from …
chayaRoten Sep 16, 2024
7801aa1
GUI: Fix logger files to comply with coding conventions
chayaRoten Sep 18, 2024
8d38b26
GUI: Move log files into a separate organized directory
chayaRoten Sep 18, 2024
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
43 changes: 43 additions & 0 deletions gui/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
BasedOnStyle: Google
IndentWidth: 4
TabWidth: 4
UseTab: Never
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
ColumnLimit: 80
IndentCaseLabels: true
SortIncludes: false
SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
SpacesInSquareBrackets: false
IncludeBlocks: Preserve
IncludeIsMainSourceRegex: '$'
AllowShortFunctionsOnASingleLine: Empty
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: true
AlignTrailingComments: true
BreakConstructorInitializersBeforeComma: false
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
DerivePointerAlignment: false
PointerAlignment: Right
NamespaceIndentation: None
ReflowComments: false
IndentPPDirectives: None
MaxEmptyLinesToKeep: 1
AccessModifierOffset: -4
IndentAccessModifiers: false
47 changes: 47 additions & 0 deletions gui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# CMake-related files
**/cmake-build-debug
**/CMakeCache.txt
**/cmake_install.cmake
**/install_manifest.txt
**/CMakeFiles/
**/CTestTestfile.cmake
**/Makefile
**/*.cbp
**/CMakeScripts
**/compile_commands.json
# IDE-specific files
.idea/
# Visual Studio Code
.vscode/
# Ignore build directory
build/
# Exclude generated files in include, lib, bin
include/divisible/*
lib/*
bin/*
# Test-specific files
test/test_runner
77 changes: 77 additions & 0 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
cmake_minimum_required(VERSION 3.5)

# Set the project name and version
project(DraggableSquares VERSION 1.0)

# Set C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Enable automatic generation of MOC, UIC, and RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Include current source directory
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Set the -fPIC flag to enable Position Independent Code for all targets
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Set the output directory for executables to the build directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

# Find the Qt5 library
find_package(Qt5 REQUIRED COMPONENTS Widgets Core Gui Test)

# Find the BSON library using pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(BSON REQUIRED libbson-1.0)

# Create a library for the common code
add_library(DraggableSquaresLib
src/draggable_square.cpp
src/process.cpp
src/process_dialog.cpp
src/main_window.cpp
src/simulation_state_manager.cpp
src/log_handler.cpp
src/frames.cpp
../logger/logger.cpp
)

# Add headers to the library target
target_sources(DraggableSquaresLib PRIVATE
include/main_window.h
include/draggable_square.h
include/process_dialog.h
include/simulation_state_manager.h
include/log_handler.h
include/frames.h
../logger/logger.h
)

# Include BSON directories and project include directory
target_include_directories(DraggableSquaresLib PRIVATE
${BSON_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/../logger
)

# Link the BSON library and Qt5 components to the library
target_link_libraries(DraggableSquaresLib PRIVATE ${BSON_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets)

# Create the main executable
add_executable(DraggableSquares src/main.cpp)

# Link the main executable with the library and Qt5 modules
target_link_libraries(DraggableSquares PRIVATE DraggableSquaresLib Qt5::Core Qt5::Gui Qt5::Widgets)

# Make sure the main executable has access to the include directory
target_include_directories(DraggableSquares PRIVATE ${CMAKE_SOURCE_DIR}/include ${BSON_INCLUDE_DIRS})

# Enable testing
enable_testing()

# Add the test directory
add_subdirectory(test)
File renamed without changes.
64 changes: 64 additions & 0 deletions gui/include/draggable_square.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef __DRAGGABLE_SQUARE_H__
#define __DRAGGABLE_SQUARE_H__

#include <QLabel>
#include <QMouseEvent>
#include <QWidget>
#include <QPushButton>
#include "process.h"

class DraggableSquare : public QWidget {
Q_OBJECT

public:
friend class DraggableSquareTest;
explicit DraggableSquare(
QWidget *parent = nullptr,
const QString &color =
"QWidget {"
" background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1, "
" stop: 0 #E0F7F7, stop: 1 #00BFAE);" // Gradient from mint to cyan
" border: 3px solid silver;" // Silver-colored borders
" border-radius: 10px;" // Rounded corners
"}",
int width = 120, int height = 120);
DraggableSquare(const DraggableSquare &other); // Copy constructor
DraggableSquare &operator=(
const DraggableSquare &other); // Copy assignment operator
void setProcess(Process *process);
Process *getProcess() const;
const QPoint getDragStartPosition() const;
void setDragStartPosition(QPoint dragStartPosition);
void setSquareColor(const QString &color);
int getId() const
{
return id;
}
void setId(int _id)
{
id = _id;
}
~DraggableSquare() override;
void print() const;
void setStopButtonVisible(bool visible);

protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;

private:
QPushButton *stopButton;
QLabel *label;
Process *process;
int id;
bool dragging;
QPoint dragStartPosition;

private slots:
void editSquare(int id);
void deleteSquare(int id);
void handleStopButtonClicked();
};

#endif // __DRAGGABLE_SQUARE_H__
59 changes: 59 additions & 0 deletions gui/include/frames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef __FRAMES_H__
#define __FRAMES_H__

#include "log_handler.h"
#include <QDateTime>
#include <QHash>
#include <QMap>
#include <QPainter>
#include <QPen>
#include <QSet>
#include <QString>
#include <vector>

class Frames : public QWidget {
Q_OBJECT

public:
struct Frame {
QString color;
double thickness;
};

// Ctor
Frames(LogHandler &logHandler, QWidget *parent = nullptr);

// Getters
const LogHandler &getLogHandler() const;
const std::vector<std::vector<Frame>> &getFramesMat() const;
const std::multimap<QDateTime, LogHandler::LogEntry> &getActiveLogEntries()
const;
QMap<int, int> getIdMapping() const;

// Setters
void setLogHandler(LogHandler &logHandler);
void setFramesMat(const std::vector<std::vector<Frame>> &framesMat);
void setActiveLogEntries(
const std::multimap<QDateTime, LogHandler::LogEntry> &logEntriesVector);
void setIdMapping(const QMap<int, int> &idMapping);

protected:
void paintEvent(QPaintEvent *event) override;

private slots:
void updateFrames();

private:
LogHandler &logHandler;
std::vector<std::vector<Frame>> framesMat;
std::multimap<QDateTime, LogHandler::LogEntry> activeLogEntries;
QMap<int, int> idMapping;
qint64 differenceTime;

void initialFramesMat(int size);
void createSequentialIds();
QString generateRandomColor();
void fillFramesMat();
};

#endif // __FRAMES_H__
43 changes: 43 additions & 0 deletions gui/include/log_handler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef LOGHANDLER_H
#define LOGHANDLER_H

#include "draggable_square.h"
#include <QDateTime>
#include <QDockWidget>
#include <QJsonObject>
#include <QMainWindow>
#include <QString>
#include <QTime>
#include <QVector>

class LogHandler {
public:
struct LogEntry {
QDateTime timestamp;
int srcId;
int dstId;
QString payload;
QString status; // SEND/RECEIVE

bool operator<(const LogEntry &other) const
{
return timestamp < other.timestamp;
}
};

void readLogFile(const QString &fileName);
void sortLogEntries();
void analyzeLogEntries(QMainWindow *mainWindow, const QString &jsonFileName,
bool realTime = false);
QVector<LogHandler::LogEntry> getLogEntries();
const QMap<int, DraggableSquare *> &getProcessSquares() const;

private:
QVector<LogEntry> logEntries;
QMap<int, DraggableSquare *>
processSquares; // Track process squares by their IDs
QMap<int, QMap<int, int>>
communicationCounts; // Track communication counts between process pairs
};

#endif // LOGHANDLER_H
Loading