-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.cpp
More file actions
67 lines (58 loc) · 2.13 KB
/
edit.cpp
File metadata and controls
67 lines (58 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "mainwindow.h"
#include <QFile>
#include <QRegularExpression>
#include <TopoR_PCB_File.h>
// #include <xmlserializer.h>
void MainWindow::edit() {
QRegularExpression re{"^(G\\d+)|(REL\\S+)$"};
// QStringList resistors;
std::map<QString, QStringList> map;
#if 0
for(auto&& net: file->netList.Nets) {
if(net.name.contains(re)) {
qWarning() << net.name;
for(auto&& ref: net.refs) {
ref.visit(
[&map, &net](const auto& val) {
if(val.compName.startsWith('R')
|| val.compName.startsWith("VT")
&& !map[val.compName].contains(net.name))
map[val.compName].push_back(net.name);
});
}
}
}
for(auto&& [compName, nets]: map) {
for(auto&& net: file->netList.Nets) {
for(auto&& ref: net.refs) {
ref.visit(
[&](const PinRef& val) -> void {
if(val.compName == compName && val.pinName == "2")
map[val.compName].push_back(net.name);
},
[](const PadRef& val) -> void {
});
}
}
qInfo() << compName << nets;
}
return;
auto xml = (Xml::Serializer{""} << *file).toString();
for(auto&& [compName, nets]: map) {
assert(nets.size() == 2);
xml.replace(nets.back(), nets.front());
}
for(auto&& [compName, nets]: map)
file->netList.Nets.erase(std::ranges::find(file->netList.Nets, nets.back(), &NetList::Net::name));
if(QFile file{"edited.fst"}; file.open(QFile::WriteOnly)) {
file.write(xml.toUtf8());
} else
qWarning() << file.errorString();
// for(auto&& resRefDes: resistors) {
// auto* comp = file->componentsOnBoard.getComponentOf(resRefDes);
// if(!comp) continue;
// qWarning() << comp->name;
// qWarning() << comp->Pins.size();
// }
#endif
}