Debian Codegraph @

main.cpp

raw symbols SCIP
1
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick
5 ** All rights reserved.
6 ** Contact: [email protected]
7 **
8 ** This file is part of the ShelXle
9 **
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file COPYING included in the
13 ** packaging of this file. Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 **
18 ****************************************************************************/
19 #include "window.h"
20 #include <QApplication>
21 //öß
22 #if (QT_VERSION >= 0x050000)
23 void mh(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
24 printf("mh %X\n",QT_VERSION);
25 QByteArray localMsg = msg.toLocal8Bit();
26 QString pth=QDir::homePath()+"/ShelXle_qt6_message.txt";
27 FILE *er=fopen(pth.toStdString().c_str(),"at");
28 fprintf(er,"======%s\n%s\n======\n",
29 QDateTime::currentDateTime().toString().toStdString().c_str(),
30 localMsg.constData());
31 fclose(er);
32 if (strstr(localMsg.constData(),"QOpenGLShader::link:")!=NULL) {
33 printf("%s\n",localMsg.constData());fflush(stdout);
34 return; // ignore useless error messages with shitty intel graphic cards reporting \"No error."
35 }
36 if (strstr(localMsg.constData(),"QAccessibleWidget")!=NULL) {
37 printf("%s\n",localMsg.constData());fflush(stdout);
38 return; // ignore useless error messages on win with touch screens
39 }
40 if (strstr(localMsg.constData(),"setGeometry")!=NULL) {
41 printf("%s\n",localMsg.constData());fflush(stdout);
42 return; // ignore useless error messages
43 }
44 if (strstr(localMsg.constData(),"QOpenGLShader::link:")!=NULL) {
45 printf("%s\n",localMsg.constData());fflush(stdout);
46 return; // ignore useless error messages
47 }
48 if (strstr(localMsg.constData(),"WM_DESTROY")!=NULL) {
49 printf("ignore %s\n",localMsg.constData());fflush(stdout);
50 return; // ignore useless error messages
51 }
52
53
54 switch (type) {
55 case QtDebugMsg:
56 fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
57 // Q_WS_* was droppen in QT5 in favor of Q_OS_*
58 #if defined Q_WS_WIN || defined Q_OS_WIN
59 //QMessageBox::information(0,"information",msg);
60 #endif
61 break;
62 case QtInfoMsg:
63 fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
64 #if defined Q_WS_WIN || defined Q_OS_WIN
65 //QMessageBox::information(0,"information",msg);
66 #endif
67 break;
68 case QtWarningMsg:
69 fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
70 #if defined Q_WS_WIN || defined Q_OS_WIN
71 //QMessageBox::warning(0,"warning",msg);
72 #endif
73 break;
74 case QtCriticalMsg:
75 fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
76 #if defined Q_WS_WIN || defined Q_OS_WIN
77 //QMessageBox::critical(0,"critical",msg);
78 #endif
79 break;
80 case QtFatalMsg:
81 fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
82 #if defined Q_WS_WIN || defined Q_OS_WIN
83 QMessageBox::critical(0,"fatal",msg);
84 #endif
85 abort();
86 }
87 }
88 #else
89 void mh(QtMsgType type, const char *msg){
90 QString pth=QDir::homePath()+"/ShelXle_message.txt";
91 FILE *er=fopen(pth.toStdString().c_str(),"wt");
92 fprintf(er,"======\n%s\n======\n",msg);
93 fclose(er);
94 if (strstr(msg,"QOpenGLShader::link:")!=NULL) {
95 printf("%s\n",msg);fflush(stdout);
96 return; // ignore useless error messages with shitty intel graphic cards reporting \"No error."
97 }
98 if (strstr(msg,"QAccessibleWidget")!=NULL) {
99 printf("%s\n",msg);fflush(stdout);
100 return; // ignore useless error messages on win with touch screens
101 }
102
103 if (strstr(msg,"setGeometry")!=NULL) {
104 printf("%s\n",msg);fflush(stdout);
105 return; // ignore useless error messages
106 }
107 if (strstr(msg,"QOpenGLShader::link:")!=NULL) {
108 printf("%s\n",msg);fflush(stdout);
109 return; // ignore useless error messages
110 }
111 if (strstr(msg,"Warning: External WM_DESTROY received for")!=NULL) {
112 printf("%s\n",msg);fflush(stdout);
113 return; // ignore useless error messages
114 }
115
116
117 switch (type){
118 case QtDebugMsg:
119
120 printf("%s\n",msg);fflush(stdout);
121
122 #if defined Q_WS_WIN
123 QMessageBox::information(0,"information",msg);
124 #endif
125 break;
126 case QtWarningMsg:
127 printf("%s\n",msg);fflush(stdout);
128 #if defined Q_WS_WIN
129 QMessageBox::warning(0,"warning",msg);
130 #endif
131 break;
132 case QtCriticalMsg:
133 printf("%s\n",msg);fflush(stdout);
134 #if defined Q_WS_WIN
135 QMessageBox::critical(0,"critical",msg);
136 #endif
137 break;
138 case QtFatalMsg:
139 printf("%s\n",msg);fflush(stdout);
140 #if defined Q_WS_WIN
141 QMessageBox::critical(0,"fatal",msg);
142 #endif
143 abort();
144 }
145 }
146
147 #endif
148
149 /*
150 void printicon(){
151 #if defined Q_WS_WIN || defined Q_OS_WIN
152 #define DEFINE_CONSOLEV2_PROPERTIES
153 #endif
154 QImage II=QImage(":xle-icons/SHELxLE.png" );
155 // QImage II=QPixmap(":xle-icons/cbh.png" ).toImage();
156 int r, g, b, c216,gray,k=0;
157 double alpha;
158 char x[9]="@ShelXle";
159 for (int j=0; j<II.height(); j++){
160 for (int i=0; i<II.width(); i++){
161 //printf("%2x",qGray(II.pixel(i,j)));a
162 alpha=qAlpha(II.pixel(i,j))/256.0;
163 r=(int) (qRed(II.pixel(i,j))/48.0*alpha);
164 g=(int) (qGreen(II.pixel(i,j))/48.0*alpha);
165 b=(int) (qBlue(II.pixel(i,j))/48.0*alpha);
166 c216 = 16 + 36 * r + 6 * g + b;
167 gray =qGray(II.pixel(i,j))/11+232;
168 gray= (int)(alpha*gray +(235*(1.0-alpha)));
169 #if defined Q_WS_WIN || defined Q_OS_WIN
170 wprintf(L"\x1b[48;5;%dm\x1b[38;5;%dm%c",c216,gray,x[k%8]);
171 #else
172 printf("\e[48;5;%dm\e[38;5;%dm%c",c216,gray,x[k%8]);
173 #endif
174 //printf("\e[48;5;%dm\e[38;5;%dm%c",gray,c216,x[k%8]);
175 k++;
176 }
177 #if defined Q_WS_WIN || defined Q_OS_WIN
178 wprintf(L"\x1b[0;0;0m\n");j++;
179 #else
180 printf("\e[0;0;0m\n");j++;
181 #endif
182 }
183
184
185 }
186 */
187 int main(int argv, char *args[]){
188 char *ENUS=setlocale(LC_ALL,"C");
189 if (!ENUS)ENUS=setlocale(LC_ALL,"en_US.UTF-8");
190 //printf("%s\n",ENUS);
191 #if (QT_VERSION >= 0x050000)
192 QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
193 //printf("AA_UseDesktopOpenGL %d \n",QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL));
194 printf("Qt::AA_ShareOpenGLContexts %d\n",QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts));
195 QApplication app(argv, args);
196 QSurfaceFormat f = QSurfaceFormat::defaultFormat();
197 //printf("??\n");
198 //f.setSampleBuffers(true);
199 f.setSwapInterval(0);
200 QSurfaceFormat::setDefaultFormat(f);
201 #else
202 QApplication app(argv, args);
203 #endif
204
205 app.setOrganizationName("shelxle");
206 app.setWindowIcon(QIcon(":xle-icons/SHELxLE.png"));
207 //printicon();
208 #if (QT_VERSION >= 0x050000)
209 qInstallMessageHandler(mh);
210 #else
211 qInstallMsgHandler(mh);
212 #endif
213 //printf("??1\n");
214 //ChGL *chgl = new ChGL(0);
215 //PlayOpenGL *chgl = new PlayOpenGL();
216 //printf("??2 %p\n",chgl);
217 Window *window = new Window();
218 //printf("??2.5 %p\n",window->chgl);
219 window->chgl->setMainWindow(window);
220 //printf("??3\n");
221 window->show();
222 int istat = app.exec();
223 //printf("delete the main window now...\n");
224 delete window;
225 //printf("%d bye bye! Thanks for using!\n",istat);
226 return istat;
227 }