Skip to content

Commit 6e16ff9

Browse files
committed
Port to CMake and GCC, fix dark theme, add example circuits
1 parent dcc01e7 commit 6e16ff9

File tree

9 files changed

+843
-8
lines changed

9 files changed

+843
-8
lines changed

.gitignore

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,73 @@ ASALocalRun/
337337
.localhistory/
338338

339339
# BeatPulse healthcheck temp database
340-
healthchecksdb
340+
healthchecksdb
341+
342+
# https://github.com/github/gitignore/blob/master/CMake.gitignore
343+
CMakeLists.txt.user
344+
CMakeCache.txt
345+
CMakeFiles
346+
CMakeScripts
347+
Testing
348+
Makefile
349+
cmake_install.cmake
350+
install_manifest.txt
351+
compile_commands.json
352+
CTestTestfile.cmake
353+
_deps
354+
355+
# https://github.com/github/gitignore/blob/master/Qt.gitignore
356+
# C++ objects and libs
357+
*.slo
358+
*.lo
359+
*.o
360+
*.a
361+
*.la
362+
*.lai
363+
*.so
364+
*.so.*
365+
*.dll
366+
*.dylib
367+
368+
# Qt-es
369+
object_script.*.Release
370+
object_script.*.Debug
371+
*_plugin_import.cpp
372+
/.qmake.cache
373+
/.qmake.stash
374+
*.pro.user
375+
*.pro.user.*
376+
*.qbs.user
377+
*.qbs.user.*
378+
*.moc
379+
moc_*.cpp
380+
moc_*.h
381+
qrc_*.cpp
382+
ui_*.h
383+
*.qmlc
384+
*.jsc
385+
Makefile*
386+
*build*
387+
*.qm
388+
*.prl
389+
390+
# Qt unit tests
391+
target_wrapper.*
392+
393+
# QtCreator
394+
*.autosave
395+
396+
# QtCreator Qml
397+
*.qmlproject.user
398+
*.qmlproject.user.*
399+
400+
# QtCreator CMake
401+
CMakeLists.txt.user*
402+
403+
# QtCreator 4.8< compilation database
404+
compile_commands.json
405+
406+
# QtCreator local machine specific files for imported projects
407+
*creator.user*
408+
409+
*_qmlcache.qrc

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
3+
}

CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmake_minimum_required(VERSION 3.7.0)
2+
3+
project(OOP_Task4 VERSION 1.0.0 LANGUAGES CXX)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
9+
10+
set(CMAKE_AUTOMOC ON)
11+
set(CMAKE_AUTORCC ON)
12+
set(CMAKE_AUTOUIC ON)
13+
14+
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
15+
16+
add_executable(OOP_Task4
17+
AddElementDialog.cpp
18+
AddElementDialog.h
19+
AddElementWindow.ui
20+
EditElementDialog.cpp
21+
EditElementDialog.h
22+
EditElementWindow.ui
23+
ElectricalCircuitCalculator.cpp
24+
ElectricalCircuitCalculator.h
25+
ElectricalElement.cpp
26+
ElectricalElement.h
27+
ElectricalElements/CurrentSource.cpp
28+
ElectricalElements/CurrentSource.h
29+
ElectricalElements/ElectricHeater.cpp
30+
ElectricalElements/ElectricHeater.h
31+
ElectricalElements/ElectricLamp.cpp
32+
ElectricalElements/ElectricLamp.h
33+
ElectricalElements/Resistor.cpp
34+
ElectricalElements/Resistor.h
35+
ElectricalElements/Switch.cpp
36+
ElectricalElements/Switch.h
37+
ElectricalElements/VoltageSource.cpp
38+
ElectricalElements/VoltageSource.h
39+
ElectricalElements/Wire.cpp
40+
ElectricalElements/Wire.h
41+
ElectricalElementsManager.cpp
42+
ElectricalElementsManager.h
43+
main.cpp
44+
MainWindow.cpp
45+
MainWindow.h
46+
MainWindow.qrc
47+
MainWindow.ui
48+
RenderArea.cpp
49+
RenderArea.h
50+
)
51+
52+
target_link_libraries(OOP_Task4 Qt5::Core Qt5::Gui Qt5::Widgets)

ElectricalCircuitCalculator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ bool ElectricalCircuitCalculator::findNodesAndElements(QString& error)
4646

4747
// Каждой точке сетки сопоставляются элементы, подключённые к ней
4848
QMap<QPoint, QVector<ElectricalElement*>> allPoints;
49-
for (int or = 0; or < 2; or++) // 2 ориентации
50-
for (auto el : ElectricalElementsManager::getInstance().getElements()[or]) // Все элементы с данной ориентацией
49+
for (int orient = 0; orient < 2; orient++) // 2 ориентации
50+
for (auto el : ElectricalElementsManager::getInstance().getElements()[orient]) // Все элементы с данной ориентацией
5151
for (auto p : el->getEndPoints()) // Все крайние точки элемента
5252
allPoints[p].push_back(el);
5353

@@ -225,7 +225,7 @@ bool ElectricalCircuitCalculator::findVoltagesAndCurrents(QString& error)
225225
// Вершины, к которым подключён элемент
226226
int i = pr.second.first, j = pr.second.second;
227227
// Если есть внутреннее сопротивление
228-
if (!isinf(pr.first->getResistance()))
228+
if (!std::isinf(pr.first->getResistance()))
229229
{
230230
// Проводимость элемента
231231
double conductance = 1.0 / pr.first->getResistance();
@@ -387,7 +387,7 @@ bool ElectricalCircuitCalculator::getCurrent(const QPoint& loc, Qt::Orientation
387387
if (currentSources[i].first == el)
388388
{
389389
// Если идеальный источник
390-
if (isinf(el->getResistance()))
390+
if (std::isinf(el->getResistance()))
391391
res = currentSources[i].first->getCurrent();
392392
else
393393
{

0 commit comments

Comments
 (0)