# HG changeset patch # User František Kučera # Date 1300136043 -3600 # Node ID b166c6f4971947aa8979ba7a6aa61c244aa8bc9e # Parent 90b924d8957948a4a3fb86c34b7eaa935644c0b5 První návrh diff -r 90b924d89579 -r b166c6f49719 c++/POSIXoveFronty/Fronta/Makefile --- a/c++/POSIXoveFronty/Fronta/Makefile Tue Aug 17 22:40:16 2010 +0200 +++ b/c++/POSIXoveFronty/Fronta/Makefile Mon Mar 14 21:54:03 2011 +0100 @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: Fronta -# Generated by qmake (2.01a) (Qt 4.4.3) on: ne dub 5 22:16:48 2009 +# Generated by qmake (2.01a) (Qt 4.7.0) on: st 2 9 19:12:09 2011 # Project: Fronta.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile Fronta.pro @@ -13,10 +13,10 @@ DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) -INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. LINK = g++ -LFLAGS = -Wl,--no-undefined -LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread +LFLAGS = -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread AR = ar cqs RANLIB = QMAKE = /usr/bin/qmake @@ -26,11 +26,12 @@ SED = sed COPY_FILE = $(COPY) COPY_DIR = $(COPY) -r +STRIP = strip INSTALL_FILE = install -m 644 -p INSTALL_DIR = $(COPY_DIR) INSTALL_PROGRAM = install -m 755 -p DEL_FILE = rm -f -SYMLINK = ln -sf +SYMLINK = ln -f -s DEL_DIR = rmdir MOVE = mv -f CHK_DIR_EXISTS= test -d @@ -52,6 +53,7 @@ /usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/linux.conf \ /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ /usr/share/qt4/mkspecs/features/qt_functions.prf \ /usr/share/qt4/mkspecs/features/qt_config.prf \ /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ @@ -66,6 +68,7 @@ /usr/share/qt4/mkspecs/features/uic.prf \ /usr/share/qt4/mkspecs/features/yacc.prf \ /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ Fronta.pro QMAKE_TARGET = Fronta DESTDIR = @@ -102,6 +105,7 @@ /usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/linux.conf \ /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ /usr/share/qt4/mkspecs/features/qt_functions.prf \ /usr/share/qt4/mkspecs/features/qt_config.prf \ /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ @@ -116,6 +120,7 @@ /usr/share/qt4/mkspecs/features/uic.prf \ /usr/share/qt4/mkspecs/features/yacc.prf \ /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ /usr/lib/libQtGui.prl \ /usr/lib/libQtCore.prl $(QMAKE) -unix -o Makefile Fronta.pro @@ -123,6 +128,7 @@ /usr/share/qt4/mkspecs/common/unix.conf: /usr/share/qt4/mkspecs/common/linux.conf: /usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: /usr/share/qt4/mkspecs/features/qt_functions.prf: /usr/share/qt4/mkspecs/features/qt_config.prf: /usr/share/qt4/mkspecs/features/exclusive_builds.prf: @@ -137,6 +143,7 @@ /usr/share/qt4/mkspecs/features/uic.prf: /usr/share/qt4/mkspecs/features/yacc.prf: /usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: /usr/lib/libQtGui.prl: /usr/lib/libQtCore.prl: qmake: FORCE @@ -159,6 +166,8 @@ -$(DEL_FILE) Makefile +check: first + mocclean: compiler_moc_header_clean compiler_moc_source_clean mocables: compiler_moc_header_make_all compiler_moc_source_make_all @@ -187,7 +196,8 @@ fronta.o: fronta.cpp fronta.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o fronta.o fronta.cpp -program.o: program.cpp program.h +program.o: program.cpp program.h \ + fronta.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o program.o program.cpp gdbmacros.o: qtc-gdbmacros/gdbmacros.cpp diff -r 90b924d89579 -r b166c6f49719 c++/ukazatele/ukazatele.cpp --- a/c++/ukazatele/ukazatele.cpp Tue Aug 17 22:40:16 2010 +0200 +++ b/c++/ukazatele/ukazatele.cpp Mon Mar 14 21:54:03 2011 +0100 @@ -1,19 +1,26 @@ #include +#include #include #include #include using namespace std; -int main () { +int main (int argc, const char* argv[]) { cout << obarvi("*** Ukazatele ***", BARVA_ZELENA) << endl << endl; + upravPromennou(); + cout << endl; + zpracujParametry(argc, argv); + + cout << endl << obarvi("*** konec programu ***", BARVA_ZELENA) << endl; + exit(0); } void upravPromennou() { int x; - x= 100; + x = 100; upravSpatne(x); cout << obarvi("špatný výsledek: ", BARVA_ZELENA) << x << endl; @@ -22,13 +29,13 @@ cout << obarvi("dobrý výsledek: ", BARVA_ZELENA) << x << endl; - /** Nefunguje → error: invalid conversion from ‘int’ to ‘int*’ */ + /** Nejde přeložit → error: invalid conversion from ‘int’ to ‘int*’ */ //x = 100; //upravDobre(x); //cout << obarvi("dobrý výsledek: ", BARVA_ZELENA) << x << endl; - /** Nefunguje → error: invalid conversion from ‘int*’ to ‘int’ */ - //x= 100; + /** Nejde přeložit → error: invalid conversion from ‘int*’ to ‘int’ */ + //x = 100; //upravSpatne(&x); //cout << obarvi("špatný výsledek: ", BARVA_ZELENA) << x << endl; } @@ -43,3 +50,10 @@ *n = 123; } +void zpracujParametry(int argc, const char* argv[]) { + cout << obarvi("Počet parametrů: ", BARVA_ZELENA) << argc << ":" << endl; + for (int i = 0; i < argc; i++) { + cout << obarvi("Parametr: ", BARVA_ZELENA) << argv[i] << endl; + } +} + diff -r 90b924d89579 -r b166c6f49719 c++/ukazatele/ukazatele.h --- a/c++/ukazatele/ukazatele.h Tue Aug 17 22:40:16 2010 +0200 +++ b/c++/ukazatele/ukazatele.h Mon Mar 14 21:54:03 2011 +0100 @@ -1,4 +1,4 @@ void upravPromennou(); void upravSpatne(int n); void upravDobre(int *n); - +void zpracujParametry(int argc, const char* argv[]); diff -r 90b924d89579 -r b166c6f49719 java/ObrazkovyApplet/src/cz/frantovo/obrazkovyApplet/ObrazkovyApplet.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/ObrazkovyApplet/src/cz/frantovo/obrazkovyApplet/ObrazkovyApplet.form Mon Mar 14 21:54:03 2011 +0100 @@ -0,0 +1,78 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r 90b924d89579 -r b166c6f49719 java/ObrazkovyApplet/src/cz/frantovo/obrazkovyApplet/ObrazkovyApplet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/ObrazkovyApplet/src/cz/frantovo/obrazkovyApplet/ObrazkovyApplet.java Mon Mar 14 21:54:03 2011 +0100 @@ -0,0 +1,216 @@ +package cz.frantovo.obrazkovyApplet; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.image.BufferedImage; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.imageio.ImageIO; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; + +public class ObrazkovyApplet extends javax.swing.JApplet implements MouseMotionListener, MouseListener { + + private static final Logger log = Logger.getLogger(ObrazkovyApplet.class.getSimpleName()); + private static final String CILOVE_URL = "http://vm.frantovo.cz/temp/applet/"; + private int stareX; + private int stareY; + private boolean kresli; + private Graphics g; + private Graphics2D vystupniGrafika; + private BufferedImage obrazek; + + private void odesliData() { + try { + URL url = new URL(CILOVE_URL); + URLConnection spojeni = url.openConnection(); + spojeni.setDoOutput(true); + spojeni.connect(); + OutputStream os = spojeni.getOutputStream(); + ImageIO.write(obrazek, "png", os); + os.flush(); + os.close(); + + BufferedReader r = new BufferedReader(new InputStreamReader(spojeni.getInputStream())); + vypisStav(r.readLine()); + r.close(); + + smazGrafiku(); + } catch (Exception e) { + vypisStav("odeslání selhalo: " + e.getMessage()); + log.log(Level.SEVERE, "Nepodařilo se odeslat data", e); + } + } + + private void smazGrafiku() { + getVystupniGrafika().clearRect(0, 0, platno.getWidth(), platno.getHeight()); + g.clearRect(0, 0, platno.getWidth(), platno.getHeight()); + } + + public void mouseDragged(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + + if (kresli) { + vypisStav("kreslím: " + stareX + "x" + stareY + "→" + x + "x" + y); + g = platno.getGraphics(); + g.setColor(Color.BLUE); + g.drawLine(stareX, stareY, x, y); + + platno.pa + + + getVystupniGrafika().drawLine(stareX, stareY, x, y); + } + + stareX = x; + stareY = y; + } + + public void mousePressed(MouseEvent e) { + stareX = e.getX(); + stareY = e.getY(); + kresli = true; + } + + public void mouseReleased(MouseEvent e) { + kresli = false; + } + + public void mouseMoved(MouseEvent e) { + } + + public void mouseClicked(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + kresli = false; + } + + private Graphics2D getVystupniGrafika() { + if (obrazek == null) { + obrazek = new BufferedImage(platno.getWidth(), platno.getHeight(), BufferedImage.TYPE_INT_RGB); + } + if (vystupniGrafika == null) { + vystupniGrafika = obrazek.createGraphics(); + vystupniGrafika.setBackground(Color.WHITE); + vystupniGrafika.setColor(Color.BLUE); + vystupniGrafika.clearRect(0, 0, platno.getWidth(), platno.getHeight()); + } + return vystupniGrafika; + } + + @Override + public void init() { + + /** Lepší vzhled – LaF */ + try { + for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (Exception e) { + } + + /** Spuštění appletu */ + try { + java.awt.EventQueue.invokeAndWait(new Runnable() { + + public void run() { + initComponents(); + } + }); + } catch (Exception e) { + log.log(Level.SEVERE, "Chyba appletu:", e); + } + + /** Nastavení plátna */ + platno.addMouseMotionListener(ObrazkovyApplet.this); + platno.addMouseListener(ObrazkovyApplet.this); + log.log(Level.INFO, "plátno nastaveno"); + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + odeslat = new javax.swing.JButton(); + stavovyRadek = new javax.swing.JLabel(); + platno = new javax.swing.JPanel(); + + odeslat.setText("Odeslat na server"); + odeslat.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + odeslatActionPerformed(evt); + } + }); + + stavovyRadek.setText(" "); + + platno.setDoubleBuffered(true); + + javax.swing.GroupLayout platnoLayout = new javax.swing.GroupLayout(platno); + platno.setLayout(platnoLayout); + platnoLayout.setHorizontalGroup( + platnoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 388, Short.MAX_VALUE) + ); + platnoLayout.setVerticalGroup( + platnoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 255, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(platno, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(stavovyRadek, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(odeslat))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(platno, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(odeslat) + .addComponent(stavovyRadek)) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void odeslatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_odeslatActionPerformed + odesliData(); + }//GEN-LAST:event_odeslatActionPerformed + + private void vypisStav(String text) { + stavovyRadek.setText(text); + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton odeslat; + private javax.swing.JPanel platno; + private javax.swing.JLabel stavovyRadek; + // End of variables declaration//GEN-END:variables +}