1    	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2    	/*                                                                           */
3    	/*                  This file is part of the program and library             */
4    	/*         SCIP --- Solving Constraint Integer Programs                      */
5    	/*                                                                           */
6    	/*  Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB)                      */
7    	/*                                                                           */
8    	/*  Licensed under the Apache License, Version 2.0 (the "License");          */
9    	/*  you may not use this file except in compliance with the License.         */
10   	/*  You may obtain a copy of the License at                                  */
11   	/*                                                                           */
12   	/*      http://www.apache.org/licenses/LICENSE-2.0                           */
13   	/*                                                                           */
14   	/*  Unless required by applicable law or agreed to in writing, software      */
15   	/*  distributed under the License is distributed on an "AS IS" BASIS,        */
16   	/*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17   	/*  See the License for the specific language governing permissions and      */
18   	/*  limitations under the License.                                           */
19   	/*                                                                           */
20   	/*  You should have received a copy of the Apache-2.0 license                */
21   	/*  along with SCIP; see the file LICENSE. If not visit scipopt.org.         */
22   	/*                                                                           */
23   	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24   	
25   	/**@file   scip_disp.c
26   	 * @ingroup OTHER_CFILES
27   	 * @brief  public methods for display handler plugins
28   	 * @author Tobias Achterberg
29   	 * @author Timo Berthold
30   	 * @author Gerald Gamrath
31   	 * @author Leona Gottwald
32   	 * @author Stefan Heinz
33   	 * @author Gregor Hendel
34   	 * @author Thorsten Koch
35   	 * @author Alexander Martin
36   	 * @author Marc Pfetsch
37   	 * @author Michael Winkler
38   	 * @author Kati Wolter
39   	 *
40   	 * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
41   	 */
42   	
43   	/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
44   	
45   	#include "scip/debug.h"
46   	#include "scip/disp.h"
47   	#include "scip/pub_message.h"
48   	#include "scip/scip_disp.h"
49   	#include "scip/set.h"
50   	#include "scip/struct_mem.h"
51   	#include "scip/struct_scip.h"
52   	#include "scip/struct_set.h"
53   	
54   	/** creates a display column and includes it in SCIP */
55   	SCIP_RETCODE SCIPincludeDisp(
56   	   SCIP*                 scip,               /**< SCIP data structure */
57   	   const char*           name,               /**< name of display column */
58   	   const char*           desc,               /**< description of display column */
59   	   const char*           header,             /**< head line of display column */
60   	   SCIP_DISPSTATUS       dispstatus,         /**< display activation status of display column */
61   	   SCIP_DECL_DISPCOPY    ((*dispcopy)),      /**< copy method of display column or NULL if you don't want to copy your plugin into sub-SCIPs */
62   	   SCIP_DECL_DISPFREE    ((*dispfree)),      /**< destructor of display column */
63   	   SCIP_DECL_DISPINIT    ((*dispinit)),      /**< initialize display column */
64   	   SCIP_DECL_DISPEXIT    ((*dispexit)),      /**< deinitialize display column */
65   	   SCIP_DECL_DISPINITSOL ((*dispinitsol)),   /**< solving process initialization method of display column */
66   	   SCIP_DECL_DISPEXITSOL ((*dispexitsol)),   /**< solving process deinitialization method of display column */
67   	   SCIP_DECL_DISPOUTPUT  ((*dispoutput)),    /**< output method */
68   	   SCIP_DISPDATA*        dispdata,           /**< display column data */
69   	   int                   width,              /**< width of display column (no. of chars used) */
70   	   int                   priority,           /**< priority of display column */
71   	   int                   position,           /**< relative position of display column */
72   	   SCIP_Bool             stripline           /**< should the column be separated with a line from its right neighbor? */
73   	   )
74   	{
75   	   SCIP_DISP* disp;
76   	
77   	   SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeDisp", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
78   	
79   	   /* check whether display column is already present */
80   	   if( SCIPfindDisp(scip, name) != NULL )
81   	   {
82   	      SCIPerrorMessage("display column <%s> already included.\n", name);
83   	      return SCIP_INVALIDDATA;
84   	   }
85   	
86   	   SCIP_CALL( SCIPdispCreate(&disp, scip->set, scip->messagehdlr, scip->mem->setmem,
87   	         name, desc, header, dispstatus,
88   	         dispcopy,
89   	         dispfree, dispinit, dispexit, dispinitsol, dispexitsol, dispoutput, dispdata,
90   	         width, priority, position, stripline) );
91   	   SCIP_CALL( SCIPsetIncludeDisp(scip->set, disp) );
92   	
93   	   return SCIP_OKAY;
94   	}
95   	
96   	/** returns the display column of the given name, or NULL if not existing */
97   	SCIP_DISP* SCIPfindDisp(
98   	   SCIP*                 scip,               /**< SCIP data structure */
99   	   const char*           name                /**< name of display column */
100  	   )
101  	{
102  	   assert(scip != NULL);
103  	   assert(scip->set != NULL);
104  	   assert(name != NULL);
105  	
106  	   return SCIPsetFindDisp(scip->set, name);
107  	}
108  	
109  	/** returns the array of currently available display columns */
110  	SCIP_DISP** SCIPgetDisps(
111  	   SCIP*                 scip                /**< SCIP data structure */
112  	   )
113  	{
114  	   assert(scip != NULL);
115  	   assert(scip->set != NULL);
116  	
117  	   return scip->set->disps;
118  	}
119  	
120  	/** returns the number of currently available display columns */
121  	int SCIPgetNDisps(
122  	   SCIP*                 scip                /**< SCIP data structure */
123  	   )
124  	{
125  	   assert(scip != NULL);
126  	   assert(scip->set != NULL);
127  	
128  	   return scip->set->ndisps;
129  	}
130  	
131  	/** automatically selects display columns for being shown w.r.t. the display width parameter */
132  	SCIP_RETCODE SCIPautoselectDisps(
133  	   SCIP*                 scip                /**< SCIP data structure */
134  	   )
135  	{
136  	   assert(scip != NULL);
137  	   assert(scip->set != NULL);
138  	
139  	   SCIP_CALL( SCIPdispAutoActivate(scip->set) );
140  	
141  	   return SCIP_OKAY;
142  	}
143  	
144  	/** changes the display column mode */
145  	void SCIPchgDispMode(
146  	   SCIP_DISP*            disp,               /**< display column */
147  	   SCIP_DISPMODE         mode                /**< the display column mode */
148  	   )
149  	{
150  	   assert(disp != NULL);
151  	
152  	   SCIPdispChgMode(disp, mode);
153  	}
154