0027900: Coding rules - drop redundant Name parameter from V3d_Viewer constructor
[occt.git] / src / ViewerTest / ViewerTest_AviCommands.cxx
1 // Created on: 2008-06-30
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #if (defined(_WIN32) || defined(__WIN32__)) && defined(HAVE_VIDEOCAPTURE)
17   #include <windows.h>
18   #include <Aspect_Window.hxx>
19   #include <OpenGl_AVIWriter.hxx>
20   #include <V3d_View.hxx>
21 #endif
22
23 #include <ViewerTest.hxx>
24 #include <Draw_Interpretor.hxx>
25
26 static Standard_Integer avi_record(Draw_Interpretor& /*di*/,
27                                    Standard_Integer argc, const char** argv)
28 {
29   if (argc < 2)
30   {
31     cout << "Syntax: " << argv[0] << " file | start | stop | save" << endl;
32     return 1;
33   }
34
35   Standard_Integer aResult = 1;
36 #if (defined(_WIN32) || defined(__WIN32__))
37   #ifdef HAVE_VIDEOCAPTURE
38     Handle(V3d_View) aView = ViewerTest::CurrentView ();
39     if (aView.IsNull())
40     {
41       std::cout << "Call vinit before!\n";
42       return 1;
43     }
44
45     static OpenGl_AVIWriter * pAviWriter = 0L;
46
47     if (strncmp(argv[1], "file", 5) == 0) {
48       if (argc < 3) {
49         cout << "Please define the name of AVI file to create ..." << endl;
50       } else {
51         const char * aFilename = argv[2];
52         DWORD aFormat = mmioFOURCC('X','V','I','D');
53         if (argc > 3) {
54           const char * aFourcc = argv[3];
55           aFormat = mmioFOURCC(aFourcc[0], aFourcc[1], aFourcc[2], aFourcc[3]);
56         }
57         pAviWriter = new OpenGl_AVIWriter (aFilename, aFormat, 25);
58         aResult = 0;
59       }
60     } else if (pAviWriter == 0L) {
61       cout << "AVI Writer instance has not been initialized. Use command "
62            << argv[0] << " file ..." << endl;
63     } else if (strncmp(argv[1], "start", 6) == 0) {
64       pAviWriter->StartRecording (aView->Window()->NativeHandle());
65       aResult = 0;
66     } else if (strncmp(argv[1], "stop", 5) == 0) {
67       pAviWriter->StopRecording();
68       aResult = 0;
69     } else if (strncmp(argv[1], "save", 5) == 0) {
70       pAviWriter->StopRecording();
71       delete pAviWriter;
72       pAviWriter = 0L;
73       aResult = 0;
74     } else if (strncmp(argv[1], "status", 7) == 0) {
75       cout << pAviWriter->GetLastErrorMessage() << endl;
76       aResult = 0;
77     }
78   #else
79     cout << "AVI writer capability was disabled\n";
80   #endif
81 #else
82   cout << "AVI writer is implemented only in Windows version\n";
83 #endif
84   return aResult;
85 }
86
87 //=======================================================================
88 //function : AviCommands
89 //purpose  : 
90 //=======================================================================
91
92 void ViewerTest::AviCommands(Draw_Interpretor& theCommands)
93 {
94   const char* group = "ViewerTest AVI commands";
95
96   theCommands.Add("vrecord", "vrecord [option]\n"
97                   "where [option] can be:\n"
98                   "\tfile <filename.avi> <FOURCC=VIDX': Create AVI file "
99                                          "for recording,\n"
100                   "\tstart              : begin/restart recording,\n"
101                   "\tstop               : stop recording,\n"
102                   "\tstatus             : log error message,\n"
103                   "\tsave               : close the AVI file\n",
104                   __FILE__,
105                   &avi_record, group); //Draft_Modification
106 }