Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gui to edit FeatureModels #112

Open
wants to merge 116 commits into
base: vara-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
49d4adc
Add base graph implementation based on qt example
Sinerum Nov 4, 2022
f2c949e
add function to position the nodes in a tree like structure
Nov 7, 2022
9a5c030
Remove usage of unique pointer because qt does not like that.
Sinerum Nov 7, 2022
e85c7af
add ui
Sinerum Nov 15, 2022
8a89717
build the main gui
Nov 29, 2022
2cd9b06
add Feature Add Dialog
Sinerum Dec 20, 2022
9aa6a9e
add syntax highlighting and feature source highlighting
Sinerum Jan 9, 2023
38f5959
Rewrite the Code for positioning Nodes
Sinerum Jan 17, 2023
1d47e77
Add tree view as alternative for view for feature model.
Sinerum Feb 6, 2023
32c454e
Removes deprecated std::iterator (#97)
vulder Nov 7, 2022
7507cbb
Updates python binding library (#99)
vulder Nov 8, 2022
a255aa4
Move to LLVM 14 (#98)
vulder Nov 9, 2022
fda30dc
Add Relationships Iterator and Sort Methods in Header (#95)
s9latimm Nov 13, 2022
466bcba
Add Output String For Features (#100)
s9latimm Nov 16, 2022
6c1b073
Adds parsing of step functions (#103)
s9latimm Dec 18, 2022
0e48b9c
Adds Revision Range (#101)
s9latimm Dec 19, 2022
72cc0b9
Bugfix in `FeatureModelBuilder::makeRoot` (#104)
vulder Dec 19, 2022
5568161
Display outputstring of feature in treeview
Feb 7, 2023
f89ad52
Extend Feature AddDialog to provide choice of feature type
Sinerum Feb 7, 2023
59b3038
Add contextMenu to FeatureTreeItems
Sinerum Feb 7, 2023
b69fba0
Add Function to get type of added feature
Sinerum Feb 14, 2023
d350add
Add the ability to add sources to features
Sinerum Feb 14, 2023
b893910
Load feature information when selecting feature in treeview
Sinerum Feb 14, 2023
81b1d36
Refactor and add full functionality to feature adding.
Sinerum Feb 15, 2023
626fa78
Allow FeatureAddDialog to take a predefined parent
Feb 16, 2023
e476851
Fix states for numeric value selection
Feb 16, 2023
a1c59fc
Add new features to relations if present, and add context menu option…
Feb 16, 2023
50be685
Add the ability to remove features from the model
Sinerum Feb 22, 2023
e3a13a5
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Feb 22, 2023
8e4b0e3
remove Changes accidentally made by merging
Sinerum Feb 22, 2023
248e928
Apply suggestions from flangformater
Sinerum Feb 22, 2023
e01fd2f
Apply suggestions from formater
Sinerum Feb 22, 2023
ba588a4
revert accidental rename by clion
Sinerum Feb 22, 2023
ea1d7e8
Apply formatting suggestions from code review
Sinerum Feb 23, 2023
7e848fd
move qsourcehighlite to be a submodule instead of copied code
Sinerum Feb 23, 2023
5e90a34
reformat
Sinerum Feb 23, 2023
4df3126
Apply Suggestions from code review
Sinerum Feb 23, 2023
b3b1a2f
remove accidental changes
Sinerum Mar 2, 2023
e84b72c
Fix formating
Sinerum Mar 2, 2023
af8dc58
Let addAction create the action instead of handling that our self's.
Sinerum Mar 2, 2023
70fec0a
Fix typo
Sinerum Mar 2, 2023
ddb71b2
Extract Numeric Feature Creation to its own method for better readabi…
Sinerum Mar 2, 2023
d0f2dd8
Include Utils directly
Sinerum Mar 2, 2023
9fd1257
Add some documentation
Sinerum Mar 2, 2023
6941ea2
Remove Unused Methods
Sinerum Mar 2, 2023
0b191f1
Use dyn_cast correctly
Sinerum Mar 2, 2023
2dc309b
only create new Treeview if we none exits
Sinerum Mar 2, 2023
e0d1dd8
format
Sinerum Mar 2, 2023
3cfb050
make the highlighter a unique pointer
Sinerum Mar 2, 2023
a3f56e8
fix typos
Sinerum Mar 2, 2023
6cd51d7
rework menu for FeatureTreeItems to use a QueuedConnection for remove…
Sinerum Mar 2, 2023
7a3ee48
format
Sinerum Mar 2, 2023
0079bf1
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Mar 2, 2023
0860ac8
format
Sinerum Mar 2, 2023
53aa4f5
add support for Both qt5 and 6
Sinerum Mar 2, 2023
de394e6
Make everything qt5 compatible
Sinerum Mar 2, 2023
82df3c6
Add qt6-dev install to github workflow
Sinerum Mar 2, 2023
c64c18e
Use qt5-dev in github workflow
Sinerum Mar 2, 2023
d1616ff
Allow for qt versions older than 5.15
Sinerum Mar 2, 2023
fee14db
Remove setPlaceHolderText if qt < 5.15
Sinerum Mar 2, 2023
6740805
Fix source location marking
Sinerum Mar 2, 2023
d842541
format
Sinerum Mar 2, 2023
4825b9d
format
Sinerum Mar 2, 2023
26c0d72
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Mar 3, 2023
e6f7e8c
fix lint
Sinerum Mar 3, 2023
097af7b
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Mar 14, 2023
2f244ca
Apply suggestions from code review
Sinerum Mar 14, 2023
0186315
cleanup clang-tidy errors
Sinerum Mar 15, 2023
ddbdf9f
cleanup clang-tidy errors
Sinerum Mar 15, 2023
5d0d0a6
Update include/vara/Feature/FeatureModelTransaction.h
Sinerum Mar 15, 2023
cc6c1ba
cleanup clang-tidy errors
Sinerum Mar 15, 2023
f14a510
write clang tidy overwrite to the correct directory
Sinerum Mar 15, 2023
335acc9
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Apr 3, 2023
18643cf
Update .gitmodules
Sinerum Apr 13, 2023
59d2daa
reformat CMakeLists.txt
Sinerum Apr 17, 2023
2550447
keep asserts to check for correct cast in release build.
Sinerum Apr 17, 2023
dfc752b
keep asserts to check for correct cast in release build.
Sinerum Apr 17, 2023
75ee65a
Replace the asserts for nullpointer with aborts
Sinerum Apr 19, 2023
5cce459
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Apr 24, 2023
d068a82
Apply suggestions from code review
Sinerum May 16, 2023
e7fe6b8
Remove special case for old qt versions
Jun 20, 2023
d344c67
Cleanup
Jun 20, 2023
bb33e0c
Automatically select newly added source files
Jun 20, 2023
56cd7ef
Add Q_Interface declaration to FeatureNode.h
Jun 20, 2023
c4e02e2
Fix Formatting
Jun 20, 2023
12e6cdd
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Jun 20, 2023
004cfaa
add source locations only once to selection
Jun 20, 2023
c38dc49
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Jul 26, 2023
1d74318
Add separator between feature locations
Sinerum Jul 26, 2023
0d3150f
Make graph movable
Sinerum Jul 26, 2023
c4bead2
Check ModelPath before loading FeatureModel
Sinerum Jul 26, 2023
61c923d
Fix spacing and cut off for node labels
Sinerum Jul 27, 2023
0392b58
Fix formatting
Sinerum Jul 27, 2023
061bff1
* Switched to use selection changed option for navigating through fea…
Sep 18, 2023
b141fd3
* Added action to create new feature models
Sep 26, 2023
19b317e
* Improvements to save and added saveAs
Sep 26, 2023
9e00b3f
* Added All Files filter to add source
Sep 26, 2023
b7dd95f
* Added guard to avoid adding empty source range
Sep 26, 2023
b4bb9c5
* Set correct line wrap mode for source code preview
Sep 26, 2023
5f649cd
load Models from cwd
Sinerum Oct 30, 2023
963ce63
do not use smart pointers in graphics view let qGraphics Scene handel…
Sinerum Oct 30, 2023
4e510e7
update tree view when adding features
Sinerum Oct 30, 2023
6b72bbe
Merge branch 'vara-dev' into f-FeatureGui
vulder Nov 17, 2023
6e5614c
Fix clang-tidy exclusion of generated files
Nov 20, 2023
1c016ad
Fix clang warnings
Nov 20, 2023
90ff5a8
Show root feature in treeview
Nov 20, 2023
4ca982c
Merge branch 'vara-dev' into f-FeatureGui
Sinerum Nov 20, 2023
bfc46bc
Fix format
Nov 20, 2023
8a2a93d
dont display data fro empty Feature Tree Item
Nov 21, 2023
6190334
fix clang tidy errors
Nov 21, 2023
2c6c475
fix clang tidy errors
Dec 5, 2023
7c19b0c
move item null check in FeatureTreeItem
Dec 5, 2023
1913c34
Add extra abstraction for "ghost" root item in treeview
Dec 5, 2023
dfad1c1
check nullability after cast to numeric feature
Dec 5, 2023
a3ea757
add context menu functionality to newly added features
Sinerum Nov 17, 2023
7fcc47b
fix repository selection
Sinerum Mar 5, 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
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ jobs:
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main'
sudo apt-get update
sudo apt-get -y install --no-install-recommends clang-${{ matrix.llvm-major }} llvm-${{ matrix.llvm-major }}-dev clang-tidy-14

- name: Install Tool Dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install qtbase5-dev qtdeclarative5-dev
- name: Workaround for sanitizer
shell: bash
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
[submodule "external/csv-parser"]
path = external/csv-parser
url = https://github.com/se-sic/csv-parser.git
[submodule "external/qsourcehighlite"]
path = external/qsourcehighlite
url = [email protected]:Waqar144/QSourceHighlite.git
[submodule "external/z3"]
path = external/z3
url = https://github.com/fabianbs96/z3.git
1 change: 1 addition & 0 deletions external/qsourcehighlite
Submodule qsourcehighlite added at f1ed26
33 changes: 28 additions & 5 deletions include/vara/Feature/FeatureModelTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class FeatureModelTransaction
/// \returns a pointer to the inserted Feature in CopyMode, otherwise,
/// nothing.
decltype(auto) addFeature(std::unique_ptr<Feature> NewFeature,
Feature *Parent = nullptr) {
FeatureTreeNode *Parent = nullptr) {
Sinerum marked this conversation as resolved.
Show resolved Hide resolved
if constexpr (IsCopyMode) {
return this->addFeatureImpl(std::move(NewFeature), Parent);
} else {
Expand Down Expand Up @@ -321,11 +321,11 @@ class AddFeatureToModel : public FeatureModelModification {

private:
AddFeatureToModel(std::unique_ptr<Feature> NewFeature,
Feature *Parent = nullptr)
FeatureTreeNode *Parent = nullptr)
: NewFeature(std::move(NewFeature)), Parent(Parent) {}

std::unique_ptr<Feature> NewFeature;
Feature *Parent;
FeatureTreeNode *Parent;
};

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -829,7 +829,7 @@ class FeatureModelCopyTransactionBase {
// Modifications

Result<FTErrorCode, Feature *>
addFeatureImpl(std::unique_ptr<Feature> NewFeature, Feature *Parent) {
addFeatureImpl(std::unique_ptr<Feature> NewFeature, FeatureTreeNode *Parent) {
if (!FM) {
return ERROR;
}
Expand Down Expand Up @@ -968,6 +968,28 @@ class FeatureModelCopyTransactionBase {
return FM->getFeature(F.getName());
}

[[nodiscard]] FeatureTreeNode *translateFeature(FeatureTreeNode &F) {
if (F.getKind() == FeatureTreeNode::NodeKind::NK_RELATIONSHIP) {
FeatureTreeNode *Parent = F.getParent();
auto *ParentFeature = llvm::dyn_cast<Feature, FeatureTreeNode>(Parent);
if (ParentFeature == nullptr) {
// The Parent of a Relationship should always be a Feature
abort();
}
ParentFeature = FM->getFeature(ParentFeature->getName());
Relationship *Base = *ParentFeature->getChildren<Relationship>(0).begin();
Base = *Base->getChildren<Relationship>(0).begin();
return Base;
}
auto *CastF = llvm::dyn_cast<Feature, FeatureTreeNode>(&F);
if (CastF == nullptr) {
// There are only Features and Relationship nodes if F was not a
// Relationship it has to be a Feature
abort();
}
return FM->getFeature(CastF->getName());
}

std::unique_ptr<FeatureModel> FM;
};

Expand Down Expand Up @@ -1008,7 +1030,8 @@ class FeatureModelModifyTransactionBase {
//===--------------------------------------------------------------------===//
// Modifications

void addFeatureImpl(std::unique_ptr<Feature> NewFeature, Feature *Parent) {
void addFeatureImpl(std::unique_ptr<Feature> NewFeature,
FeatureTreeNode *Parent) {
assert(FM && "FeatureModel is null.");

Modifications.push_back(
Expand Down
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ if(VARA_FEATURE_USE_Z3_SOLVER)
add_subdirectory(config-generator)
endif()
add_subdirectory(fm-viewer)
add_subdirectory(fm-editor)
61 changes: 61 additions & 0 deletions tools/fm-editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
set(LLVM_LINK_COMPONENTS Support Demangle Core)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
find_package(
QT
NAMES
Qt6
Qt5
REQUIRED
COMPONENTS Widgets
)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
include_directories(../../external/qsourcehighlite)
include_directories(.)

add_vara_executable(
fm-editor
main.cpp
graph/FeatureModelGraph.h
graph/FeatureModelGraph.cpp
graph/FeatureNode.h
graph/FeatureNode.cpp
graph/FeatureEdge.h
graph/FeatureEdge.cpp
tree/FeatureTreeViewModel.h
tree/FeatureTreeViewModel.cpp
tree/FeatureTreeItem.h
tree/FeatureTreeItem.cpp
FeatureModelEditor.h
FeatureModelEditor.cpp
FeatureAddDialog.h
FeatureAddDialog.cpp
../../external/qsourcehighlite/qsourcehighliter.h
../../external/qsourcehighlite/qsourcehighliter.cpp
../../external/qsourcehighlite/languagedata.h
../../external/qsourcehighlite/languagedata.cpp
../../external/qsourcehighlite/qsourcehighliterthemes.h
../../external/qsourcehighlite/qsourcehighliterthemes.cpp
)
target_link_libraries(
fm-editor
LINK_PRIVATE
VaRAFeature
Qt${QT_VERSION_MAJOR}::Widgets
${STD_FS_LIB}
)

add_custom_target(
check-vara-fm-editor
COMMAND fm-editor xml/test.xml -viewer cat | dot | grep . -q
COMMENT "Unittests"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources
)

file(
WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy"
"
Sinerum marked this conversation as resolved.
Show resolved Hide resolved
Checks: '-*,llvm-twine-local'
...
"
)
101 changes: 101 additions & 0 deletions tools/fm-editor/FeatureAddDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#include "FeatureAddDialog.h"
#include "graph/FeatureModelGraph.h"
#include "graph/FeatureNode.h"

using vara::feature::Feature;
FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent,
Feature *ParentFeature)
: QDialog(Parent) {
setupUi(this);
NodeNames = QStringList();
if (ParentFeature) {
NodeNames.push_back(QString::fromStdString(ParentFeature->getName().str()));
Nodes->setEnabled(false);
} else {
for (const auto &Node : *Graph->getNodes()) {
NodeNames.push_back(Node->getQName());
}
}
this->Nodes->addItems(NodeNames);
this->FeatureKind->addItems(QStringList{"Binary", "Numeric"});
stepOperator->addItems(QStringList{"Add +", "Multiply *", "Exp ^"});
NumericFeature->setVisible(false);
connect(FeatureKind, QOverload<int>::of(&QComboBox::activated), this,
&FeatureAddDialog::featureType);
}

QString FeatureAddDialog::getName() const { return name->text(); }

QString FeatureAddDialog::getParent() const { return Nodes->currentText(); }

void FeatureAddDialog::featureType(int Index) {
if (Index == 1) {
NumericFeature->setVisible(true);
} else {
NumericFeature->setVisible(false);
}
}

vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() {
return vara::feature::Feature::FeatureKind(FeatureKind->currentIndex());
}
Sinerum marked this conversation as resolved.
Show resolved Hide resolved

bool FeatureAddDialog::isOptional() const { return optionalCheck->isChecked(); }

QString FeatureAddDialog::getOutputString() const {
return outputString->text();
}

std::vector<int64_t> stringToIntVector(string &Input) {
std::stringstream InStream(Input);
std::vector<int64_t> Out{};

for (std::string Substring; std::getline(InStream, Substring, ',');) {
Out.push_back(std::stoi(Substring));
}
Sinerum marked this conversation as resolved.
Show resolved Hide resolved
return Out;
}

/// Retrieve the Feature defined by the dialog this should only be called after
/// the dialog was accepted
std::unique_ptr<Feature> FeatureAddDialog::getFeature() {
const std::string Name = getName().toStdString();
const bool Optional = isOptional();
const std::string OutputString = getOutputString().toStdString();
switch (getFeatureKind()) {
case Feature::FeatureKind::FK_BINARY:
return std::make_unique<vara::feature::BinaryFeature>(
Name, Optional, std::vector<vara::feature::FeatureSourceRange>(),
OutputString);
case Feature::FeatureKind::FK_NUMERIC: {
return getNumericFeature();
}
default:
return std::make_unique<Feature>(Name);
}
}

std::unique_ptr<Feature> FeatureAddDialog::getNumericFeature() const {
const std::string Name = getName().toStdString();
const bool Optional = isOptional();
const std::string OutputString = getOutputString().toStdString();
std::unique_ptr<vara::feature::StepFunction> SF{};
vara::feature::NumericFeature::ValuesVariantType ValueRange;

if (range->isChecked()) {
ValueRange = vara::feature::NumericFeature::ValueRangeType(min->value(),
max->value());
if (lhs->isChecked()) {
SF = std::make_unique<vara::feature::StepFunction>(
stepOperand->value(), vara::feature::StepFunction::StepOperation(
stepOperator->currentIndex()));
}
} else {
auto ValueString = values->text().toStdString();
ValueRange = stringToIntVector(ValueString);
}
return std::make_unique<vara::feature::NumericFeature>(
Name, ValueRange, Optional,
std::vector<vara::feature::FeatureSourceRange>(), OutputString,
std::move(SF));
}
32 changes: 32 additions & 0 deletions tools/fm-editor/FeatureAddDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef VARA_FEATURE_FEATUREADDDIALOG_H
#define VARA_FEATURE_FEATUREADDDIALOG_H

#include "graph/FeatureModelGraph.h"
#include "ui_FeatureAddDialog.h"

#include <QDialog>
#include <QInputDialog>

class FeatureAddDialog : public QDialog, public Ui::Add {
Q_OBJECT

public:
FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent,
vara::feature::Feature *ParentFeature = nullptr);
QString getName() const;
QString getParent() const;
QString getOutputString() const;
std::unique_ptr<vara::feature::Feature> getFeature();
vara::feature::Feature::FeatureKind getFeatureKind();
bool isOptional() const;

public slots:
void featureType(int Index);

private:
QStringList NodeNames;
Sinerum marked this conversation as resolved.
Show resolved Hide resolved

std::unique_ptr<vara::feature::Feature> getNumericFeature() const;
};

#endif // VARA_FEATURE_FEATUREADDDIALOG_H
Loading
Loading