Test for 0022778: Bug in BRepMesh
[occt.git] / src / ViewerTest / ViewerTest_AviCommands.cxx
1 // Created on: 2008-06-30
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2008-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20 #if (defined(_WIN32) || defined(__WIN32__)) && defined(HAVE_VIDEOCAPTURE)
21   #include <windows.h>
22   #include <OpenGl_AVIWriter.hxx>
23 #endif
24
25 #include <ViewerTest.hxx>
26 #include <Draw_Interpretor.hxx>
27
28 static Standard_Integer avi_record(Draw_Interpretor& di,
29                                    Standard_Integer argc, const char** argv)
30 {
31   if (argc < 2)
32   {
33     cout << "Syntax: " << argv[0] << " file | start | stop | save" << endl;
34     return 1;
35   }
36
37   Standard_Integer aResult = 1;
38 #if (defined(_WIN32) || defined(__WIN32__))
39   #ifdef HAVE_VIDEOCAPTURE
40     static OpenGl_AVIWriter * pAviWriter = 0L;
41
42     if (strncmp(argv[1], "file", 5) == 0) {
43       if (argc < 3) {
44         cout << "Please define the name of AVI file to create ..." << endl;
45       } else {
46         const char * aFilename = argv[2];
47         DWORD aFormat = mmioFOURCC('X','V','I','D');
48         if (argc > 3) {
49           const char * aFourcc = argv[3];
50           aFormat = mmioFOURCC(aFourcc[0], aFourcc[1], aFourcc[2], aFourcc[3]);
51         }
52         pAviWriter = new OpenGl_AVIWriter (aFilename, aFormat, 25);
53         aResult = 0;
54       }
55     } else if (pAviWriter == 0L) {
56       cout << "AVI Writer instance has not been initialized. Use command "
57            << argv[0] << " file ..." << endl;
58     } else if (strncmp(argv[1], "start", 6) == 0) {
59       pAviWriter->StartRecording();
60       aResult = 0;
61     } else if (strncmp(argv[1], "stop", 5) == 0) {
62       pAviWriter->StopRecording();
63       aResult = 0;
64     } else if (strncmp(argv[1], "save", 5) == 0) {
65       pAviWriter->StopRecording();
66       delete pAviWriter;
67       pAviWriter = 0L;
68       aResult = 0;
69     } else if (strncmp(argv[1], "status", 7) == 0) {
70       cout << pAviWriter->GetLastErrorMessage() << endl;
71       aResult = 0;
72     }
73   #else
74     cout << "AVI writer capability was disabled\n";
75   #endif
76 #else
77   cout << "AVI writer is implemented only in Windows version\n";
78 #endif
79   return aResult;
80 }
81
82 //=======================================================================
83 //function : AviCommands
84 //purpose  : 
85 //=======================================================================
86
87 void ViewerTest::AviCommands(Draw_Interpretor& theCommands)
88 {
89   const char* group = "ViewerTest AVI commands";
90
91   theCommands.Add("vrecord", "vrecord [option]\n"
92                   "where [option] can be:\n"
93                   "\tfile <filename.avi> <FOURCC=VIDX': Create AVI file "
94                                          "for recording,\n"
95                   "\tstart              : begin/restart recording,\n"
96                   "\tstop               : stop recording,\n"
97                   "\tstatus             : log error message,\n"
98                   "\tsave               : close the AVI file\n",
99                   __FILE__,
100                   &avi_record, group); //Draft_Modification
101 }