Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CmdLabel.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: CmdLabel.C,v $
00013  *      $Author: johns $        $Locker:  $                $State: Exp $
00014  *      $Revision: 1.70 $      $Date: 2019/01/17 21:20:58 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * Command objects used to create, list, delete, or graph labels for measuring
00020  * geometries.
00021  *
00022  ***************************************************************************/
00023 
00024 #include <string.h>
00025 #include <ctype.h>
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include "config.h"
00029 #include "CmdLabel.h"
00030 #include "utilities.h"
00031 #include "Inform.h"
00032 
00033 // The following uses the Cmdtypes LABEL_ADD, LABEL_SHOW, LABEL_LIST,
00034 // and LABEL_DELETE from the Command class
00035 
00037 CmdLabelAddspring::CmdLabelAddspring(int themol, int theatom1, int theatom2,
00038                                float thek) :
00039         Command(LABEL_ADDSPRING) {
00040   /* initialize the member variables */
00041   molid = themol;
00042   atom1 = theatom1;
00043   atom2 = theatom2;
00044   k = thek;
00045 }
00046 
00047 void CmdLabelAddspring::create_text() {
00048   *cmdText << "label addspring " << molid << " " << atom1 << " "
00049            << atom2 << " " << k << ends;
00050 }
00051 
00053 CmdLabelAdd::CmdLabelAdd(const char *geomcat, int n, int *middata, 
00054                          int *atmdata) 
00055 : Command(LABEL_ADD) {
00056 
00057   sprintf(geomcatStr, "%s ", geomcat);
00058   num_geomitems = n;
00059   for (int j=0; j<n; j++) {
00060     char buf[50];
00061     sprintf(buf,"%d/%d",middata[j], atmdata[j]); 
00062     geomitems[j] = stringdup(buf);
00063   }
00064 }
00065 
00066 void CmdLabelAdd::create_text(void) {
00067   *cmdText << "label add " << geomcatStr;
00068   for (int i=0; i<num_geomitems; i++)
00069     *cmdText << geomitems[i] << " ";
00070   *cmdText << ends;
00071 }
00072 
00073 CmdLabelAdd::~CmdLabelAdd(void) {
00074   for (int i=0; i<num_geomitems; i++)  
00075     delete [] geomitems[i];
00076 }
00077 
00078 
00080 CmdLabelShow::CmdLabelShow(const char *geomcat, int n, int s) :
00081         Command(LABEL_SHOW), item(n), show(s) {
00082   sprintf(geomcatStr, "%s", geomcat);
00083 }
00084 
00085 void CmdLabelShow::create_text(void) {
00086   *cmdText << "label " << (show ? "show" : "hide") << " " << geomcatStr;
00087   if(item >= 0)
00088     *cmdText << " " << item;
00089   *cmdText << ends;
00090 }
00091 
00093 CmdLabelDelete::CmdLabelDelete(const char *geomcat, int n) :
00094         Command(LABEL_DELETE), item(n) {
00095   sprintf(geomcatStr, "%s", geomcat);
00096 }
00097 
00098 void CmdLabelDelete::create_text(void) {
00099   *cmdText << "label delete " << geomcatStr;
00100   if (item >= 0)
00101     *cmdText << " " << item;
00102   *cmdText << ends;
00103 }
00104 
00105 void CmdLabelTextSize::create_text() {
00106   *cmdText << "label textsize " << size << ends;
00107 }
00108 
00109 void CmdLabelTextThickness::create_text() {
00110   *cmdText << "label textthickness " << thickness << ends;
00111 }
00112 
00113 CmdLabelTextOffset::CmdLabelTextOffset(const char *name, int ind, float x, float y)
00114 : Command(LABEL_TEXTSIZE), n(ind), m_x(x), m_y(y) {
00115   nm = stringdup(name);
00116 }
00117 CmdLabelTextOffset::~CmdLabelTextOffset() {
00118   delete [] nm;
00119 }
00120 
00121 void CmdLabelTextOffset::create_text() {
00122   *cmdText << "label textoffset " << (const char *)nm << " " << n << " { " << m_x << " " << m_y << " } " << ends;
00123 }
00124 
00125 CmdLabelTextFormat::CmdLabelTextFormat(const char *name, int ind, 
00126     const char *fmt)
00127 : Command(LABEL_TEXTSIZE), n(ind) {
00128   nm = stringdup(name);
00129   format = stringdup(fmt);
00130 }
00131 CmdLabelTextFormat::~CmdLabelTextFormat() {
00132   delete [] nm;
00133   delete [] format;
00134 }
00135 
00136 void CmdLabelTextFormat::create_text() {
00137   *cmdText << "label textformat " << (const char *)nm << " " << n 
00138            << " { " << format << " " << " } " << ends;
00139 }
00140 

Generated on Fri Oct 4 02:43:29 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002